check_junos: chassis_environment: Support targets.
If a target has been specified, which is absent, this is treated as status CRITICAL.
This commit is contained in:
parent
0b0be0f9ea
commit
90915aa6a8
|
@ -298,6 +298,12 @@ foreach my $check (@{$conf{'checks'}}) {
|
||||||
|
|
||||||
my $class = "";
|
my $class = "";
|
||||||
foreach my $item (get_object_by_spec($res, 'environment-item')) {
|
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')) {
|
if (get_object_value_by_spec($item, 'class')) {
|
||||||
$class = get_object_value_by_spec($item, 'class');
|
$class = get_object_value_by_spec($item, 'class');
|
||||||
}
|
}
|
||||||
|
@ -305,8 +311,11 @@ foreach my $check (@{$conf{'checks'}}) {
|
||||||
my $status = get_object_value_by_spec($item, 'status');
|
my $status = get_object_value_by_spec($item, 'status');
|
||||||
|
|
||||||
if ($status eq "Absent") {
|
if ($status eq "Absent") {
|
||||||
|
if (! scalar(@targets)) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
# else: check this component
|
||||||
|
}
|
||||||
|
|
||||||
my $state = UNKNOWN;
|
my $state = UNKNOWN;
|
||||||
if (defined $status_map{$status}) {
|
if (defined $status_map{$status}) {
|
||||||
|
@ -319,9 +328,8 @@ foreach my $check (@{$conf{'checks'}}) {
|
||||||
++$items_ok;
|
++$items_ok;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$plugin->add_message($state, $class . " "
|
$plugin->add_message($state, $class . " $name: status " .
|
||||||
. get_object_value_by_spec($item, 'name')
|
$status);
|
||||||
. ": status " . $status);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue