Skip to content

Instantly share code, notes, and snippets.

@MrXermon
Last active April 6, 2021 02:32
Show Gist options
  • Save MrXermon/00376547f3ee223a1ebb to your computer and use it in GitHub Desktop.
Save MrXermon/00376547f3ee223a1ebb to your computer and use it in GitHub Desktop.
munin plugin to monitor SHOUTcast Broadcaster listeners
#!/usr/bin/php
<?php
$url = 'http://127.0.0.1:8000/statistics?json=1';
if(count($argv) == 2 && $argv[1] == 'authconf') {
exit('yes');
}
$data = file_get_contents($url);
if($data != false){
$data = json_decode(utf8_decode($data), true);
}
if(count($argv) == 2 && $argv[1] == 'config') {
echo("graph_title Shoutcast Listeners\n");
echo("graph_vlabel count\n");
echo("graph_category shoutcast\n");
foreach($data['streams'] as $stream){
echo("stream".$stream['id'].".label ".str_replace('/', '', $stream['streampath'])."\n");
if(strlen($stream['servertitle'])){
echo("stream".$stream['id'].".info ".$stream['servertitle']."\n");
}
}
echo("total.label Sum\n");
echo("total.info Total count of listeners of all streams\n");
exit();
}
$summe = 0;
foreach($data['streams'] as $stream){
echo("stream".$stream['id'].".value ".$stream['uniquelisteners']."\n");
$summe = $summe+$stream['uniquelisteners'];
}
echo("total.value ".$summe."\n");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment