stats.h 2.09 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_connection_tag
{
26 27
    connection_t *con;
    http_parser_t *parser;
Jack Moffitt's avatar
Jack Moffitt committed
28 29 30 31
} stats_connection_t;

typedef struct _stats_node_tag
{
32 33
    char *name;
    char *value;
Jack Moffitt's avatar
Jack Moffitt committed
34 35 36 37
} stats_node_t;

typedef struct _stats_event_tag
{
38 39 40
    char *source;
    char *name;
    char *value;
41
    int  action;
Jack Moffitt's avatar
Jack Moffitt committed
42

43
    struct _stats_event_tag *next;
Jack Moffitt's avatar
Jack Moffitt committed
44 45 46 47
} stats_event_t;

typedef struct _stats_source_tag
{
48 49
    char *source;
    avl_tree *stats_tree;
Jack Moffitt's avatar
Jack Moffitt committed
50 51 52 53
} stats_source_t;

typedef struct _stats_tag
{
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    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
73 74 75 76 77 78 79 80

} stats_t;

void stats_initialize();
void stats_shutdown();

stats_t *stats_get_stats();

81 82 83 84 85
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);
Jack Moffitt's avatar
Jack Moffitt committed
86 87

void *stats_connection(void *arg);
88
void *stats_callback(void *arg);
Jack Moffitt's avatar
Jack Moffitt committed
89

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

#endif  /* __STATS_H__ */