librenms-librenms/includes/polling/netstats-udp.inc.php

45 lines
1.1 KiB
PHP
Raw Normal View History

<?php
2015-07-13 20:10:26 +02:00
if ($device['os'] != 'Snom') {
echo ' UDP';
// These are at the start of large trees that we don't want to walk the entirety of, so we snmpget_multi them
$oids = array(
'udpInDatagrams',
'udpOutDatagrams',
'udpInErrors',
'udpNoPorts',
);
$rrd_def = array();
$snmpstring = '';
2015-07-13 20:10:26 +02:00
foreach ($oids as $oid) {
$oid_ds = truncate($oid, 19, '');
$rrd_def[] = " DS:$oid_ds:COUNTER:600:U:1000000"; // Limit to 1MPPS?
2015-07-13 20:10:26 +02:00
$snmpstring .= ' UDP-MIB::'.$oid.'.0';
}
2015-07-13 20:10:26 +02:00
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'UDP-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 {
$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]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams'])) {
2015-08-19 20:58:02 +00:00
$tags = compact('rrd_def');
data_update($device, 'netstats-udp', $tags, $fields);
2015-08-19 20:58:02 +00:00
2015-07-13 20:10:26 +02:00
$graphs['netstat_udp'] = true;
}
2015-07-13 20:10:26 +02:00
}//end if
unset($oids, $data, $rrd_def, $fields, $tags, $snmpstring);