Files
librenms-librenms/includes/polling/netstats/netstats-ip.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

57 lines
1.5 KiB
PHP

<?php
use LibreNMS\RRD\RrdDefinition;
if (!starts_with($device['os'], array('Snom', 'asa'))) {
echo ' IP';
// These are at the start of large trees that we don't want to walk the entirety of, so we snmp_get_multi them
$oids = array(
'ipForwDatagrams',
'ipInDelivers',
'ipInReceives',
'ipOutRequests',
'ipInDiscards',
'ipOutDiscards',
'ipOutNoRoutes',
'ipReasmReqds',
'ipReasmOKs',
'ipReasmFails',
'ipFragOKs',
'ipFragFails',
'ipFragCreates',
'ipInUnknownProtos',
'ipInHdrErrors',
'ipInAddrErrors',
);
$rrd_def = new RrdDefinition();
$snmpstring = '';
foreach ($oids as $oid) {
$rrd_def->addDataset($oids, 'COUNTER', null, 100000000000);
$snmpstring .= ' IP-MIB::'.$oid.'.0';
}
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-MIB');
$fields = array();
foreach ($oids as $oid) {
if (is_numeric($data[0][$oid])) {
$value = $data[0][$oid];
} else {
$value = 'U';
}
$fields[$oid] = $value;
}
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives'])) {
$tags = compact('rrd_def');
data_update($device, 'netstats-ip', $tags, $fields);
$graphs['netstat_ip'] = true;
$graphs['netstat_ip_frag'] = true;
}
}//end if
unset($oids, $data, $snmpstring, $rrd_def, $fields, $tags);