Add gap_on_all_nan option to nut.pm

This option shows gaps only if all data points are nan instead of requiring only one to be nan for a gap.
This commit is contained in:
Andreas Bachlechner 2022-02-24 10:07:27 +01:00
parent c6447adc80
commit d3f2558352
2 changed files with 27 additions and 12 deletions

View File

@ -303,6 +303,8 @@ sub nut_cgi {
$temp_scale = "Fahrenheit"; $temp_scale = "Fahrenheit";
} }
my $gap_on_all_nan = lc($nut->{gap_on_all_nan} || "") eq "y" ? 1 : 0;
# text mode # text mode
# #
if(lc($config->{iface_mode}) eq "text") { if(lc($config->{iface_mode}) eq "text") {
@ -483,6 +485,7 @@ sub nut_cgi {
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig"; ($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
@tmp = @tmpz; @tmp = @tmpz;
} }
my $cdef_allvalues_volt = $gap_on_all_nan ? "CDEF:allvalues=ltran,UN,0,1,IF,htran,UN,0,1,IF,ivolt,UN,0,1,IF,ovolt,UN,0,1,IF,+,+,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=ltran,htran,ivolt,ovolt,+,+,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6]",
"--title=$config->{graphs}->{_nut1} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut1} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -499,7 +502,7 @@ sub nut_cgi {
"DEF:htran=$rrd:nut" . $e . "_htran:AVERAGE", "DEF:htran=$rrd:nut" . $e . "_htran:AVERAGE",
"DEF:ivolt=$rrd:nut" . $e . "_ivolt:AVERAGE", "DEF:ivolt=$rrd:nut" . $e . "_ivolt:AVERAGE",
"DEF:ovolt=$rrd:nut" . $e . "_ovolt:AVERAGE", "DEF:ovolt=$rrd:nut" . $e . "_ovolt:AVERAGE",
"CDEF:allvalues=ltran,htran,ivolt,ovolt,+,+,+", $cdef_allvalues_volt,
@CDEF, @CDEF,
"COMMENT: \\n", "COMMENT: \\n",
@tmp, @tmp,
@ -526,7 +529,7 @@ sub nut_cgi {
"DEF:htran=$rrd:nut" . $e . "_htran:AVERAGE", "DEF:htran=$rrd:nut" . $e . "_htran:AVERAGE",
"DEF:ivolt=$rrd:nut" . $e . "_ivolt:AVERAGE", "DEF:ivolt=$rrd:nut" . $e . "_ivolt:AVERAGE",
"DEF:ovolt=$rrd:nut" . $e . "_ovolt:AVERAGE", "DEF:ovolt=$rrd:nut" . $e . "_ovolt:AVERAGE",
"CDEF:allvalues=ltran,htran,ivolt,ovolt,+,+,+", $cdef_allvalues_volt,
@CDEF, @CDEF,
@tmpz); @tmpz);
$err = RRDs::error; $err = RRDs::error;
@ -588,6 +591,7 @@ sub nut_cgi {
($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig"; ($width, $height) = split('x', $config->{graph_size}->{main}) if $silent eq "imagetagbig";
@tmp = @tmpz; @tmp = @tmpz;
} }
my $cdef_allvalues_bat = $gap_on_all_nan ? "CDEF:allvalues=bchar,UN,0,1,IF,mbatc,UN,0,1,IF,loadc,UN,0,1,IF,+,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=bchar,mbatc,loadc,+,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 1]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 1]",
"--title=$config->{graphs}->{_nut2} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut2} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -603,7 +607,7 @@ sub nut_cgi {
"DEF:bchar=$rrd:nut" . $e . "_bchar:AVERAGE", "DEF:bchar=$rrd:nut" . $e . "_bchar:AVERAGE",
"DEF:loadc=$rrd:nut" . $e . "_loadc:AVERAGE", "DEF:loadc=$rrd:nut" . $e . "_loadc:AVERAGE",
"DEF:mbatc=$rrd:nut" . $e . "_mbatc:AVERAGE", "DEF:mbatc=$rrd:nut" . $e . "_mbatc:AVERAGE",
"CDEF:allvalues=bchar,mbatc,loadc,+,+", $cdef_allvalues_bat,
@CDEF, @CDEF,
"COMMENT: \\n", "COMMENT: \\n",
@tmp, @tmp,
@ -630,7 +634,7 @@ sub nut_cgi {
"DEF:bchar=$rrd:nut" . $e . "_bchar:AVERAGE", "DEF:bchar=$rrd:nut" . $e . "_bchar:AVERAGE",
"DEF:loadc=$rrd:nut" . $e . "_loadc:AVERAGE", "DEF:loadc=$rrd:nut" . $e . "_loadc:AVERAGE",
"DEF:mbatc=$rrd:nut" . $e . "_mbatc:AVERAGE", "DEF:mbatc=$rrd:nut" . $e . "_mbatc:AVERAGE",
"CDEF:allvalues=bchar,mbatc,loadc,+,+", $cdef_allvalues_bat,
@CDEF, @CDEF,
@tmpz); @tmpz);
$err = RRDs::error; $err = RRDs::error;
@ -693,6 +697,7 @@ sub nut_cgi {
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
} }
my $cdef_allvalues_temp = $gap_on_all_nan ? "CDEF:allvalues=itemp,UN,0,1,IF,atemp,UN,0,1,IF,humid,UN,0,1,IF,+,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=itemp,atemp,humid,+,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 2]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 2]",
"--title=$config->{graphs}->{_nut3} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut3} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -709,7 +714,7 @@ sub nut_cgi {
"DEF:itemp=$rrd:nut" . $e . "_itemp:AVERAGE", "DEF:itemp=$rrd:nut" . $e . "_itemp:AVERAGE",
"DEF:atemp=$rrd:nut" . $e . "_atemp:AVERAGE", "DEF:atemp=$rrd:nut" . $e . "_atemp:AVERAGE",
"DEF:humid=$rrd:nut" . $e . "_humid:AVERAGE", "DEF:humid=$rrd:nut" . $e . "_humid:AVERAGE",
"CDEF:allvalues=itemp,atemp,humid,+,+", $cdef_allvalues_temp,
@CDEF, @CDEF,
@tmp); @tmp);
$err = RRDs::error; $err = RRDs::error;
@ -733,7 +738,7 @@ sub nut_cgi {
"DEF:itemp=$rrd:nut" . $e . "_itemp:AVERAGE", "DEF:itemp=$rrd:nut" . $e . "_itemp:AVERAGE",
"DEF:atemp=$rrd:nut" . $e . "_atemp:AVERAGE", "DEF:atemp=$rrd:nut" . $e . "_atemp:AVERAGE",
"DEF:humid=$rrd:nut" . $e . "_humid:AVERAGE", "DEF:humid=$rrd:nut" . $e . "_humid:AVERAGE",
"CDEF:allvalues=itemp,atemp,humid,+,+", $cdef_allvalues_temp,
@CDEF, @CDEF,
@tmpz); @tmpz);
$err = RRDs::error; $err = RRDs::error;
@ -783,6 +788,7 @@ sub nut_cgi {
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
} }
my $cdef_allvalues_batvolt = $gap_on_all_nan ? "CDEF:allvalues=battv,UN,0,1,IF,nomba,UN,0,1,IF,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=battv,nomba,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 3]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 3]",
"--title=$config->{graphs}->{_nut4} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut4} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -798,7 +804,7 @@ sub nut_cgi {
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:battv=$rrd:nut" . $e . "_battv:AVERAGE", "DEF:battv=$rrd:nut" . $e . "_battv:AVERAGE",
"DEF:nomba=$rrd:nut" . $e . "_nomba:AVERAGE", "DEF:nomba=$rrd:nut" . $e . "_nomba:AVERAGE",
"CDEF:allvalues=battv,nomba,+", $cdef_allvalues_batvolt,
@CDEF, @CDEF,
@tmp); @tmp);
$err = RRDs::error; $err = RRDs::error;
@ -821,7 +827,7 @@ sub nut_cgi {
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:battv=$rrd:nut" . $e . "_battv:AVERAGE", "DEF:battv=$rrd:nut" . $e . "_battv:AVERAGE",
"DEF:nomba=$rrd:nut" . $e . "_nomba:AVERAGE", "DEF:nomba=$rrd:nut" . $e . "_nomba:AVERAGE",
"CDEF:allvalues=battv,nomba,+", $cdef_allvalues_batvolt,
@CDEF, @CDEF,
@tmpz); @tmpz);
$err = RRDs::error; $err = RRDs::error;
@ -871,6 +877,7 @@ sub nut_cgi {
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
} }
my $cdef_allvalues_timeleft = $gap_on_all_nan ? "CDEF:allvalues=timel,UN,0,1,IF,minti,UN,0,1,IF,+,0,GT,1,UNKN,IF" : "CDEF:allvalues=timel,minti,+";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 4]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 4]",
"--title=$config->{graphs}->{_nut5} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut5} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -886,7 +893,7 @@ sub nut_cgi {
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:timel=$rrd:nut" . $e . "_timel:AVERAGE", "DEF:timel=$rrd:nut" . $e . "_timel:AVERAGE",
"DEF:minti=$rrd:nut" . $e . "_minti:AVERAGE", "DEF:minti=$rrd:nut" . $e . "_minti:AVERAGE",
"CDEF:allvalues=timel,minti,+", $cdef_allvalues_timeleft,
"CDEF:timel_min=timel,60,/", "CDEF:timel_min=timel,60,/",
"CDEF:minti_min=minti,60,/", "CDEF:minti_min=minti,60,/",
@CDEF, @CDEF,
@ -911,7 +918,7 @@ sub nut_cgi {
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:timel=$rrd:nut" . $e . "_timel:AVERAGE", "DEF:timel=$rrd:nut" . $e . "_timel:AVERAGE",
"DEF:minti=$rrd:nut" . $e . "_minti:AVERAGE", "DEF:minti=$rrd:nut" . $e . "_minti:AVERAGE",
"CDEF:allvalues=timel,minti,+", $cdef_allvalues_timeleft,
"CDEF:timel_min=timel,60,/", "CDEF:timel_min=timel,60,/",
"CDEF:minti_min=minti,60,/", "CDEF:minti_min=minti,60,/",
@CDEF, @CDEF,
@ -960,6 +967,7 @@ sub nut_cgi {
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
push(@tmp, "COMMENT: \\n"); push(@tmp, "COMMENT: \\n");
} }
my $cdef_allvalues_freq = $gap_on_all_nan ? "CDEF:allvalues=linef,UN,0,1,IF,0,GT,1,UNKN,IF" : "CDEF:allvalues=linef";
$pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 5]", $pic = $rrd{$version}->("$IMG_DIR" . "$IMG[$e * 6 + 5]",
"--title=$config->{graphs}->{_nut6} ($tf->{nwhen}$tf->{twhen})", "--title=$config->{graphs}->{_nut6} ($tf->{nwhen}$tf->{twhen})",
"--start=-$tf->{nwhen}$tf->{twhen}", "--start=-$tf->{nwhen}$tf->{twhen}",
@ -974,7 +982,7 @@ sub nut_cgi {
@{$cgi->{version12_small}}, @{$cgi->{version12_small}},
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:linef=$rrd:nut" . $e . "_linef:AVERAGE", "DEF:linef=$rrd:nut" . $e . "_linef:AVERAGE",
"CDEF:allvalues=linef", $cdef_allvalues_freq,
@CDEF, @CDEF,
@tmp); @tmp);
$err = RRDs::error; $err = RRDs::error;
@ -996,7 +1004,7 @@ sub nut_cgi {
@{$cgi->{version12_small}}, @{$cgi->{version12_small}},
@{$colors->{graph_colors}}, @{$colors->{graph_colors}},
"DEF:linef=$rrd:nut" . $e . "_linef:AVERAGE", "DEF:linef=$rrd:nut" . $e . "_linef:AVERAGE",
"CDEF:allvalues=linef", $cdef_allvalues_freq,
@CDEF, @CDEF,
@tmpz); @tmpz);
$err = RRDs::error; $err = RRDs::error;

View File

@ -4206,6 +4206,13 @@ This option, when enabled via \fIy\fP, shows \fInan\fP values for missing data i
.P .P
Default value: \fIn\fP Default value: \fIn\fP
.RE .RE
.P
.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
.SS Wowza Media Server (wowza.pm) .SS Wowza Media Server (wowza.pm)
This graph is able to monitor an unlimited number of Wowza servers. This graph is able to monitor an unlimited number of Wowza servers.
.P .P