1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-23 06:25:24 +00:00

add global listeners stat

svn path=/icecast/trunk/icecast/; revision=14016
This commit is contained in:
Karl Heyes 2007-10-20 00:58:05 +00:00
parent dcffbb38ad
commit ab75a3297f
4 changed files with 22 additions and 2 deletions

View File

@ -208,6 +208,7 @@ int format_check_http_buffer (source_t *source, client_t *client)
client->con->error = 1;
return -1;
}
stats_event_inc (NULL, "listeners");
stats_event_inc (NULL, "listener_connections");
stats_event_inc (source->mount, "listener_connections");
}

View File

@ -212,6 +212,9 @@ void source_clear_source (source_t *source)
source->dumpfile = NULL;
}
if (source->listeners)
stats_event_sub (NULL, "listeners", source->listeners);
/* lets kick off any clients that are left on here */
while (avl_get_first (source->client_tree))
{
@ -716,6 +719,7 @@ void source_main (source_t *source)
client_node = avl_get_next(client_node);
avl_delete(source->client_tree, (void *)client, _free_client);
source->listeners--;
stats_event_dec (NULL, "listeners");
DEBUG0("Client removed");
continue;
}

View File

@ -49,8 +49,9 @@
#define STATS_EVENT_INC 1
#define STATS_EVENT_DEC 2
#define STATS_EVENT_ADD 3
#define STATS_EVENT_REMOVE 4
#define STATS_EVENT_HIDDEN 5
#define STATS_EVENT_SUB 4
#define STATS_EVENT_REMOVE 5
#define STATS_EVENT_HIDDEN 6
typedef struct _event_queue_tag
{
@ -343,6 +344,18 @@ void stats_event_add(const char *source, const char *name, unsigned long value)
}
}
void stats_event_sub(const char *source, const char *name, unsigned long value)
{
stats_event_t *event = build_event (source, name, NULL);
if (event)
{
event->value = malloc (16);
snprintf (event->value, 16, "%ld", value);
event->action = STATS_EVENT_SUB;
queue_global_event (event);
}
}
/* decrease the value in the provided stat by 1 */
void stats_event_dec(const char *source, const char *name)
{
@ -609,6 +622,7 @@ static void *_stats_thread(void *arg)
stats_event (NULL, "connections", "0");
stats_event (NULL, "sources", "0");
stats_event (NULL, "stats", "0");
stats_event (NULL, "listeners", "0");
/* global accumulating stats */
stats_event (NULL, "client_connections", "0");

View File

@ -85,6 +85,7 @@ void stats_event_conv(const char *mount, const char *name,
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_sub(const char *source, const char *name, unsigned long value);
void stats_event_dec(const char *source, const char *name);
void stats_event_hidden (const char *source, const char *name, int hidden);
void stats_event_time (const char *mount, const char *name);