Commit ab75a329 authored by Karl Heyes's avatar Karl Heyes

add global listeners stat

svn path=/icecast/trunk/icecast/; revision=14016
parent dcffbb38
......@@ -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");
}
......
......@@ -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;
}
......
......@@ -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");
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment