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

View File

@ -55,6 +55,7 @@ sub new {
{ {
"warning:s" => { name => 'warning' }, "warning:s" => { name => 'warning' },
"critical:s" => { name => 'critical' }, "critical:s" => { name => 'critical' },
"filter:s" => { name => 'filter' },
}); });
return $self; return $self;
@ -106,6 +107,12 @@ sub run {
$descr = $hrDeviceIndex . '#' . $prtInputIndex; $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})) { if (!defined($unit_managed{$unit})) {
$self->{output}->output_add(long_msg => "Skipping input '$descr': unit not managed."); $self->{output}->output_add(long_msg => "Skipping input '$descr': unit not managed.");
next; next;
@ -161,6 +168,10 @@ Threshold warning in percent.
Threshold critical in percent. Threshold critical in percent.
=item B<--filter>
Filter tray to check (can use a regexp).
=back =back
=cut =cut