From 90915aa6a8e881a269100963e576c6e16ad2660b Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Mon, 2 Jan 2012 14:08:47 +0100 Subject: [PATCH] check_junos: chassis_environment: Support targets. If a target has been specified, which is absent, this is treated as status CRITICAL. --- check_junos.pl | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/check_junos.pl b/check_junos.pl index f5565ac..20642af 100755 --- a/check_junos.pl +++ b/check_junos.pl @@ -298,6 +298,12 @@ foreach my $check (@{$conf{'checks'}}) { my $class = ""; foreach my $item (get_object_by_spec($res, 'environment-item')) { + my $name = get_object_value_by_spec($item, 'name'); + + if (scalar(@targets) && (! grep { m/^$name$/ } @targets)) { + next; + } + if (get_object_value_by_spec($item, 'class')) { $class = get_object_value_by_spec($item, 'class'); } @@ -305,7 +311,10 @@ foreach my $check (@{$conf{'checks'}}) { my $status = get_object_value_by_spec($item, 'status'); if ($status eq "Absent") { - next; + if (! scalar(@targets)) { + next; + } + # else: check this component } my $state = UNKNOWN; @@ -319,9 +328,8 @@ foreach my $check (@{$conf{'checks'}}) { ++$items_ok; } else { - $plugin->add_message($state, $class . " " - . get_object_value_by_spec($item, 'name') - . ": status " . $status); + $plugin->add_message($state, $class . " $name: status " . + $status); } }