stats.h 1.29 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 5 6 7
#include "connection.h"
#include "httpp.h"
#include "client.h"

Jack Moffitt's avatar
Jack Moffitt committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
typedef struct _stats_connection_tag
{
	connection_t *con;
	http_parser_t *parser;
} stats_connection_t;

typedef struct _stats_node_tag
{
	char *name;
	char *value;
} stats_node_t;

typedef struct _stats_event_tag
{
	char *source;
	char *name;
	char *value;

	struct _stats_event_tag *next;
} stats_event_t;

typedef struct _stats_source_tag
{
	char *source;
	avl_tree *stats_tree;
} stats_source_t;

typedef struct _stats_tag
{
	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
	*/

} 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);
71
void *stats_callback(void *arg);
Jack Moffitt's avatar
Jack Moffitt committed
72 73 74 75 76 77 78 79 80

void stats_sendxml(client_t *client);

#endif  /* __STATS_H__ */