Icecast monitoring with cacti

I needed to monitor an icecast server with cacti.

So, searching the web for ready-to-use cacti templates, I found some solutions:

I finally used the latter one.

Unfortunately, the author didn’t have time enough to describe all the tricks of the installation, and a yet old version of cacti (0.8.7a) was used – even though cacti hasn’t changed too much in last ten years, and I respect it for that :-)

Actual cacti version is 0.8.8b, but also previous releases like 0.8.7i can be found on long-term support distros like for example Ubuntu 12.04 LTS.

I’ve managed to finally install the bundle, so I’ll describe the step by step process here… I hope I didn’t forget anything, but I cannot assure it: there are some points where I’ll check things just in case:

First of all, I get rid of one template used for aggregating graphs and all its related steps, as that can now easily be done with the “aggregate” plugin. The “aggregate” plugin needs to previously install the plugin architecture, unless you use the 0.8.8 version or higher, which includes it. As it is easy to install and configure, I clearly recommend it.

The original zip has one problem in a php file (icecast_v2_xml.php) which didn’t has the “<?php” tag beggining, but just a “<?“, which can made it to fail if you don’t have the correct php configuration to manage it.

I’ve deleted the Data Query template (cacti_data_query_unix_-_get_icecast_mounts.xml) from the bundle, as I had to manually create it.

2015/12 Edit: I’ve updated the script to v2.2 (some php functions were obsolete for PHP > 5.3).

Here is the modified bundle: cacti-icecast-v2.2.tar.gz

The first step is to copy the files under “./cacti” to the cacti installation under the same paths:




Modify the file “resource/script_queries/unix_icecast2.xml” with your correct user and password to access your icecast server:

<arg_prepend>|host_hostname| YOUR_USER YOUR_PASSWORD 8001</arg_prepend>

Fill only your user, password and icecast’s port. Check that there’s an space between all values. The value for your host name will be automatically retrieved when we create a new cacti Device later: that’s why it’s between vertical bars (it’s a cacti “variable”).

If your icecast installation uses a different port than 8001, modify it there also.

Note that doing this in a template will make all your icecast servers on cacti (if more than one) share the user/password. The original page states some advices if you need to change this behaviour. In fact, cacti allows a per-device parameter configuration, but as I just had one device, I didn’t cope with it.

Next, import the provided templates from the “Import…” button of cacti administration:



They’ll probably rise errors. We’ll ignore them by now.

Create a new “Data Query” with this data:

Name Unix – Get Icecast Mounts
Description Queries a list of mounted streams with a php script
XML Path <path_cacti>/resource/script_queries/unix_icecast2.xml
Data Input Method Get Script Data (Indexed) [chosen from the dropdown]

and under “Associated Graph Templates” add:

Name Icecast2 Listener per Mountpoint php query
Graph Template Icecast2 Listener per Mountpoint query [chosen from the dropdown]

After creating the Associated Graph Template, click its link, and fill this in the next screen ([x] represents a checked checkbox control):

Associated Data Templates
Data Template – Icecast2 per mount query
Data Source: icecast_byteread icebyteread (Bytes Read) [x]
Data Source: icecast_bytesent icebytesent (Bytes Sent) [x]
Data Source: icecast_listeners icelisteners (Current Listener) [x]
Data Source: icecast_list_peak icelistenerspeak (Listener Peak)[x]

After saving, check on previous screen these checkboxes:

Custom Data [data input: Get Script Data (Indexed)]
Index Type
[x] Use Per-Data Source Value (Ignore this Value)
Index Value
[x] Use Per-Data Source Value (Ignore this Value)
Output Type ID
[x] Use Per-Data Source Value (Ignore this Value)

Now go to the Graph Template “Icecast2 Listener per Mountpoint query” and make sure that there are just four items under “Graph Item Inputs”. If there are more, click on each one of then, and if it has no “Associated Graph Item” selected, DELETE it on the previous screen with the red “x” icon on its row.

Now, cacti configuration should be done.

Create a new Device, with proper name and hostname. It is not necessary to select a Host Type: just add a new item under “Associated Data Queries” by selecting “Unix – Get Icecast Mounts” on the dropdown control and clicking “Add”.

Clicking on “(Verbose Query)” should show several “+ Found item” lines. Now you can go to “Create Graphs for this Host” and, if everything is ok, you can now select the appropriate icecast listeners to check with cacti.

