[Icecast] IceCast Listenter Count Stat - BASH or php?
Jeroen van Oosten
jvoosten at bankai.nl
Mon Mar 12 21:07:34 UTC 2018
Hello,
On 08-03-18 05:54, ScanCaster wrote:
> Is there some simple way to get just the listener count on mounts out of
> IceCast, specifically 2.4.1
>
> Via BASH preferred, or CLI php if I must, I guess python 2.x would be an
> option too. (3.x is not an option though!)
>
> All the stuff I've seen is scrapping things from the status.xsl, which is
> bad form.
Well, you can create your own XSL with less data. I use this (as
web/simple.xsl):
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0" >
<xsl:output omit-xml-declaration="no" method="text"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes" encoding="UTF-8" />
<xsl:template match = "/icestats" >MountPoint,Connections,Stream
Name,Current Listeners,Description,Currently Playing,Stream URL
Global,Client:<xsl:value-of select="connections" /> Source:
<xsl:value-of select="source_connections" />,,<xsl:value-of
select="listeners" />,,
<xsl:for-each select="source">
<xsl:value-of select="@mount" />,,<xsl:value-of select="name"
/>,<xsl:value-of select="listeners" />,<xsl:value-of
select="description" />,<xsl:value-of select="artist" /> - <xsl:value-of
select="title" />,<xsl:value-of select="url" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
...which looks complex but spits out a comma-separated list of values:
MountPoint,Connections,Stream Name,Current Listeners,Description,Currently Playing,Stream URL
Global,Client:2338283 Source: ,,3,,
/high.aac,,,1,, - Sheppard - Geronimo,
/high.mp3,,,2,, - Sheppard - Geronimo,
/low.aac,,,0,, - Sheppard - Geronimo,
/shoutcast.mp3,,,0,, - ,
If necessary you can trim down the data even more to just:
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
version = "1.0" >
<xsl:output omit-xml-declaration="no" method="text"
doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
indent="yes" encoding="UTF-8" />
<xsl:template match = "/icestats" >
<xsl:for-each select="source">
<xsl:value-of select="@mount" /><xsl:value-of select="listeners" />
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
> I really just need the listener count, and something I can run say every
> 2-3 minutes via CRON job. Also note, any solution has to work on Linux, I
> do not use any non Linux platforms.
Upload your XSL, then:
$ wget -q -O simple.txt http://your.radio.station:port/simple.xsl
Or output to stdout and pipe it into whatever you want.
Regards,
- Jeroen
--
Bankai Software bv
Jeroen van Oosten
Telefoon: 088-2344999
E-mail: jvoosten at bankai.nl
KvK inschrijving: 67066267
PGP key: B2308F8E
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." --Red Adair
More information about the Icecast
mailing list