From 0430687694882f4a6788434e374065d7007d658e Mon Sep 17 00:00:00 2001 From: Andreas Bachlechner <62039342+bachandi@users.noreply.github.com> Date: Wed, 12 Jan 2022 17:57:16 +0100 Subject: [PATCH] Add more legend options to ambsens.pm - show_average option to also show average, minimum and maximum in the legend. - scientific_notation option to print the current values in scientific notation. --- lib/ambsens.pm | 20 +++++++++++++++++--- man/man5/monitorix.conf.5 | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/lib/ambsens.pm b/lib/ambsens.pm index d4139f9..34e99e8 100644 --- a/lib/ambsens.pm +++ b/lib/ambsens.pm @@ -404,6 +404,10 @@ sub ambsens_cgi { } } + my $use_scientific_notation = lc($ambsens->{scientific_notation} || "") eq "y" ? 1 : 0; + my $show_average = lc($ambsens->{show_average} || "") eq "y" ? 1 : 0; + my $value_format = $use_scientific_notation ? "%6.1lf%s" : "%7.1lf" ; + @riglim = @{setup_riglim($rigid[0], $limit[0])}; $n = 0; while($n < scalar(my @sl = split(',', $ambsens->{list}))) { @@ -426,9 +430,19 @@ sub ambsens_cgi { foreach my $i (split(',', $ambsens->{desc}->{$n})) { $i = trim($i); $str = $ambsens->{map}->{$i} || $i; - $str = sprintf("%-40s", substr($str, 0, 40)); - push(@tmp, "LINE2:s" . ($e + 1) . $LC[$e] . ":$str"); - push(@tmp, "GPRINT:s" . ($e + 1) . ":LAST: Current\\:%7.1lf\\n"); + if ($show_average) { + $str = sprintf("%-10s", substr($str, 0, 10)); + push(@tmp, "LINE2:s" . ($e + 1) . $LC[$e] . ":$str"); + push(@tmp, "GPRINT:s" . ($e + 1) . ":LAST: Cur\\:" . $value_format); + push(@tmp, "GPRINT:s" . ($e + 1) . ":AVERAGE:Avg\\:" . $value_format); + push(@tmp, "GPRINT:s" . ($e + 1) . ":MIN:Min\\:" . $value_format); + push(@tmp, "GPRINT:s" . ($e + 1) . ":MAX:Max\\:" . $value_format . "\\n"); + } + else { + $str = sprintf("%-40s", substr($str, 0, 40)); + push(@tmp, "LINE2:s" . ($e + 1) . $LC[$e] . ":$str"); + push(@tmp, "GPRINT:s" . ($e + 1) . ":LAST: Current\\:" . $value_format . "\\n"); + } push(@tmpz, "LINE2:s" . ($e + 1) . $LC[$e] . ":$str"); $e++; } diff --git a/man/man5/monitorix.conf.5 b/man/man5/monitorix.conf.5 index 8ae0466..a5c9361 100644 --- a/man/man5/monitorix.conf.5 +++ b/man/man5/monitorix.conf.5 @@ -1357,6 +1357,20 @@ This is the number of graphs that will be put in a row. .P Default value: \fI2\fP .RE +.RE +.BI scientific_notation +.RS +This is an option to enable scientific notation for the current value in the legend. +.P +Default value: \fIn\fP +.RE +.RE +.BI show_average +.RS +This is an option to show also average, minimum and maximum values in the legend +.P +Default value: \fIn\fP +.RE .SS AMD GPU temperatures and usage (amdgpu.pm) This graph is able to monitor an unlimited number of AMD GPUs as long as the driver provides a hwmon interface. Usually it is not guaranteed to always get the same hwmon path so it is advised to assign fixed links via udev rules. .P