From 99b8e2fec06b64b9b5b0038228dba07ec2680418 Mon Sep 17 00:00:00 2001 From: Dalfo <55084117+dalfo77@users.noreply.github.com> Date: Mon, 18 Jan 2021 11:29:43 +0100 Subject: [PATCH] Correct memory calculation (#2513) Correct memory calculation for Arista with EOS > 4.22.0F https://eos.arista.com/memory-utilization-of-eos-devices/ --- network/arista/snmp/mode/memory.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/network/arista/snmp/mode/memory.pm b/network/arista/snmp/mode/memory.pm index 13071a73c..e3e7e77ae 100644 --- a/network/arista/snmp/mode/memory.pm +++ b/network/arista/snmp/mode/memory.pm @@ -132,10 +132,11 @@ sub manage_selection { ); $snmp_result = $options{snmp}->get_leef(); - my ($total, $used, $cached, $buffer); + my ($total, $used, $cached, $buffer, $unavailable); #.1.3.6.1.2.1.25.2.3.1.3.1 = STRING: RAM #.1.3.6.1.2.1.25.2.3.1.3.2 = STRING: RAM (Buffers) #.1.3.6.1.2.1.25.2.3.1.3.3 = STRING: RAM (Cache) + #.1.3.6.1.2.1.25.2.3.1.3.100 = STRING: RAM (Unavailable) foreach (@$storages) { my $result = $options{snmp}->map_instance(mapping => $mapping, results => $snmp_result, instance => $_); my $current = $result->{hrStorageUsed} * $result->{hrStorageAllocationUnits}; @@ -145,13 +146,19 @@ sub manage_selection { $cached = $current; } elsif ($result->{hrStorageDescr} =~ /RAM.*?Buffers/i) { $buffer = $current; + } elsif ($result->{hrStorageDescr} =~ /RAM.*?Unavailable/i) { + $unavailable = $current; } elsif ($result->{hrStorageDescr} =~ /RAM/i) { $used = $current; $total = $result->{hrStorageSize} * $result->{hrStorageAllocationUnits}; } } - $used -= (defined($cached) ? $cached : 0) - (defined($buffer) ? $buffer : 0); + if (defined($unavailable)) { + $used = $unavailable; + } else { + $used -= (defined($cached) ? $cached : 0) - (defined($buffer) ? $buffer : 0); + } $self->{ram} = { total => $total, cached => $cached,