stats.h 1.59 KB
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1 2 3
#ifndef __STATS_H__
#define __STATS_H__

Michael Smith's avatar
Michael Smith committed
4
#include "connection.h"
Karl Heyes's avatar
Karl Heyes committed
5
#include "httpp/httpp.h"
Michael Smith's avatar
Michael Smith committed
6
#include "client.h"
7 8 9 10
#include <libxml/xmlmemory.h>
#include <libxml/parser.h>
#include <libxml/tree.h>

Michael Smith's avatar
Michael Smith committed
11

Jack Moffitt's avatar
Jack Moffitt committed
12 13
typedef struct _stats_connection_tag
{
14 15
    connection_t *con;
    http_parser_t *parser;
Jack Moffitt's avatar
Jack Moffitt committed
16 17 18 19
} stats_connection_t;

typedef struct _stats_node_tag
{
20 21
    char *name;
    char *value;
Jack Moffitt's avatar
Jack Moffitt committed
22 23 24 25
} stats_node_t;

typedef struct _stats_event_tag
{
26 27 28
    char *source;
    char *name;
    char *value;
Jack Moffitt's avatar
Jack Moffitt committed
29

30
    struct _stats_event_tag *next;
Jack Moffitt's avatar
Jack Moffitt committed
31 32 33 34
} stats_event_t;

typedef struct _stats_source_tag
{
35 36
    char *source;
    avl_tree *stats_tree;
Jack Moffitt's avatar
Jack Moffitt committed
37 38 39 40
} stats_source_t;

typedef struct _stats_tag
{
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
    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
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

} stats_t;

void stats_initialize();
void stats_shutdown();

stats_t *stats_get_stats();

void stats_event(char *source, char *name, char *value);
void stats_event_args(char *source, char *name, char *format, ...);
void stats_event_inc(char *source, char *name);
void stats_event_add(char *source, char *name, unsigned long value);
void stats_event_dec(char *source, char *name);

void *stats_connection(void *arg);
75
void *stats_callback(void *arg);
Jack Moffitt's avatar
Jack Moffitt committed
76

77
void stats_transform_xslt(client_t *client, char *xslpath);
Jack Moffitt's avatar
Jack Moffitt committed
78
void stats_sendxml(client_t *client);
79
void stats_get_xml(xmlDocPtr *doc);
80
char *stats_get_value(char *source, char *name);
Jack Moffitt's avatar
Jack Moffitt committed
81 82 83 84 85 86 87

#endif  /* __STATS_H__ */