Merge pull request #382 from bachandi/ambsens

Add legend customisation to ambsens.pm
This commit is contained in:
Jordi Sanfeliu 2022-01-13 10:32:19 +01:00 committed by GitHub
commit 7d3f2383ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 3 deletions

View File

@ -406,6 +406,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}))) {
@ -428,9 +432,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