View previous topic :: View next topic |
Author |
Message |
GateKeeper Guest
|
Posted: Wed Aug 03, 2005 11:58 am Post subject: Icecast2 telnet-like stats |
|
|
Hi, there. The feature, i'd like to find in icecast2 server - on-line statistics receiving via simple interface such as telnet-based. I don't understand why listclients.xls been copied to public 'web' directory from 'admin' doesn't show per-mount statistics (well, it seems like it's hardcoded into server to request auth for such statistics), but stats need to be got via script.
Please, add a simple text interface to get ollover control and statistics collecting. |
|
Back to top |
|
|
karlH Code Warrior
Joined: 13 Jun 2005 Posts: 5476 Location: UK
|
Posted: Wed Aug 03, 2005 2:36 pm Post subject: Re: Icecast2 telnet-like stats |
|
|
GateKeeper wrote: |
Hi, there. The feature, i'd like to find in icecast2 server - on-line statistics receiving via simple interface such as telnet-based. I don't understand why listclients.xls been copied to public 'web' directory from 'admin' doesn't show per-mount statistics (well, it seems like it's hardcoded into server to request auth for such statistics), but stats need to be got via script.
Please, add a simple text interface to get ollover control and statistics collecting. |
regarding listclients, 2 things, connected listener details are classed as secure, so they should _NOT_ be available via webroot, secondly listener details are not put into the stats tree, so are specially handled by the listclients admin handler. In -kh I populate listener details into the xml tree for /admin access, and your own xsl files can apply to it.
Most stats for the trunk/kh code are available via the stats client eg
curl -X STATS 'http://admin:hackme@host:8000/'
While listener counts changes show up via this, the actual listener details don't currently. |
|
Back to top |
|
|
BWare Guest
|
Posted: Tue Aug 23, 2005 10:28 pm Post subject: |
|
|
Well, a simple php script and an additional xsl file to do something like this would look like the ones below... Only one problem, the usernames, passwords and mountpoint to stat are hardcoded
xsl file to be put in the icecast web directory, for example: /usr/share/icecast/web/all_statistics.xsl...
Code: |
<xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" version = "1.0" >
<xsl:output omit-xml-declaration="no" method="xml" 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" >
<pre>
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:for-each>
</pre>
</xsl:template>
</xsl:stylesheet>
|
PHP script to parse the xsl output and display the outcome and to be placed in your public web directory: icestats.php...
Code: |
<?php
/*
* icestats.php
***************
*
* Connects to icecast server and fetches
* statistical information from all streams
*
* Written by: BWare <bware_at_s4s.dyndns.org>
*/
function http_get( $host, $port, $request="/" ) {
$fp = fsockopen($host, $port);
if (!$fp) {
return false;
} else {
fwrite($fp, "GET $request HTTP/1.0\r\n\r\n");
stream_set_timeout($fp, 3);
$res["data"] = fread($fp, 2000);
$res["meta"] = stream_get_meta_data($fp);
fclose($fp);
if ($res["meta"]['timed_out']) {
return false;
} else {
return $res;
}
}
}
function prep_stats( $stats ) {
foreach( $stats as $line ) {
list(
$mountpoint,
$connections,
$name,
$listeners,
$descr,
$playing,
$url
) = explode( ",", $line );
$station = str_replace( "/", "", $mountpoint );
$statistics[$station]["mount"] = $mountpoint;
$statistics[$station]["connections"] = $connections;
$statistics[$station]["name"] = $name;
$statistics[$station]["listeners"] = $listeners;
$statistics[$station]["descr"] = $descr;
$statistics[$station]["playing"] = $playing;
$statistics[$station]["url"] = $url;
}
return $statistics;
}
function parse_raw( $rawdata ) {
$rawdata = explode( "\r\n", $rawdata);
$parsed = "";
foreach( $rawdata as $line ) {
if(
stristr($line, 'text/html') === FALSE &&
stristr($line, 'http/1.0') === FALSE
) {
$parsed = strip_tags(trim( str_replace( "\n", "", $line ) ));
}
}
$parsed = explode("[#]", $parsed);
$parsed = prep_stats($parsed);
return $parsed;
}
/*** MAIN ***/
$host = "127.0.0.1";
$port = 8000;
$mountpoint = "my-mount";
$request = "/all_statistics.xsl";
$statsraw = http_get( $host, $port, $request );
if( $statsraw != false ) {
$allstats = parse_raw( $statsraw["data"] );
if( key_exists( $mountpoint, $allstats ) ) {
// OnAir!
print( "<a href=\"http://$host:$port/$mountpoint\">" );
print( "<img src=\"images/onair.gif\" alt=\"stream\" border=\"0\" />" );
print( "</a><br />" );
print( "Listeners: " . $allstats[$mountpoint]["listeners"] . "<br />" );
} else {
// Offline!
print( "offline" );
}
}
?>
|
Enjoy! |
|
Back to top |
|
|
bumfank Guest
|
Posted: Mon Oct 17, 2005 9:12 pm Post subject: bumfank |
|
|
im trying to using your script but he allways give me offline, configuration is good because if I put
Code: |
else {
// Offline!
print( "offline" );
echo $statsraw["data"];
}
|
he give me a status page.
i have a lot of mointpoint but i tryed to use every one and he give me offline allways........ |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Mon Oct 17, 2005 9:50 pm Post subject: |
|
|
Quote: |
i have a lot of mointpoint but i tryed to use every one and he give me offline allways........ |
Did you add a slash ( / ) in front of the mountpoint or not ?
It is supposed to be configured without a leading slash ( / ). |
|
Back to top |
|
|
bumfank Guest
|
Posted: Tue Oct 18, 2005 11:26 am Post subject: |
|
|
yes i did.
here is my configuration:
Code: |
/*** MAIN ***/
$host = "strumyczek.man.olsztyn.pl";
$port = 8000;
$mountpoint = "techno-pl.ogg";
$request = "/status2.xsl"; |
my status page: http://strumyczek.man.olsztyn.pl:8000/status2.xsl |
|
Back to top |
|
|
Guest
|
Posted: Tue Oct 18, 2005 12:35 pm Post subject: |
|
|
Quote: |
$mountpoint = "techno-pl.ogg";
|
Try changing this to:
Code: |
$mountpoint = "pltechno-pl.ogg";
|
I didn't test the script with ogg streams, as I don't have any
From the stats2 page I see that you add pl/ to the mountpoints and as all slashes are stripped from the mountpoint name:
Code: |
$station = str_replace( "/", "", $mountpoint );
|
The mountpoint to check looks a bit akward in your situation |
|
Back to top |
|
|
akinci313
Joined: 20 Mar 2008 Posts: 3 Location: Germany
|
Posted: Fri May 02, 2008 10:53 am Post subject: |
|
|
It works very fine. Thanks to bware. |
|
Back to top |
|
|
Anonymous Guest
|
Posted: Tue May 06, 2008 5:37 pm Post subject: |
|
|
great script. anyway to get list of ips for each point ? |
|
Back to top |
|
|
Deker
Joined: 28 Aug 2008 Posts: 3
|
|
Back to top |
|
|
a.sniezek
Joined: 23 Jun 2009 Posts: 1
|
Posted: Tue Jun 23, 2009 9:11 pm Post subject: it doesn't work |
|
|
Hi
I check this script in my student's radiostation and it doesn't work
My status page: http://149.156.124.56:7146/status2.xsl
my configuration:
$host = "149.156.124.56";
$port = 7146;
$mountpoint = "audycja_mp3";
$request = "/status2.xsl";
and sciprt send error message:
Radio is offline
Could You check in your server or tell me what is going on?
Thanks for help:)
Arek |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2002 phpBB Group subRebel style by ktauber
|