Files
librenms-librenms/includes/polling/netstats/netstats-icmp.inc.php
Neil Lathwood fad5aca1b7 feature: Allow customisation of rrd step/heartbeat when creating new rrd files (#5947)
* feature: Allow customisation of rrd step/heartbeat when creating new rrd files

* revert defaults

* added docs + webui config option

* Move RrdDefinition to an Object to make them easier to create and remove the possibility of typos.

* Fix style/lint issues and missing use statements

* 3 more missing use statements

* updated doc + moved schema file
2017-02-23 22:45:50 +00:00

58 lines
1.6 KiB
PHP

<?php
use LibreNMS\RRD\RrdDefinition;
if (!starts_with($device['os'], array('Snom', 'asa'))) {
echo ' ICMP';
// Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them
$oids = array(
'icmpInMsgs',
'icmpOutMsgs',
'icmpInErrors',
'icmpOutErrors',
'icmpInEchos',
'icmpOutEchos',
'icmpInEchoReps',
'icmpOutEchoReps',
'icmpInDestUnreachs',
'icmpOutDestUnreachs',
'icmpInParmProbs',
'icmpInTimeExcds',
'icmpInSrcQuenchs',
'icmpInRedirects',
'icmpInTimestamps',
'icmpInTimestampReps',
'icmpInAddrMasks',
'icmpInAddrMaskReps',
'icmpOutTimeExcds',
'icmpOutParmProbs',
'icmpOutSrcQuenchs',
'icmpOutRedirects',
'icmpOutTimestamps',
'icmpOutTimestampReps',
'icmpOutAddrMasks',
'icmpOutAddrMaskReps',
);
$data = snmpwalk_cache_oid($device, 'icmp', array(), 'IP-MIB');
$data = $data[0];
if (isset($data['icmpInMsgs']) && isset($data['icmpOutMsgs'])) {
$rrd_def = new RrdDefinition();
$fields = array();
foreach ($oids as $oid) {
$rrd_def->addDataset($oid, 'COUNTER', null, 100000000000);
$fields[$oid] = isset($data[$oid]) ? $data[$oid] : 'U';
}
$tags = compact('rrd_def');
data_update($device, 'netstats-icmp', $tags, $fields);
$graphs['netstat_icmp'] = true;
$graphs['netstat_icmp_info'] = true;
}
unset($oids, $data, $rrd_def, $fields, $tags);
}//end if