Table of Contents

Icecast+Cricket

Here is a short icecast+cricket monitoring HOWTO. This is the same setup I use in http://icecast.version6.net:8888/status.xsl

Icecast server

Create file rawstats.xsl in icecast web directory (the same place where status.xsl is by default). In my case it is /usr/share/icecast/web/rawstats.xsl

<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output method="text" indent="yes" />
<xsl:template match = "/icestats" >

<xsl:for-each select="source">

<xsl:choose>
<xsl:when test="listeners">
<xsl:value-of select="@mount" />,       <xsl:value-of select="listeners" />
</xsl:when>
<xsl:otherwise>
name: /no-stream        0
</xsl:otherwise>
</xsl:choose>
x
</xsl:for-each>

</xsl:template>
</xsl:stylesheet>''

After that you can go to server:port/rawstats.xsl and should get output like this:

/mania.ogg,	36
x
/okul.ogg,	0
x

Cricket configuration

Collector script

Create file icecast2.sh somewhere in cricket binary tree. I put it into /usr/local/cricket/cricket/util/icecast2.sh

#!/bin/sh

server="$1"
mount="$2"
if [ "z$mount" = "z" ]; then
        echo "usage: $0 <server:port> <mount>" >&2
        exit 1
fi

wget -q -O - -U cricket http://${server}/rawstats.xsl \
        | grep "^${mount}," \
        | cut -d, -f2

Using this script you can query listener number per stream. Here is one example:

sh-2.05$ /usr/local/cricket/cricket/util/icecast2.sh icecast.version6.net:8888 /mania.ogg
        33

Collector configuration

Now you need to set up Cricket configuration to collect this statistics. Create a new subdirectory somewhere under cricket-config and put following two files into it:

Defaults for default collector configuration:

Target  --default--
        directory-desc          = "icecast2 servers"
        snmp-host               = none
        target-type             = icecast2

datasource      --default--
        rrd-ds-type             =       GAUGE
        rrd-heartbeat   =       1800
        rrd-min                 =       undef
        rrd-max                 =       undef

datasource      listeners       ds-source = "exec:0:/usr/local/cricket/cricket/util/icecast2.sh %server% %mount%"

targetType      icecast2
        ds      =       "listeners"
        view    =       "Listeners: listeners"

graph   --default--
        draw-as =       LINE2
        units   =       ""
        si-unit =       false
        y-axis  =       "#"

graph   listeners
        color   =       red
        legend  =       "Clients"

Icecast server configuration file with any name you like. I use icecast.version6.net and this file consists all targets I'd like to monitor:

target  --default--
        server          =       icecast.version6.net:8888

target  icecast.version6.net_8888_mania.ogg
        short-desc      =       http://icecast.version6.net:8888/mania.ogg
        mount           =       /mania.ogg

target  icecast.version6.net_8888_okul.ogg
        short-desc      =       http://icecast.version6.net:8888/okul.ogg
        mount           =       /okul.ogg

That's it. Now just compile new configuration and try it yourself.