/* called after each xml reload */ void stats_global (ice_config_t *config) { stats_event_flags (NULL, "server_id", config->server_id, STATS_GENERAL); stats_event_flags (NULL, "host", config->hostname, STATS_GENERAL); stats_event (NULL, "location", config->location); stats_event (NULL, "admin", config->admin); thread_spin_lock (&global.spinlock); global.max_rate = config->max_bandwidth; throttle_sends = 0; thread_spin_unlock (&global.spinlock); }
void fserve_initialize(void) { if (fserve_running) return; ice_config_t *config = config_get_config(); mimetypes = NULL; thread_spin_create (&pending_lock); #ifndef HAVE_PREAD thread_mutex_create (&seekread_lock); #endif fh_cache = avl_tree_new (_compare_fh, NULL); fserve_recheck_mime_types (config); config_release_config(); stats_event_flags (NULL, "file_connections", "0", STATS_COUNTERS); fserve_running = 1; memset (&no_file, 0, sizeof (no_file)); thread_mutex_create (&no_file.lock); no_file.clients = avl_tree_new (client_compare, NULL); no_file.refcount = 1; no_file.expire = (time_t)-1; no_file.f = -1; avl_insert (fh_cache, &no_file); INFO0("file serving started"); }
void stats_event_time (const char *mount, const char *name, int flags) { time_t now = time(NULL); char buffer[100]; util_get_clf_time (buffer, sizeof (buffer), now); stats_event_flags (mount, name, buffer, flags); }
void stats_event_time (const char *mount, const char *name, int flags) { time_t now = time(NULL); struct tm local; char buffer[100]; localtime_r (&now, &local); strftime (buffer, sizeof (buffer), ICECAST_TIME_FMT, &local); stats_event_flags (mount, name, buffer, flags); }
void stats_initialize(void) { if (_stats_running) return; /* set up global struct */ _stats.global_tree = avl_tree_new(_compare_stats, NULL); _stats.source_tree = avl_tree_new(_compare_source_stats, NULL); _stats.event_listeners = NULL; thread_mutex_create (&_stats.listeners_lock); _stats_running = 1; stats_event_time (NULL, "server_start", STATS_GENERAL); /* global currently active stats */ stats_event_flags (NULL, "clients", "0", STATS_COUNTERS); stats_event_flags (NULL, "connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "sources", "0", STATS_COUNTERS); stats_event_flags (NULL, "stats", "0", STATS_COUNTERS); stats_event_flags (NULL, "banned_IPs", "0", STATS_COUNTERS); stats_event (NULL, "listeners", "0"); #ifdef GIT_VERSION stats_event (NULL, "build", GIT_VERSION); #endif /* global accumulating stats */ stats_event_flags (NULL, "client_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "source_client_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "source_relay_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "source_total_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "stats_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "listener_connections", "0", STATS_COUNTERS); stats_event_flags (NULL, "outgoing_kbitrate", "0", STATS_COUNTERS|STATS_REGULAR); stats_event_flags (NULL, "stream_kbytes_sent", "0", STATS_COUNTERS|STATS_REGULAR); stats_event_flags (NULL, "stream_kbytes_read", "0", STATS_COUNTERS|STATS_REGULAR); }
static int do_yp_touch (ypdata_t *yp, char *s, unsigned len) { unsigned listeners = 0, max_listeners = 1; char *val, *artist, *title; int ret; artist = (char *)stats_get_value (yp->mount, "artist"); title = (char *)stats_get_value (yp->mount, "title"); if (artist || title) { char *song; char *separator = " - "; if (artist == NULL) { artist = strdup(""); separator = ""; } if (title == NULL) title = strdup(""); song = malloc (strlen (artist) + strlen (title) + strlen (separator) +1); if (song) { sprintf (song, "%s%s%s", artist, separator, title); add_yp_info(yp, song, YP_CURRENT_SONG); stats_event_flags (yp->mount, "yp_currently_playing", song, STATS_COUNTERS); free (song); } } free (artist); free (title); val = (char *)stats_get_value (yp->mount, "listeners"); if (val) { listeners = atoi (val); free (val); } val = stats_get_value (yp->mount, "max_listeners"); if (val == NULL || strcmp (val, "unlimited") == 0 || atoi(val) < 0) max_listeners = client_limit; else max_listeners = atoi (val); free (val); val = stats_get_value (yp->mount, "subtype"); if (val) { add_yp_info (yp, val, YP_SUBTYPE); free (val); } ret = snprintf (s, len, "action=touch&sid=%s&st=%s" "&listeners=%u&max_listeners=%u&stype=%s\r\n", yp->sid, yp->current_song, listeners, max_listeners, yp->subtype); if (ret >= (signed)len) return ret+1; /* space required for above text and nul*/ if (send_to_yp ("touch", yp, s) == 0) { yp_schedule (yp, yp->touch_interval); return 0; } return -1; }