mirror of https://github.com/mikaku/Monitorix.git
Fixed and improved the calculation of 'Used' in .memory.pm'
There was a stupid bug that prevented to include the SReclaimable value in the formula to calculate the 'Used' value. Morever, I've seen that newer versions of 'free' command also include the value SUnreclaim in that formula. So, the final calculation of 'Used' is like this: Used = MemTotal - MemFree - Buffers - Cached - SReclaimable - SUnreclaim This ensures that Monitorix is in sync with the results of 'free' command. #204
This commit is contained in:
parent
9d26e28f90
commit
b290ffd417
|
@ -168,6 +168,7 @@ sub system_update {
|
|||
my $uptime = 0;
|
||||
|
||||
my $srecl = 0;
|
||||
my $snorecl = 0;
|
||||
my $rrdata = "N";
|
||||
|
||||
if($config->{os} eq "Linux") {
|
||||
|
@ -236,11 +237,19 @@ sub system_update {
|
|||
}
|
||||
if(/^SReclaimable:\s+(\d+) kB$/) {
|
||||
$srecl = $1;
|
||||
next;
|
||||
}
|
||||
if(/^SUnreclaim:\s+(\d+) kB$/) {
|
||||
$snorecl = $1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
close(IN);
|
||||
$mfree -= $srecl; # SReclaimable is subtracted here
|
||||
|
||||
# SReclaimable and SUnreclaim values are added to 'mfree'
|
||||
# in order to be also included in the subtraction later.
|
||||
$mfree += $srecl;
|
||||
$mfree += $snorecl;
|
||||
|
||||
open(IN, "/proc/sys/kernel/random/entropy_avail");
|
||||
while(<IN>) {
|
||||
|
|
Loading…
Reference in New Issue