Files
librenms-librenms/includes/polling/netstats/netstats-ip.inc.php

57 lines
1.5 KiB
PHP
Raw Normal View History

<?php
use LibreNMS\RRD\RrdDefinition;
if (!starts_with($device['os'], array('Snom', 'asa'))) {
2015-07-13 20:10:26 +02:00
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 = '';
2015-07-13 20:10:26 +02:00
foreach ($oids as $oid) {
$rrd_def->addDataset($oids, 'COUNTER', null, 100000000000);
2015-07-13 20:10:26 +02:00
$snmpstring .= ' IP-MIB::'.$oid.'.0';
}
2015-07-13 20:10:26 +02:00
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'IP-MIB');
$fields = array();
2015-07-13 20:10:26 +02:00
foreach ($oids as $oid) {
if (is_numeric($data[0][$oid])) {
$value = $data[0][$oid];
} else {
2015-07-13 20:10:26 +02:00
$value = 'U';
}
$fields[$oid] = $value;
2015-07-13 20:10:26 +02:00
}
2015-07-13 20:10:26 +02:00
if (isset($data[0]['ipOutRequests']) && isset($data[0]['ipInReceives'])) {
$tags = compact('rrd_def');
data_update($device, 'netstats-ip', $tags, $fields);
2015-08-19 20:58:02 +00:00
2015-07-13 20:10:26 +02:00
$graphs['netstat_ip'] = true;
$graphs['netstat_ip_frag'] = true;
}
2015-07-13 20:10:26 +02:00
}//end if
unset($oids, $data, $snmpstring, $rrd_def, $fields, $tags);