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.
This commit is contained in:
Andreas Bachlechner 2022-01-12 17:57:16 +01:00
parent cb1802e26e
commit 0430687694
2 changed files with 31 additions and 3 deletions

View File

@ -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++;
}

View File

@ -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