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

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

Michael Smith's avatar
Michael Smith committed
24

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

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

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

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

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

} stats_t;

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

Karl Heyes's avatar
Karl Heyes committed
77
void stats_global(ice_config_t *config);
78
stats_t *stats_get_stats(void);
79
refbuf_t *stats_get_streams (void);
80
void stats_clear_virtual_mounts (void);
Jack Moffitt's avatar
Jack Moffitt committed
81

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

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

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

#endif  /* __STATS_H__ */