stats.h 2.58 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__

16 17 18 19
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

20 21
#include "icecasttypes.h"
#include "refbuf.h"
Michael Smith's avatar
Michael Smith committed
22

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

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

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

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

typedef struct _stats_tag
{
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
    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
69 70 71

} stats_t;

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

75
void stats_global(ice_config_t *config);
76
stats_t *stats_get_stats(void);
77
refbuf_t *stats_get_streams (void);
78
void stats_clear_virtual_mounts (void);
Jack Moffitt's avatar
Jack Moffitt committed
79

80
void stats_event(const char *source, const char *name, const char *value);
81 82
void stats_event_conv(const char *mount, const char *name,
        const char *value, const char *charset);
83 84 85
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);
Karl Heyes's avatar
Karl Heyes committed
86
void stats_event_sub(const char *source, const char *name, unsigned long value);
87
void stats_event_dec(const char *source, const char *name);
88
void stats_event_hidden (const char *source, const char *name, int hidden);
Karl Heyes's avatar
Karl Heyes committed
89
void stats_event_time (const char *mount, const char *name);
90
void stats_event_time_iso8601 (const char *mount, const char *name);
Jack Moffitt's avatar
Jack Moffitt committed
91 92

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

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

#endif  /* __STATS_H__ */