From 4c3f4a9cb86e7b1b844da22b4f2b9b8e3a86fb62 Mon Sep 17 00:00:00 2001 From: Quentin Garnier Date: Thu, 17 Apr 2014 14:15:11 +0200 Subject: [PATCH] Refs #5362 Add a filter on printer trays --- .../printers/standard/rfc3805/mode/papertray.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm index e9c385b7d..1fd698e7e 100644 --- a/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm +++ b/centreon-plugins/hardware/printers/standard/rfc3805/mode/papertray.pm @@ -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