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

Adding stream_start_iso8601, server_start_iso8601

ISO8601 compliante timestamps for statistics. Should make usage in e.g. JSON
much easier.
Added as new variables to avoid breaking backwards compatibility.

svn path=/icecast/trunk/icecast/; revision=19122
This commit is contained in:
Thomas B. "dm8tbr" Ruecker 2014-05-04 07:14:54 +00:00
parent 09fdaed7e4
commit 9b823cb879
3 changed files with 15 additions and 0 deletions

View File

@ -656,6 +656,7 @@ static void source_init (source_t *source)
stats_event_args (source->mount, "listeners", "%lu", source->listeners);
stats_event_args (source->mount, "listener_peak", "%lu", source->peak_listeners);
stats_event_time (source->mount, "stream_start");
stats_event_time_iso8601 (source->mount, "stream_start_iso8601");
DEBUG0("Source creation complete");
source->last_read = time (NULL);

View File

@ -597,6 +597,18 @@ void stats_event_time (const char *mount, const char *name)
}
void stats_event_time_iso8601 (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), "%FT%T%z", &local);
stats_event (mount, name, buffer);
}
void stats_global (ice_config_t *config)
{
stats_event (NULL, "server_id", config->server_id);
@ -613,6 +625,7 @@ static void *_stats_thread(void *arg)
event_listener_t *listener;
stats_event_time (NULL, "server_start");
stats_event_time_iso8601 (NULL, "server_start_iso8601");
/* global currently active stats */
stats_event (NULL, "clients", "0");

View File

@ -89,6 +89,7 @@ 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);
void stats_event_time_iso8601 (const char *mount, const char *name);
void *stats_connection(void *arg);
void stats_callback (client_t *client, void *notused);