Add a filter on printer trays
This commit is contained in:
Quentin Garnier 2014-04-17 14:15:11 +02:00
parent 5872dab3f0
commit 4c3f4a9cb8
1 changed files with 12 additions and 1 deletions

View File

@ -55,6 +55,7 @@ sub new {
{
"warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' },
"filter:s" => { name => 'filter' },
});
return $self;
@ -106,6 +107,12 @@ sub run {
$descr = $hrDeviceIndex . '#' . $prtInputIndex;
}
if (defined($self->{option_results}->{filter}) && $self->{option_results}->{filter} ne '' &&
$descr !~ /$self->{option_results}->{filter}/) {
$self->{output}->output_add(long_msg => "Skipping tray '$descr': not matching filter.");
next;
}
if (!defined($unit_managed{$unit})) {
$self->{output}->output_add(long_msg => "Skipping input '$descr': unit not managed.");
next;
@ -114,7 +121,7 @@ sub run {
$self->{output}->output_add(long_msg => "Skipping tray '$descr': no level.");
next;
} elsif ($current_value == -2) {
$self->{output}->output_add(long_msg => "Skippinp tray'$descr': level unknown.");
$self->{output}->output_add(long_msg => "Skippinp tray '$descr': level unknown.");
next;
} elsif ($current_value == -3) {
$self->{output}->output_add(long_msg => "Tray '$descr': no level but some space remaining.");
@ -161,6 +168,10 @@ Threshold warning in percent.
Threshold critical in percent.
=item B<--filter>
Filter tray to check (can use a regexp).
=back
=cut