mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
fix: Check HC counters individually (#6828)
* fix: Check HC counters individually Vendors are very inconsistent returning ifXTable values. Some only implement some of them (seemingly randomly). Others return them, but they are always 0. This attempts to fix that by checking each value individually. * A couple of small cleanups * Change the logic, The (if < hc) logic will be messed up when the counters roll. Just make sure it is not 0 or an empty string.
This commit is contained in:
committed by
Neil Lathwood
parent
c66f6c9704
commit
f5931535b4
@@ -119,6 +119,17 @@ $table_base_oids = array(
|
||||
'ifAdminStatus',
|
||||
);
|
||||
|
||||
$hc_mappings = array(
|
||||
'ifHCInOctets' => 'ifInOctets',
|
||||
'ifHCOutOctets' => 'ifOutOctets',
|
||||
'ifHCInUcastPkts' => 'ifInUcastPkts',
|
||||
'ifHCOutUcastPkts' => 'ifOutUcastPkts',
|
||||
'ifHCInBroadcastPkts' => 'ifInBroadcastPkts',
|
||||
'ifHCOutBroadcastPkts' => 'ifOutBroadcastPkts',
|
||||
'ifHCInMulticastPkts' => 'ifInMulticastPkts',
|
||||
'ifHCOutMulticastPkts' => 'ifOutMulticastPkts',
|
||||
);
|
||||
|
||||
$hc_oids = array(
|
||||
'ifInMulticastPkts',
|
||||
'ifInBroadcastPkts',
|
||||
@@ -431,17 +442,8 @@ foreach ($ports as $port) {
|
||||
$port['update']['poll_period'] = $polled_period;
|
||||
}
|
||||
|
||||
// use HC values if they are available
|
||||
if (!isset($this_port['ifInOctets'])) {
|
||||
echo "HC ";
|
||||
$this_port['ifInOctets'] = $this_port['ifHCInOctets'];
|
||||
$this_port['ifOutOctets'] = $this_port['ifHCOutOctets'];
|
||||
$this_port['ifInUcastPkts'] = $this_port['ifHCInUcastPkts'];
|
||||
$this_port['ifOutUcastPkts'] = $this_port['ifHCOutUcastPkts'];
|
||||
}
|
||||
|
||||
if ($device['os'] === 'airos-af' && $port['ifAlias'] === 'eth0') {
|
||||
$airos_stats = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.41112.1.3.3.1', $airos_stats, 'UBNT-AirFIBER-MIB');
|
||||
$airos_stats = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.41112.1.3.3.1', array(), 'UBNT-AirFIBER-MIB');
|
||||
$this_port['ifInOctets'] = $airos_stats[1]['rxOctetsOK'];
|
||||
$this_port['ifOutOctets'] = $airos_stats[1]['txOctetsOK'];
|
||||
$this_port['ifInErrors'] = $airos_stats[1]['rxErroredFrames'];
|
||||
@@ -470,16 +472,18 @@ foreach ($ports as $port) {
|
||||
$this_port['ifPhysAddress'] = zeropad($a_a).zeropad($a_b).zeropad($a_c).zeropad($a_d).zeropad($a_e).zeropad($a_f);
|
||||
}
|
||||
|
||||
if (is_numeric($this_port['ifHCInBroadcastPkts']) && is_numeric($this_port['ifHCOutBroadcastPkts']) && is_numeric($this_port['ifHCInMulticastPkts']) && is_numeric($this_port['ifHCOutMulticastPkts']) && $device['os'] !== 'ciscosb') {
|
||||
echo 'HC ';
|
||||
$this_port['ifInBroadcastPkts'] = $this_port['ifHCInBroadcastPkts'];
|
||||
$this_port['ifOutBroadcastPkts'] = $this_port['ifHCOutBroadcastPkts'];
|
||||
$this_port['ifInMulticastPkts'] = $this_port['ifHCInMulticastPkts'];
|
||||
$this_port['ifOutMulticastPkts'] = $this_port['ifHCOutMulticastPkts'];
|
||||
// use HC values if they are available
|
||||
foreach ($hc_mappings as $hc_oid => $if_oid) {
|
||||
if (isset($this_port[$hc_oid]) && $this_port[$hc_oid]) {
|
||||
d_echo("$hc_oid ");
|
||||
$this_port[$if_oid] = $this_port[$hc_oid];
|
||||
} else {
|
||||
d_echo("$if_oid ");
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this_port['ifHighSpeed']) && is_numeric($this_port['ifHighSpeed'])) {
|
||||
d_echo('HighSpeed ');
|
||||
d_echo('ifHighSpeed ');
|
||||
$this_port['ifSpeed'] = ($this_port['ifHighSpeed'] * 1000000);
|
||||
} elseif (isset($this_port['ifSpeed']) && is_numeric($this_port['ifSpeed'])) {
|
||||
d_echo('ifSpeed ');
|
||||
|
Reference in New Issue
Block a user