Commit 9b823cb8 authored by Thomas B. Rücker's avatar Thomas B. Rücker 😊

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
parent 09fdaed7
......@@ -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);
......
......@@ -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");
......
......@@ -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);
......
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