Files
librenms-librenms/includes/polling/applications/asterisk.inc.php
TheGreatDoc b844dd44c8 Asterisk Application support (#8914)
DO NOT DELETE THIS TEXT

#### Please note

> Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting.

- [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/)

#### Testers

If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`

PR 183 from librenms-agent contains the script to make this work

https://github.com/librenms/librenms-agent/pull/183
2018-07-21 20:48:31 +01:00

46 lines
1.5 KiB
PHP

<?php
use LibreNMS\RRD\RrdDefinition;
$name = 'asterisk';
$app_id = $app['app_id'];
if (!empty($agent_data[$name])) {
$rawdata = $agent_data[$name];
} else {
$options = '-O qv';
$oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.8.97.115.116.101.114.105.115.107';
$rawdata = snmp_walk($device, $oid, $options);
$rawdata = str_replace("<<<asterisk>>>\n", '', $rawdata);
}
# Format Data
$lines = explode("\n", $rawdata);
$asterisk = array();
foreach ($lines as $line) {
list($var,$value) = explode('=', $line);
$asterisk[$var] = $value;
}
# Asterisk stats
$rrd_name = array('app', $name, 'stats', $app_id);
$rrd_def = RrdDefinition::make()
->addDataset('calls', 'GAUGE', 0, 10000)
->addDataset('channels', 'GAUGE', 0, 20000)
->addDataset('sippeers', 'GAUGE', 0, 10000)
->addDataset('sipmononline', 'GAUGE', 0, 10000)
->addDataset('sipmonoffline', 'GAUGE', 0, 10000)
->addDataset('sipunmononline', 'GAUGE', 0, 10000)
->addDataset('sipunmonoffline', 'GAUGE', 0, 10000);
$fields = array(
'calls' => $asterisk['Calls'],
'channels' => $asterisk['Channels'],
'sipeers' => $asterisk['SipPeers'],
'sipmononline' => $asterisk['SipMonOnline'],
'sipmonoffline' => $asterisk['SipMonOffline'],
'sipunmononline' => $asterisk['SipUnMonOnline'],
'sipunmonoffline' => $asterisk['SipUnMonOffline']
);
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
data_update($device, 'app', $tags, $fields);
update_application($app, $rawdata, $fields);
unset($lines, $asterisk, $rrd_name, $rrd_def, $fields, $tags, $rawdata);