1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-22 04:15:54 -04:00

update a few stats

svn path=/icecast/trunk/icecast/; revision=9437
This commit is contained in:
Karl Heyes 2005-06-11 01:24:58 +00:00
parent 554649cf01
commit 29c83ae4eb
5 changed files with 29 additions and 2 deletions

View File

@ -487,6 +487,7 @@ int connection_complete_source (source_t *source)
}
global.sources++;
stats_event_args (NULL, "sources", "%d", global.sources);
global_unlock();
/* for relays, we don't yet have a client, however we do require one

View File

@ -546,6 +546,9 @@ static void send_to_listener (source_t *source, client_t *client, int deletion_e
}
/* Perform any initialisation just before the stream data is processed, the header
* info is processed by now and the format details are setup
*/
static void source_init (source_t *source)
{
ice_config_t *config = config_get_config();
@ -577,6 +580,8 @@ static void source_init (source_t *source)
free(listenurl);
}
stats_event_args (source->mount, "listener_peak", "0");
if (source->dumpfilename != NULL)
{
source->dumpfile = fopen (source->dumpfilename, "ab");
@ -592,9 +597,10 @@ static void source_init (source_t *source)
/* start off the statistics */
source->listeners = 0;
stats_event_inc (NULL, "sources");
stats_event_inc (NULL, "source_total_connections");
stats_event (source->mount, "slow_listeners", "0");
stats_event (source->mount, "listener_peak", "0");
stats_event_time (source->mount, "stream_start");
if (source->client->con)
sock_set_blocking (source->con->sock, SOCK_NONBLOCK);
@ -754,6 +760,11 @@ void source_main (source_t *source)
if (source->listeners != listeners)
{
INFO2("listener count on %s now %lu", source->mount, source->listeners);
if (source->listeners > source->peak_listeners)
{
source->peak_listeners = source->listeners;
stats_event_args (source->mount, "listener_peak", "%lu", source->peak_listeners);
}
stats_event_args (source->mount, "listeners", "%lu", source->listeners);
if (source->listeners == 0 && source->on_demand)
source->running = 0;
@ -820,7 +831,6 @@ static void source_shutdown (source_t *source)
}
/* delete this sources stats */
stats_event_dec(NULL, "sources");
stats_event(source->mount, NULL, NULL);
/* we don't remove the source from the tree here, it may be a relay and
@ -829,6 +839,7 @@ static void source_shutdown (source_t *source)
global_lock();
global.sources--;
stats_event_args (NULL, "sources", "%d", global.sources);
global_unlock();
/* release our hold on the lock so the main thread can continue cleaning up */

View File

@ -51,6 +51,7 @@ typedef struct source_tag
char *dumpfilename; /* Name of a file to dump incoming stream to */
FILE *dumpfile;
unsigned long peak_listeners;
unsigned long listeners;
long max_listeners;
int yp_public;

View File

@ -533,6 +533,18 @@ static void process_source_event (stats_event_t *event)
}
void stats_event_time (const char *mount, const char *name)
{
time_t now = time(NULL);
struct tm local;
char buffer[100];
localtime_r (&now, &local);
strftime (buffer, sizeof (buffer), "%a, %d %b %Y %H:%M:%S %z", &local);
stats_event (mount, name, buffer);
}
static void *_stats_thread(void *arg)
{
stats_event_t *event;
@ -540,6 +552,7 @@ static void *_stats_thread(void *arg)
event_listener_t *listener;
stats_event (NULL, "server", ICECAST_VERSION_STRING);
stats_event_time (NULL, "server_start");
/* global currently active stats */
stats_event (NULL, "clients", "0");

View File

@ -81,6 +81,7 @@ 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);
void stats_event_hidden (const char *source, const char *name, int hidden);
void stats_event_time (const char *mount, const char *name);
void *stats_connection(void *arg);
void *stats_callback(void *arg);