handle last redhat net-snmp version for memory mode
This commit is contained in:
parent
cb18a78a1b
commit
d052083aed
|
@ -156,6 +156,7 @@ sub new {
|
|||
'units:s' => { name => 'units', default => '%' },
|
||||
'free' => { name => 'free' },
|
||||
'swap' => { name => 'check_swap' },
|
||||
'redhat' => { name => 'redhat' },
|
||||
});
|
||||
|
||||
return $self;
|
||||
|
@ -208,8 +209,54 @@ sub memory_calc {
|
|||
my ($used, $free, $prct_used, $prct_free) = (0, 0, 0, 0);
|
||||
|
||||
if ($total != 0) {
|
||||
$used = $total - $available - $buffer - $cached;
|
||||
$free = $total - $used;
|
||||
#### procps-ng-3.3.10-23
|
||||
## Mem:
|
||||
## total = MemTotal in /proc/meminfo
|
||||
## used = total - free - buffer - cache
|
||||
## free = MemFree in /proc/meminfo
|
||||
## shared = Shmem in /proc/meminfo
|
||||
## buffers = Buffers in /proc/meminfo
|
||||
## cache = Cached and Slab in /proc/meminfo
|
||||
## available = MemAvailable in /proc/meminfo
|
||||
## Swap:
|
||||
## total = SwapTotal in /proc/meminfo
|
||||
## used = total - free
|
||||
## free = SwapFree in /proc/meminfo
|
||||
#### net-snmp-5.7.2-38
|
||||
## memTotalSwap = SwapTotal in /proc/meminfo
|
||||
## memAvailSwap = SwapFree in /proc/meminfo
|
||||
## memTotalReal = MemTotal in /proc/meminfo
|
||||
## memAvailReal = MemFree in /proc/meminfo
|
||||
## memTotalFree = memAvailSwap + memAvailReal
|
||||
## memShared = MemShared in /proc/meminfo
|
||||
## memBuffer = Buffers in /proc/meminfo
|
||||
## memCached = Cached in /proc/meminfo (missing Slab)
|
||||
|
||||
#### procps-ng-3.3.10-26
|
||||
## Mem:
|
||||
## total = MemTotal in /proc/meminfo
|
||||
## used = total - free - buffer - cache
|
||||
## free = MemFree in /proc/meminfo
|
||||
## shared = Shmem in /proc/meminfo
|
||||
## buffers = Buffers in /proc/meminfo
|
||||
## cache = Cached and SReclaimable in /proc/meminfo (https://gitlab.com/procps-ng/procps/commit/05d751c4f076a2f0118b914c5e51cfbb4762ad8e)
|
||||
## available = MemAvailable in /proc/meminfo
|
||||
## Swap:
|
||||
## total = SwapTotal in /proc/meminfo
|
||||
## used = total - free
|
||||
## free = SwapFree in /proc/meminfo
|
||||
#### net-snmp-5.7.2-43
|
||||
## memTotalSwap = SwapTotal in /proc/meminfo
|
||||
## memAvailSwap = SwapFree in /proc/meminfo
|
||||
## memTotalReal = MemTotal in /proc/meminfo
|
||||
## memAvailReal = MemFree + Buffers + Cached + SReclaimable in /proc/meminfo (https://bugzilla.redhat.com/attachment.cgi?id=1554747&action=diff)
|
||||
## memTotalFree = memAvailSwap + memAvailReal
|
||||
## memShared = MemShared in /proc/meminfo
|
||||
## memBuffer = Buffers in /proc/meminfo
|
||||
## memCached = Cached + SReclaimable in /proc/meminfo (https://bugzilla.redhat.com/attachment.cgi?id=1554747&action=diff)
|
||||
|
||||
$used = (defined($self->{option_results}->{redhat})) ? $total - $available : $total - $available - $buffer - $cached;
|
||||
$free = (defined($self->{option_results}->{redhat})) ? $available : $total - $used;
|
||||
$prct_used = $used * 100 / $total;
|
||||
$prct_free = 100 - $prct_used;
|
||||
}
|
||||
|
@ -289,6 +336,16 @@ Can be: 'usage' (B), 'usage-free' (B), 'usage-prct' (%),
|
|||
'swap' (B), 'swap-free' (B), 'swap-prct' (%),
|
||||
'buffer' (B), 'cached' (B), 'shared' (B).
|
||||
|
||||
=item B<--redhat>
|
||||
|
||||
If using RedHat distribution with net-snmp >= 5.7.2-43.
|
||||
|
||||
This version: used = memTotalReal - memAvailReal // free = memAvailReal
|
||||
|
||||
Others versions: used = memTotalReal - memAvailReal - memBuffer - memCached // free = total - used
|
||||
|
||||
(grep for '##' in this mode for more informations)
|
||||
|
||||
=back
|
||||
|
||||
=cut
|
||||
|
|
Loading…
Reference in New Issue