2011-09-28 23:24:28 +00:00
|
|
|
<?php
|
|
|
|
|
2012-05-25 12:24:34 +00:00
|
|
|
// Polls shoutcast statistics from script via SNMP
|
2017-02-23 22:45:50 +00:00
|
|
|
|
|
|
|
use LibreNMS\RRD\RrdDefinition;
|
|
|
|
|
2016-07-07 01:33:43 -05:00
|
|
|
$name = 'shoutcast';
|
|
|
|
$app_id = $app['app_id'];
|
|
|
|
|
2018-12-16 07:42:50 -06:00
|
|
|
$options = '-Oqv';
|
2017-03-31 04:01:40 +01:00
|
|
|
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.115.104.111.117.116.99.97.115.116';
|
2011-10-01 10:10:02 +00:00
|
|
|
$shoutcast = snmp_get($device, $oid, $options);
|
2011-09-28 23:24:28 +00:00
|
|
|
|
2015-07-10 13:36:21 +02:00
|
|
|
echo ' shoutcast';
|
2011-09-28 23:24:28 +00:00
|
|
|
|
|
|
|
$servers = explode("\n", $shoutcast);
|
|
|
|
|
2017-12-06 16:13:10 -06:00
|
|
|
$metrics = array();
|
2015-07-10 13:36:21 +02:00
|
|
|
foreach ($servers as $item => $server) {
|
|
|
|
$server = trim($server);
|
|
|
|
|
|
|
|
if (!empty($server)) {
|
2016-07-07 01:33:43 -05:00
|
|
|
$data = explode(';', $server);
|
2016-02-25 14:30:40 -06:00
|
|
|
list($host, $port) = explode(':', $data['0'], 2);
|
2011-09-28 23:24:28 +00:00
|
|
|
|
2016-07-07 01:33:43 -05:00
|
|
|
$rrd_name = array('app', $name, $app_id, $host . '_' . $port);
|
2017-02-23 22:45:50 +00:00
|
|
|
$rrd_def = RrdDefinition::make()
|
|
|
|
->addDataset('bitrate', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('traf_in', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('traf_out', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('current', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('status', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('peak', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('max', 'GAUGE', 0, 125000000000)
|
|
|
|
->addDataset('unique', 'GAUGE', 0, 125000000000);
|
2015-08-18 16:26:55 +00:00
|
|
|
|
2016-07-07 01:33:43 -05:00
|
|
|
$fields = array(
|
|
|
|
'bitrate' => $data['1'],
|
|
|
|
'traf_in' => $data['2'],
|
|
|
|
'traf_out' => $data['3'],
|
|
|
|
'current' => $data['4'],
|
|
|
|
'status' => $data['5'],
|
|
|
|
'peak' => $data['6'],
|
|
|
|
'max' => $data['7'],
|
|
|
|
'unique' => $data['8'],
|
|
|
|
);
|
2017-12-06 16:13:10 -06:00
|
|
|
$metrics[$server] = $fields;
|
2015-08-18 16:26:55 +00:00
|
|
|
|
2016-07-07 01:33:43 -05:00
|
|
|
$tags = compact('name', 'app_id', 'host', 'port', 'rrd_name', 'rrd_def');
|
|
|
|
data_update($device, 'app', $tags, $fields);
|
2015-07-10 13:36:21 +02:00
|
|
|
}//end if
|
|
|
|
}//end foreach
|
2017-12-06 16:13:10 -06:00
|
|
|
|
|
|
|
update_application($app, $shoutcast, $metrics);
|