Hi guys, radioadmin here. Kosmonauten asked me recently if there was a possibility to gather statistics from the radio streams, and I said no. Turns out that was a lie. This week i created a script which uses the same json data which Icecast provides and Ernstadmin uses for frontpage integration to gather some data about ongoing streams, and it works like this: there's a cronjob which every 5 minutes polls the current json data from Icecast, and afterwards calls a PHP script to process the data. The script checks if at least one stream is active. If not, it does nothing. If yes, roughly the following is happening:
- if the streamer doesn't exist (has never been seen by the script before), he will be created in the stats database
- if there is no active stream present for the streamer, the stream will be created in the database with the information: streamer, starting time, end time (the current time), stream name, stream description, max listeners
- if there is an active stream for this streamer (an entry for this streamer in the database not older than 15 minutes and with the same stream name), then this entry will be updated with the new end time and - if larger than before - the new max listeners-value.
The data is stored in a local SQLite-DB. In addition, there is a view which shows all the stats I already have collected: http://radio.ernstchan.xyz/statview.php
This page is provided by a local Apache server and not via Icecast, that's why it's port 80 and not 8000. I'll probably fiddle around with this a lot in the next days, so don't be too surprised if things change from time to time. Also don't be surprised if the whole thing melts down a lot, since it's literally helphelper-style development - especially when strange chars are in the stream metadata or if there's more than one stream ongoing. Also feel free to name your streams "my stream;drop database statistics;" from now on, I have implemented some very professional* protection against this.
*might not actually be very professional