Merge pull request #349 from bachandi/ipmiNan

Add option to show nan instead of 0 for missing data in ipmi.
This commit is contained in:
Jordi Sanfeliu 2021-10-11 11:08:47 +02:00 committed by GitHub
commit 94b98aee29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 4 deletions

View File

@ -134,6 +134,7 @@ sub ipmi_update {
my $rrd = $config->{base_lib} . $package . ".rrd";
my $ipmi = $config->{ipmi};
my $args = $ipmi->{extra_args} || "";
my $use_nan_for_missing_data = lc(($ipmi->{use_nan_for_missing_data} || "")) eq "y" ? 1 : 0;
my @sens;
@ -153,8 +154,7 @@ sub ipmi_update {
my $e2 = 0;
foreach my $i (split(',', $ipmi->{desc}->{$e})) {
my $unit;
$sens[$e][$e2] = 0 unless defined $sens[$e][$e2];
$sens[$e][$e2] = ($use_nan_for_missing_data ? (0+"nan") : 0) unless defined $sens[$e][$e2];
$str = trim($i);
$unit = $ipmi->{units}->{$e};
foreach(@data) {
@ -214,6 +214,7 @@ sub ipmi_cgi {
my @output;
my $ipmi = $config->{ipmi};
my $gap_on_all_nan = lc(($ipmi->{gap_on_all_nan} || "")) eq "y" ? 1 : 0;
my @rigid = split(',', ($ipmi->{rigid} || ""));
my @limit = split(',', ($ipmi->{limit} || ""));
my $tf = $cgi->{tf};
@ -400,6 +401,7 @@ sub ipmi_cgi {
}
($width, $height) = split('x', $config->{graph_size}->{medium});
$str = substr(trim($sl[$n]), 0, 25);
my $cdef_allvalues = $gap_on_all_nan ? "CDEF:allvalues=s1,UN,0,1,IF,s2,UN,0,1,IF,s3,UN,0,1,IF,s4,UN,0,1,IF,s5,UN,0,1,IF,s6,UN,0,1,IF,s7,UN,0,1,IF,s8,UN,0,1,IF,s9,UN,0,1,IF,+,+,+,+,+,+,+,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=s1,s2,s3,s4,s5,s6,s7,s8,s9,+,+,+,+,+,+,+,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$n]",
"--title=$str ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}",
@ -421,7 +423,7 @@ sub ipmi_cgi {
"DEF:s7=$rrd:ipmi" . $n . "_s7:AVERAGE",
"DEF:s8=$rrd:ipmi" . $n . "_s8:AVERAGE",
"DEF:s9=$rrd:ipmi" . $n . "_s9:AVERAGE",
"CDEF:allvalues=s1,s2,s3,s4,s5,s6,s7,s8,s9,+,+,+,+,+,+,+,+",
$cdef_allvalues,
@CDEF,
@tmp);
$err = RRDs::error;
@ -449,7 +451,7 @@ sub ipmi_cgi {
"DEF:s7=$rrd:ipmi" . $n . "_s7:AVERAGE",
"DEF:s8=$rrd:ipmi" . $n . "_s8:AVERAGE",
"DEF:s9=$rrd:ipmi" . $n . "_s9:AVERAGE",
"CDEF:allvalues=s1,s2,s3,s4,s5,s6,s7,s8,s9,+,+,+,+,+,+,+,+",
$cdef_allvalues,
@CDEF,
@tmpz);
$err = RRDs::error;

View File

@ -1221,6 +1221,29 @@ This is the number of graphs that will be put in a row.
.P
Default value: \fI2\fP
.RE
.P
.RE
.RE
.BI use_nan_for_missing_data
.RS
This option, when enabled via \fIy\fP, shows \fnan\fP values for missing data instead of \f0\fP. This is useful when \f0\fP could be mistaken for valid data.
.P
Default value: \fIn\fP
.RE
.P
.RE
.RE
.BI gap_on_all_nan
.RS
This option, when enabled via \fIy\fP, combined with the \fIshow_gaps\fP option shows gaps only if all data points are \fInan\fP instead of requiring only one to be \fInan\fP for a gap. This can be useful if not all sensor data are required for normal operation.
.P
Default value: \fIn\fP
.RE
.P
.BI extra_args
.RS