Select them, and wait a pair of cacti cycles (5*2 = 10 minutes) in order for the rrd file(s) to be created and populated.

Now go to your graph and see the results. You should an empty -or with just one line- graph.

If there’s no graph at all, go to Console / Devices / your recently created device / Graph List, and click on “Turn On Graph Debug“. Maybe you see somelines ending with:

RRDTool Says:
ERROR: the RRD does not contain an RRA matching the chosen CF

Ok. This is a pretty annoying thing that I think can be corrected on “Data Sources / RRAs” by selecting “LAST” on every item there, but as I’m not sure if that requires a complete graph reboot, let’s patch this this way: go to the Graph Template “Icecast2 Listener per Mountpoint query” and change every Item with a LAST value under “CF Type” for a AVERAGE. Except the “Listener Peak” item: it must be left as LAST or the peak value wouldn’t be shown “as is” from the icecast’s xml, but calculated over time, which would not render a good value.

With these changes, everyhting should be ok.

cacti - mountpoint icecast

cacti - aggregated icecast


4 thoughts on “Icecast monitoring with cacti

  1. I was happy to found this more simplified templates & scripts to monitor our icecast servers with cacti. it works perfekt with more than 100 mountpoints. Even if the script takes a while to get through.

    I use spine within cacti to poll the data. Recently I figured out, that the script takes long time to gather the data. I tested the script by executing the following command :
    /usr/local/spine/bin/spine -R -S -V 3 -C /etc/spine.conf

    This gives me massive outputs, for example :
    PHP Notice: Undefined index: attributes in /var/www/html/cacti-0.8.8b/scripts/icecast2-cacti-query/icecast_v2_class.php on line 104

    PHP Notice: Undefined index: value in /var/www/html/cacti-0.8.8b/scripts/icecast2-cacti-query/icecast_v2_class.php on line 105

    Are you aware of this or do you maybe knows why this PHP Notice shows up in the log files ?
    thank you

  2. Hi Tom,
    Good to hear that the scripts are useful!
    About those “notices”, maybe you have change the name of some icecast channel *after* cacti knew about it?
    I think these scripts index by name, so any change on icecast must be also done later on cacti :-(

    That said, as I haven’t coded this, I don’t know if they’re normal “notices”, (“notice” is the lowest level of warning possible)… They can just be wiped away in order to speed up the execution using a “production environment” error output conf in your php.ini ‘s (/etc/php5/apache2/php.ini , /etc/php5/cli/php.ini …) :
    error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED

    Also, you can manually check that all is ok with your icecast server using:
    /usr/bin/php -q /scripts/icecast2-cacti-query/icecast_v2_xml.php [index | query mountpoint | query listenurl | query mountdesc]

    That will also show you directly at which speed answers are returned by your icecast server.
    Cacti’s log can also be temporarily activated and shown on its admin web in order to see response times and possible errors in output processing.


  3. I followed your steps and all went great except when i click Create Graphs for this Host it dosen’t show anything. What wrong?
    This is when i press the debug mode
    + Running data query [10].
    + Found type = ‘4’ [Script Query].
    + Found data query XML file at ‘C:/wamp/apps/cacti-0.8.8f/resource/script_queries/unix_icecast2.xml’
    + XML file parsed ok.
    + Executing script for num of indexes ‘c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php |*.*.*.*|admin **** *796* num_indexes’
    + Executing script for list of indexes ‘c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php |*.*.*.*|admin **** *796* index’ Index Count: 0
    + Executing script query ‘c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php |*.*.*.*|admin **** *796* query mountpoint’
    + Executing script query ‘c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php |*.*.*.*|admin**** *796* query listenurl’
    + Executing script query ‘c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php |*.*.*.*|admin **** *796* query mountdesc’

    I run icecast server. Thank you

    • Hi krom,
      It seems from the line with “Index Count: 0” that something is wrong in the communication between the host where cacti is executed and the host with icecast.
      Maybe the icecast server IP is not correctly written (there shouldn’t be vertical bars around the IP (?)), the user/password is wrong, or maybe the tcp port is incorrect, or maybe it is not opened (firewalls, etc). Also check on your icecast server that that port is opened and used for icecast.
      Try to execute this command at MS-DOS prompt checking all these possibilities until it returns a number different from ‘0’:

      c:\wamp\bin\php\php5.5.12\php.exe -q C:\wamp\apps\cacti-0.8.8f\scripts\icecast2-cacti-query\icecast_v2_xml.php IP admin PWD PORT index

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s