stats.h 2.34 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

Jack Moffitt's avatar
Jack Moffitt committed
13 14 15
#ifndef __STATS_H__
#define __STATS_H__

Michael Smith's avatar
Michael Smith committed
16
#include "connection.h"
Karl Heyes's avatar
Karl Heyes committed
17
#include "httpp/httpp.h"
Michael Smith's avatar
Michael Smith committed
18
#include "client.h"
19 20 21 22
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

Michael Smith's avatar
Michael Smith committed
23

Jack Moffitt's avatar
Jack Moffitt committed
24 25
typedef struct _stats_node_tag
{
26 27
    char *name;
    char *value;
28
    int hidden;
Jack Moffitt's avatar
Jack Moffitt committed
29 30 31 32
} stats_node_t;

typedef struct _stats_event_tag
{
33 34 35
    char *source;
    char *name;
    char *value;
36
    int  hidden;
37
    int  action;
Jack Moffitt's avatar
Jack Moffitt committed
38

39
    struct _stats_event_tag *next;
Jack Moffitt's avatar
Jack Moffitt committed
40 41 42 43
} stats_event_t;

typedef struct _stats_source_tag
{
44
    char *source;
45
    int  hidden;
46
    avl_tree *stats_tree;
Jack Moffitt's avatar
Jack Moffitt committed
47 48 49 50
} stats_source_t;

typedef struct _stats_tag
{
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
    avl_tree *global_tree;

    /* global stats
    start_time
    total_users
    max_users
    total_sources
    max_sources
    total_user_connections
    total_source_connections
    */

    avl_tree *source_tree;

    /* stats by source, and for stats
    start_time
    total_users
    max_users
    */
Jack Moffitt's avatar
Jack Moffitt committed
70 71 72

} stats_t;

73 74
void stats_initialize(void);
void stats_shutdown(void);
Jack Moffitt's avatar
Jack Moffitt committed
75

76
stats_t *stats_get_stats(void);
77
void stats_get_streamlist (char *buffer, size_t remaining);
78
void stats_clear_virtual_mounts (void);
Jack Moffitt's avatar
Jack Moffitt committed
79

80 81 82 83 84
void stats_event(const char *source, const char *name, const char *value);
void stats_event_args(const char *source, char *name, char *format, ...);
void stats_event_inc(const char *source, const char *name);
void stats_event_add(const char *source, const char *name, unsigned long value);
void stats_event_dec(const char *source, const char *name);
85
void stats_event_hidden (const char *source, const char *name, int hidden);
Karl Heyes's avatar
Karl Heyes committed
86
void stats_event_time (const char *mount, const char *name);
Jack Moffitt's avatar
Jack Moffitt committed
87 88

void *stats_connection(void *arg);
89
void stats_callback (client_t *client, void *notused);
Jack Moffitt's avatar
Jack Moffitt committed
90

91
void stats_transform_xslt(client_t *client, const char *uri);
Jack Moffitt's avatar
Jack Moffitt committed
92
void stats_sendxml(client_t *client);
93
void stats_get_xml(xmlDocPtr *doc, int show_hidden, const char *show_mount);
94
char *stats_get_value(char *source, char *name);
Jack Moffitt's avatar
Jack Moffitt committed
95 96 97 98 99 100 101

#endif  /* __STATS_H__ */