This commit is contained in:
Quentin Garnier 2014-12-08 19:50:08 +01:00
parent b7f04e1341
commit 0d1e0af937
1 changed files with 12 additions and 2 deletions

View File

@ -62,6 +62,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;
@ -132,6 +133,11 @@ sub run {
$self->{output}->output_add(long_msg => "Marker supply '$descr': no level but some space remaining."); $self->{output}->output_add(long_msg => "Marker supply '$descr': no level but some space remaining.");
next; next;
} }
if (defined($self->{option_results}->{filter}) && $self->{option_results}->{filter} ne '' &&
$instance !~ /$self->{option_results}->{filter}/) {
$self->{output}->output_add(long_msg => "Skipping marker supply '$descr' (instance: $instance): filter.");
next;
}
my $prct_value = $current_value; my $prct_value = $current_value;
if ($unit_managed{$unit} == 1) { if ($unit_managed{$unit} == 1) {
@ -139,7 +145,7 @@ sub run {
} }
my $exit = $self->{perfdata}->threshold_check(value => $prct_value, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]); my $exit = $self->{perfdata}->threshold_check(value => $prct_value, threshold => [ { label => 'critical', 'exit_litteral' => 'critical' }, { label => 'warning', exit_litteral => 'warning' } ]);
$self->{output}->output_add(long_msg => sprintf("Marker supply '%s': %.2f %%", $descr, $prct_value)); $self->{output}->output_add(long_msg => sprintf("Marker supply '%s': %.2f %% [instance: '%s']", $descr, $prct_value, $hrDeviceIndex . '.' . $prtMarkerSuppliesIndex));
if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) {
$self->{output}->output_add(severity => $exit, $self->{output}->output_add(severity => $exit,
short_msg => sprintf("Marker supply '%s': %.2f %%", $descr, $prct_value)); short_msg => sprintf("Marker supply '%s': %.2f %%", $descr, $prct_value));
@ -149,7 +155,7 @@ sub run {
if ($result->{$oid_prtMarkerSuppliesColorantIndex . '.' . $instance} != 0) { if ($result->{$oid_prtMarkerSuppliesColorantIndex . '.' . $instance} != 0) {
$label = $result2->{$oid_prtMarkerColorantValue . '.' . $hrDeviceIndex . '.' . $result->{$oid_prtMarkerSuppliesColorantIndex . '.' . $instance}}; $label = $result2->{$oid_prtMarkerColorantValue . '.' . $hrDeviceIndex . '.' . $result->{$oid_prtMarkerSuppliesColorantIndex . '.' . $instance}};
if (defined($perf_label->{$label})) { if (defined($perf_label->{$label})) {
$label .= '#' . $hrDeviceIndex . '#' . $result->{$oid_prtMarkerSuppliesColorantIndex . '.' . $instance}; $label .= '#' . $hrDeviceIndex . '#' . $prtMarkerSuppliesIndex;
} }
} }
$perf_label->{$label} = 1; $perf_label->{$label} = 1;
@ -183,6 +189,10 @@ Threshold warning in percent.
Threshold critical in percent. Threshold critical in percent.
=item B<--filter>
Filter maker supply instance.
=back =back
=cut =cut