2016-08-26 12:08:48 +01:00
|
|
|
<?php
|
2017-02-23 22:45:50 +00:00
|
|
|
|
|
|
|
use LibreNMS\RRD\RrdDefinition;
|
|
|
|
|
2016-08-26 12:08:48 +01:00
|
|
|
$name = 'freeswitch';
|
2022-01-06 12:08:52 +01:00
|
|
|
|
2016-08-26 12:08:48 +01:00
|
|
|
if (! empty($agent_data[$name])) {
|
|
|
|
$rawdata = $agent_data[$name];
|
|
|
|
} else {
|
2018-12-16 07:42:50 -06:00
|
|
|
$options = '-Oqv';
|
2017-10-26 13:27:11 +03:00
|
|
|
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.102.114.101.101.115.119.105.116.99.104';
|
|
|
|
$rawdata = snmp_walk($device, $oid, $options);
|
|
|
|
$rawdata = str_replace("<<<freeswitch>>>\n", '', $rawdata);
|
2016-08-26 12:08:48 +01:00
|
|
|
}
|
|
|
|
// Format Data
|
2016-08-28 12:32:58 -05:00
|
|
|
$lines = explode("\n", $rawdata);
|
2016-08-26 12:08:48 +01:00
|
|
|
$freeswitch = [];
|
|
|
|
foreach ($lines as $line) {
|
2016-08-28 12:32:58 -05:00
|
|
|
[$var,$value] = explode('=', $line);
|
|
|
|
$freeswitch[$var] = $value;
|
2016-08-26 12:08:48 +01:00
|
|
|
}
|
|
|
|
// Freeswitch stats
|
2022-07-22 16:01:55 -05:00
|
|
|
$rrd_name = ['app', $name, 'stats', $app->app_id];
|
2017-02-23 22:45:50 +00:00
|
|
|
$rrd_def = RrdDefinition::make()
|
|
|
|
->addDataset('calls', 'GAUGE', 0, 10000)
|
|
|
|
->addDataset('channels', 'GAUGE', 0, 10000)
|
|
|
|
->addDataset('peak', 'GAUGE', 0, 10000)
|
|
|
|
->addDataset('in_failed', 'COUNTER', 0, 4294967295)
|
|
|
|
->addDataset('in_okay', 'COUNTER', 0, 4294967295)
|
|
|
|
->addDataset('out_failed', 'COUNTER', 0, 4294967295)
|
|
|
|
->addDataset('out_okay', 'COUNTER', 0, 4294967295);
|
2017-12-06 16:13:10 -06:00
|
|
|
$fields = [
|
|
|
|
'calls' => $freeswitch['Calls'],
|
|
|
|
'channels' => $freeswitch['Channels'],
|
|
|
|
'peak' => $freeswitch['Peak'],
|
2016-08-28 12:32:58 -05:00
|
|
|
'in_failed' => $freeswitch['InFailed'],
|
2017-12-06 16:13:10 -06:00
|
|
|
'in_okay' => $freeswitch['InTotal'] - $freeswitch['InFailed'],
|
2016-08-28 12:32:58 -05:00
|
|
|
'out_failed' => $freeswitch['OutFailed'],
|
2017-12-06 16:13:10 -06:00
|
|
|
'out_okay' => $freeswitch['OutTotal'] - $freeswitch['OutFailed'],
|
|
|
|
];
|
2016-08-26 12:08:48 +01:00
|
|
|
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
|
|
|
|
data_update($device, 'app', $tags, $fields);
|
2017-12-06 16:13:10 -06:00
|
|
|
update_application($app, $rawdata, $fields);
|
|
|
|
|
2017-11-29 02:23:19 -06:00
|
|
|
unset($lines, $freeswitch, $rrd_name, $rrd_def, $fields, $tags);
|