Last active
April 6, 2021 02:32
-
-
Save netaviator/00376547f3ee223a1ebb to your computer and use it in GitHub Desktop.
munin plugin to monitor SHOUTcast Broadcaster listeners
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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