changed the way how the Used value in Memory graph is calculated #204

This commit is contained in:
Jordi Sanfeliu 2018-03-19 13:09:58 +01:00
parent fd52846ea4
commit d7fa9e9e6d
2 changed files with 20 additions and 31 deletions

View File

@ -2,12 +2,10 @@
==================== ====================
- Added a complete graph to support external ambient sensors ('ambsens.pm'). - Added a complete graph to support external ambient sensors ('ambsens.pm').
(suggested by Zdenko Dolar, zdenko.dolar AT gmail.com) (suggested by Zdenko Dolar, zdenko.dolar AT gmail.com)
- Added a new option called 'memory_mode' to view the memory graph in two
different modes: 'real' (being the default) and 'interpreted'.
(suggested by Łukasz "Cyber Killer" Korpalski, cyberkiller8 AT gmail.com)
- Added an advice in monitorix.conf(5) as a reminder that some default values - Added an advice in monitorix.conf(5) as a reminder that some default values
are overwritten in the configuration files on certain systems. are overwritten in the configuration files on certain systems.
(suggested by Sander Bos) (suggested by Sander Bos)
- Changed the way how the Used value in Memory graph is calculated. [#204]
- Changed the alert in 'system.pm' to use the minimum value between the second - Changed the alert in 'system.pm' to use the minimum value between the second
and the third load averages to obtain a more symmetric curve and a sooner and the third load averages to obtain a more symmetric curve and a sooner
cancellation of the alert. cancellation of the alert.

View File

@ -167,6 +167,7 @@ sub system_update {
my $entropy = 0; my $entropy = 0;
my $uptime = 0; my $uptime = 0;
my $srecl = 0;
my $rrdata = "N"; my $rrdata = "N";
if($config->{os} eq "Linux") { if($config->{os} eq "Linux") {
@ -233,8 +234,13 @@ sub system_update {
$minac = $1; $minac = $1;
last; last;
} }
if(/^SReclaimable:\s+(\d+) kB$/) {
$srecl = $1;
last;
}
} }
close(IN); close(IN);
$mfree -= $srecl; # SReclaimable is subtracted here
open(IN, "/proc/sys/kernel/random/entropy_avail"); open(IN, "/proc/sys/kernel/random/entropy_avail");
while(<IN>) { while(<IN>) {
@ -492,7 +498,7 @@ sub system_cgi {
$buff /= 1024; $buff /= 1024;
$cach /= 1024; $cach /= 1024;
$free /= 1024; $free /= 1024;
@row = ($load1, $load5, $load15, $total_mem - $free, $cach, $buff, $macti, $minac, $nproc, $nprun, $npslp, $npwio, $npzom, $npstp, $npswp, $entropy, $uptime); @row = ($load1, $load5, $load15, ($total_mem - $free - $buff - $cach), $cach, $buff, $macti, $minac, $nproc, $nprun, $npslp, $npwio, $npzom, $npstp, $npswp, $entropy, $uptime);
$time = $time - (1 / $tf->{ts}); $time = $time - (1 / $tf->{ts});
push(@output, sprintf(" %2d$tf->{tc} %4.1f %4.1f %4.1f %6d %6d %6d %6d %6d %4d %4d %4d %4d %4d %4d %4d %6d %8d\n", $time, @row)); push(@output, sprintf(" %2d$tf->{tc} %4.1f %4.1f %4.1f %6d %6d %6d %6d %6d %4d %4d %4d %4d %4d %4d %4d %6d %8d\n", $time, @row));
} }
@ -659,29 +665,16 @@ sub system_cgi {
undef(@tmpz); undef(@tmpz);
undef(@CDEF); undef(@CDEF);
if($config->{os} eq "Linux" || $config->{os} eq "FreeBSD") { if($config->{os} eq "Linux" || $config->{os} eq "FreeBSD") {
if(lc($system->{memory_mode} || "") eq "interpreted") { push(@tmp, "AREA:m_mused#EE4444:Used");
push(@tmp, "AREA:m_mcach#44EE44:Cached"); push(@tmp, "AREA:m_mcach#44EE44:Cached");
push(@tmp, "AREA:m_mbuff#CCCCCC:Buffers"); push(@tmp, "AREA:m_mbuff#CCCCCC:Buffers");
push(@tmp, "AREA:m_macti#E29136:Active"); push(@tmp, "AREA:m_macti#E29136:Active");
push(@tmp, "AREA:m_minac#448844:Inactive"); push(@tmp, "AREA:m_minac#448844:Inactive");
push(@tmp, "AREA:m_mused_i#EE4444:Used"); push(@tmp, "LINE2:m_minac#008800");
push(@tmp, "LINE2:m_mused_i#EE0000"); push(@tmp, "LINE2:m_macti#E29136");
push(@tmp, "LINE2:m_minac#008800"); push(@tmp, "LINE2:m_mbuff#888888");
push(@tmp, "LINE2:m_macti#E29136"); push(@tmp, "LINE2:m_mcach#00EE00");
push(@tmp, "LINE2:m_mbuff#888888"); push(@tmp, "LINE2:m_mused#EE0000");
push(@tmp, "LINE2:m_mcach#00EE00");
} else {
push(@tmp, "AREA:m_mused#EE4444:Used");
push(@tmp, "AREA:m_mcach#44EE44:Cached");
push(@tmp, "AREA:m_mbuff#CCCCCC:Buffers");
push(@tmp, "AREA:m_macti#E29136:Active");
push(@tmp, "AREA:m_minac#448844:Inactive");
push(@tmp, "LINE2:m_minac#008800");
push(@tmp, "LINE2:m_macti#E29136");
push(@tmp, "LINE2:m_mbuff#888888");
push(@tmp, "LINE2:m_mcach#00EE00");
push(@tmp, "LINE2:m_mused#EE0000");
}
} elsif($config->{os} eq "OpenBSD" || $config->{os} eq "NetBSD") { } elsif($config->{os} eq "OpenBSD" || $config->{os} eq "NetBSD") {
push(@tmp, "AREA:m_mused#EE4444:Used"); push(@tmp, "AREA:m_mused#EE4444:Used");
push(@tmp, "AREA:m_macti#44EE44:Active"); push(@tmp, "AREA:m_macti#44EE44:Active");
@ -723,8 +716,7 @@ sub system_cgi {
"CDEF:m_mtotl=mtotl,1024,*", "CDEF:m_mtotl=mtotl,1024,*",
"CDEF:m_mbuff=mbuff,1024,*", "CDEF:m_mbuff=mbuff,1024,*",
"CDEF:m_mcach=mcach,1024,*", "CDEF:m_mcach=mcach,1024,*",
"CDEF:m_mused=m_mtotl,mfree,1024,*,-", "CDEF:m_mused=m_mtotl,mfree,1024,*,-,m_mbuff,-,m_mcach,-",
"CDEF:m_mused_i=m_mtotl,mfree,1024,*,-,m_mbuff,-,m_mcach,-",
"CDEF:m_macti=macti,1024,*", "CDEF:m_macti=macti,1024,*",
"CDEF:m_minac=minac,1024,*", "CDEF:m_minac=minac,1024,*",
"CDEF:allvalues=mtotl,mbuff,mcach,mfree,macti,minac,+,+,+,+,+", "CDEF:allvalues=mtotl,mbuff,mcach,mfree,macti,minac,+,+,+,+,+",
@ -759,8 +751,7 @@ sub system_cgi {
"CDEF:m_mtotl=mtotl,1024,*", "CDEF:m_mtotl=mtotl,1024,*",
"CDEF:m_mbuff=mbuff,1024,*", "CDEF:m_mbuff=mbuff,1024,*",
"CDEF:m_mcach=mcach,1024,*", "CDEF:m_mcach=mcach,1024,*",
"CDEF:m_mused=m_mtotl,mfree,1024,*,-", "CDEF:m_mused=m_mtotl,mfree,1024,*,-,m_mbuff,-,m_mcach,-",
"CDEF:m_mused_i=m_mtotl,mfree,1024,*,-,m_mbuff,-,m_mcach,-",
"CDEF:m_macti=macti,1024,*", "CDEF:m_macti=macti,1024,*",
"CDEF:m_minac=minac,1024,*", "CDEF:m_minac=minac,1024,*",
"CDEF:allvalues=mtotl,mbuff,mcach,mfree,macti,minac,+,+,+,+,+", "CDEF:allvalues=mtotl,mbuff,mcach,mfree,macti,minac,+,+,+,+,+",