mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Fix: netstats-udp, tcp and ip rrd's not updating (#10197)
* netstats fixes * code climate * Update netstats-ip.inc.php * fixes * code climate * GH feedback changes * codeclimate
This commit is contained in:
@@ -2,11 +2,10 @@
|
|||||||
|
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' IP';
|
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 = [
|
||||||
$oids = array(
|
|
||||||
'ipForwDatagrams',
|
'ipForwDatagrams',
|
||||||
'ipInDelivers',
|
'ipInDelivers',
|
||||||
'ipInReceives',
|
'ipInReceives',
|
||||||
@@ -23,34 +22,25 @@ if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
|||||||
'ipInUnknownProtos',
|
'ipInUnknownProtos',
|
||||||
'ipInHdrErrors',
|
'ipInHdrErrors',
|
||||||
'ipInAddrErrors',
|
'ipInAddrErrors',
|
||||||
);
|
];
|
||||||
|
$data = snmp_getnext_multi($device, $oids, '-OQUs', 'IP-MIB');
|
||||||
|
|
||||||
$rrd_def = new RrdDefinition();
|
if (is_numeric($data['ipOutRequests']) && is_numeric($data['ipInReceives'])) {
|
||||||
$snmpstring = '';
|
$rrd_def = new RrdDefinition();
|
||||||
foreach ($oids as $oid) {
|
$fields = [];
|
||||||
$rrd_def->addDataset($oid, 'COUNTER', null, 100000000000);
|
foreach ($oids as $oid) {
|
||||||
$snmpstring .= ' IP-MIB::'.$oid.'.0';
|
$rrd_def->addDataset($oid, 'COUNTER', null, 100000000000);
|
||||||
}
|
$fields[$oid] = is_numeric($data[$oid]) ? $data[$oid] : 'U';
|
||||||
|
|
||||||
$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');
|
$tags = compact('rrd_def');
|
||||||
data_update($device, 'netstats-ip', $tags, $fields);
|
data_update($device, 'netstats-ip', $tags, $fields);
|
||||||
|
|
||||||
$graphs['netstat_ip'] = true;
|
$graphs['netstat_ip'] = true;
|
||||||
$graphs['netstat_ip_frag'] = true;
|
$graphs['netstat_ip_frag'] = true;
|
||||||
}
|
|
||||||
}//end if
|
|
||||||
|
|
||||||
unset($oids, $data, $snmpstring, $rrd_def, $fields, $tags);
|
unset($rrd_def, $fields, $tags, $oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($oids, $data);
|
||||||
|
}//end if
|
||||||
|
|||||||
@@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' TCP';
|
echo ' TCP';
|
||||||
|
$oids = [
|
||||||
$oids = array(
|
|
||||||
'tcpActiveOpens',
|
'tcpActiveOpens',
|
||||||
'tcpPassiveOpens',
|
'tcpPassiveOpens',
|
||||||
'tcpAttemptFails',
|
'tcpAttemptFails',
|
||||||
@@ -16,40 +15,35 @@ if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
|||||||
'tcpRetransSegs',
|
'tcpRetransSegs',
|
||||||
'tcpInErrs',
|
'tcpInErrs',
|
||||||
'tcpOutRsts',
|
'tcpOutRsts',
|
||||||
);
|
];
|
||||||
|
$data = snmp_getnext_multi($device, $oids, '-OQUs', 'TCP-MIB');
|
||||||
|
|
||||||
$rrd_def = new RrdDefinition();
|
echo ' TCPHC';
|
||||||
$snmpstring = '';
|
$hc_oids = [
|
||||||
foreach ($oids as $oid) {
|
'tcpHCInSegs.0',
|
||||||
$rrd_def->addDataset($oid, 'COUNTER', null, 10000000);
|
'tcpHCOutSegs.0',
|
||||||
$snmpstring .= ' TCP-MIB::'.$oid.'.0';
|
];
|
||||||
}
|
$hc_data = snmp_getnext_multi($device, $hc_oids, '-OQUs', 'TCP-MIB');
|
||||||
|
|
||||||
$snmpstring .= ' tcpHCInSegs.0';
|
if ((is_numeric($data['tcpInSegs']) && is_numeric($data['tcpOutSegs'])) || (is_numeric($hc_data['tcpHCInSegs']) && is_numeric($hc_data['tcpHCOutSegs']))) {
|
||||||
$snmpstring .= ' tcpHCOutSegs.0';
|
$rrd_def = new RrdDefinition();
|
||||||
|
$fields = [];
|
||||||
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'TCP-MIB');
|
|
||||||
$data = $data[0];
|
|
||||||
|
|
||||||
if (isset($data['tcpInSegs']) && isset($data['tcpOutSegs'])) {
|
|
||||||
$fields = array();
|
|
||||||
foreach ($oids as $oid) {
|
foreach ($oids as $oid) {
|
||||||
$fields[$oid] = isset($data[$oid]) ? $data[$oid] : 'U';
|
$rrd_def->addDataset($oid, 'COUNTER', null, 10000000);
|
||||||
}
|
$fields[$oid] = is_numeric($data[$oid]) ? $data[$oid] : 'U';
|
||||||
|
|
||||||
// use HC Segs if we have them.
|
|
||||||
if (isset($data['tcpHCInSegs'])) {
|
|
||||||
if (!empty($data['tcpHCInSegs'])) {
|
|
||||||
$fields['tcpInSegs'] = $data['tcpHCInSegs'];
|
|
||||||
$fields['tcpOutSegs'] = $data['tcpHCOutSegs'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Replace Segs with HC Segs if we have them.
|
||||||
|
$fields['tcpInSegs'] = !empty($hc_data['tcpHCInSegs']) ? $hc_data['tcpHCInSegs'] : $fields['tcpInSegs'];
|
||||||
|
$fields['tcpOutSegs'] = !empty($hc_data['tcpHCOutSegs']) ? $hc_data['tcpHCOutSegs'] : $fields['tcpOutSegs'];
|
||||||
|
|
||||||
$tags = compact('rrd_def');
|
$tags = compact('rrd_def');
|
||||||
data_update($device, 'netstats-tcp', $tags, $fields);
|
data_update($device, 'netstats-tcp', $tags, $fields);
|
||||||
|
|
||||||
$graphs['netstat_tcp'] = true;
|
$graphs['netstat_tcp'] = true;
|
||||||
|
|
||||||
|
unset($rrd_def, $fields, $tags, $oid);
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($oids, $data, $fields, $oid, $snmpstring);
|
unset($oids, $hc_oids, $data, $hc_data);
|
||||||
}//end if
|
}//end if
|
||||||
|
|||||||
@@ -2,42 +2,32 @@
|
|||||||
|
|
||||||
use LibreNMS\RRD\RrdDefinition;
|
use LibreNMS\RRD\RrdDefinition;
|
||||||
|
|
||||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
||||||
echo ' UDP';
|
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 = [
|
||||||
$oids = array(
|
|
||||||
'udpInDatagrams',
|
'udpInDatagrams',
|
||||||
'udpOutDatagrams',
|
'udpOutDatagrams',
|
||||||
'udpInErrors',
|
'udpInErrors',
|
||||||
'udpNoPorts',
|
'udpNoPorts',
|
||||||
);
|
];
|
||||||
|
$data = snmp_getnext_multi($device, $oids, '-OQUs', 'UDP-MIB');
|
||||||
|
|
||||||
$rrd_def = new RrdDefinition();
|
if (is_numeric($data['udpInDatagrams']) && is_numeric($data['udpOutDatagrams'])) {
|
||||||
$snmpstring = '';
|
$rrd_def = new RrdDefinition();
|
||||||
foreach ($oids as $oid) {
|
$fields = [];
|
||||||
$rrd_def->addDataset($oid, 'COUNTER', null, 1000000); // Limit to 1MPPS?
|
foreach ($oids as $oid) {
|
||||||
$snmpstring .= ' UDP-MIB::'.$oid.'.0';
|
$rrd_def->addDataset($oid, 'COUNTER', null, 1000000); // Limit to 1MPPS?
|
||||||
}
|
$fields[$oid] = is_numeric($data[$oid]) ? $data[$oid] : 'U';
|
||||||
|
|
||||||
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'UDP-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]['udpInDatagrams']) && isset($data[0]['udpOutDatagrams'])) {
|
|
||||||
$tags = compact('rrd_def');
|
$tags = compact('rrd_def');
|
||||||
data_update($device, 'netstats-udp', $tags, $fields);
|
data_update($device, 'netstats-udp', $tags, $fields);
|
||||||
|
|
||||||
$graphs['netstat_udp'] = true;
|
$graphs['netstat_udp'] = true;
|
||||||
}
|
|
||||||
}//end if
|
|
||||||
|
|
||||||
unset($oids, $data, $rrd_def, $fields, $tags, $snmpstring);
|
unset($rrd_def, $fields, $tags, $oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($oids, $data);
|
||||||
|
}//end if
|
||||||
|
|||||||
Reference in New Issue
Block a user