+ Add option --filter-uom (Fix #220)
This commit is contained in:
parent
c0c8947f93
commit
bc73c9a360
|
@ -40,6 +40,7 @@ sub new {
|
|||
"range-perfdata:s" => { name => 'range_perfdata' },
|
||||
"filter-perfdata:s" => { name => 'filter_perfdata' },
|
||||
"change-perfdata:s@" => { name => 'change_perfdata' },
|
||||
"filter-uom:s" => { name => 'filter_uom' },
|
||||
"verbose" => { name => 'verbose' },
|
||||
"debug" => { name => 'debug' },
|
||||
"opt-exit:s" => { name => 'opt_exit', default => 'unknown' },
|
||||
|
@ -282,6 +283,8 @@ sub output_json {
|
|||
|
||||
my %values = ();
|
||||
foreach my $key (keys %$perf) {
|
||||
$perf->{$key} = '' if (defined($self->{option_results}->{filter_uom}) && $key eq 'unit' &&
|
||||
$perf->{$key} !~ /$self->{option_results}->{filter_uom}/);
|
||||
$values{$key} = $perf->{$key};
|
||||
}
|
||||
|
||||
|
@ -372,6 +375,8 @@ sub output_xml {
|
|||
$child_perfdata = $self->{xml_output}->createElement("perfdata");
|
||||
$child_plugin_perfdata->addChild($child_perfdata);
|
||||
foreach my $key (keys %$perf) {
|
||||
$perf->{$key} = '' if (defined($self->{option_results}->{filter_uom}) && $key eq 'unit' &&
|
||||
$perf->{$key} !~ /$self->{option_results}->{filter_uom}/);
|
||||
my $child = $self->{xml_output}->createElement($key);
|
||||
$child->appendText($perf->{$key});
|
||||
$child_perfdata->addChild($child);
|
||||
|
@ -412,6 +417,8 @@ sub output_txt {
|
|||
foreach my $perf (@{$self->{perfdatas}}) {
|
||||
next if (defined($self->{option_results}->{filter_perfdata}) &&
|
||||
$perf->{label} !~ /$self->{option_results}->{filter_perfdata}/);
|
||||
$perf->{unit} = '' if (defined($self->{option_results}->{filter_uom}) &&
|
||||
$perf->{unit} !~ /$self->{option_results}->{filter_uom}/);
|
||||
$self->range_perfdata(ranges => [\$perf->{warning}, \$perf->{critical}]);
|
||||
print " '" . $perf->{label} . "'=" . $perf->{value} . $perf->{unit} . ";" . $perf->{warning} . ";" . $perf->{critical} . ";" . $perf->{min} . ";" . $perf->{max};
|
||||
}
|
||||
|
@ -776,6 +783,10 @@ Syntax: regexp_matching,regexp_substitute
|
|||
Change perfdata range thresholds display:
|
||||
1 = start value equals to '0' is removed, 2 = threshold range is not display.
|
||||
|
||||
=item B<--filter-uom>
|
||||
|
||||
Filter UOM that match the regexp.
|
||||
|
||||
=item B<--opt-exit>
|
||||
|
||||
Exit code for an option error, usage (default: unknown).
|
||||
|
|
Loading…
Reference in New Issue