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,10 +2,9 @@
|
||||
|
||||
use LibreNMS\RRD\RrdDefinition;
|
||||
|
||||
if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
||||
if (!starts_with($device['os'], ['Snom', 'asa'])) {
|
||||
echo ' TCP';
|
||||
|
||||
$oids = array(
|
||||
$oids = [
|
||||
'tcpActiveOpens',
|
||||
'tcpPassiveOpens',
|
||||
'tcpAttemptFails',
|
||||
@@ -16,40 +15,35 @@ if (!starts_with($device['os'], array('Snom', 'asa'))) {
|
||||
'tcpRetransSegs',
|
||||
'tcpInErrs',
|
||||
'tcpOutRsts',
|
||||
);
|
||||
];
|
||||
$data = snmp_getnext_multi($device, $oids, '-OQUs', 'TCP-MIB');
|
||||
|
||||
$rrd_def = new RrdDefinition();
|
||||
$snmpstring = '';
|
||||
foreach ($oids as $oid) {
|
||||
$rrd_def->addDataset($oid, 'COUNTER', null, 10000000);
|
||||
$snmpstring .= ' TCP-MIB::'.$oid.'.0';
|
||||
}
|
||||
echo ' TCPHC';
|
||||
$hc_oids = [
|
||||
'tcpHCInSegs.0',
|
||||
'tcpHCOutSegs.0',
|
||||
];
|
||||
$hc_data = snmp_getnext_multi($device, $hc_oids, '-OQUs', 'TCP-MIB');
|
||||
|
||||
$snmpstring .= ' tcpHCInSegs.0';
|
||||
$snmpstring .= ' tcpHCOutSegs.0';
|
||||
|
||||
$data = snmp_get_multi($device, $snmpstring, '-OQUs', 'TCP-MIB');
|
||||
$data = $data[0];
|
||||
|
||||
if (isset($data['tcpInSegs']) && isset($data['tcpOutSegs'])) {
|
||||
$fields = array();
|
||||
if ((is_numeric($data['tcpInSegs']) && is_numeric($data['tcpOutSegs'])) || (is_numeric($hc_data['tcpHCInSegs']) && is_numeric($hc_data['tcpHCOutSegs']))) {
|
||||
$rrd_def = new RrdDefinition();
|
||||
$fields = [];
|
||||
foreach ($oids as $oid) {
|
||||
$fields[$oid] = isset($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'];
|
||||
}
|
||||
$rrd_def->addDataset($oid, 'COUNTER', null, 10000000);
|
||||
$fields[$oid] = is_numeric($data[$oid]) ? $data[$oid] : 'U';
|
||||
}
|
||||
|
||||
// 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');
|
||||
data_update($device, 'netstats-tcp', $tags, $fields);
|
||||
|
||||
$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
|
||||
|
||||
Reference in New Issue
Block a user