From 8ead9bcf0837d593ef0baf5d99fd48fcc8111c3d Mon Sep 17 00:00:00 2001 From: Colin Gagnaire Date: Mon, 29 Jul 2019 10:27:32 +0200 Subject: [PATCH] fix junos threshold overload instance --- .../juniper/common/junos/mode/components/alarm.pm | 4 ++-- network/juniper/common/junos/mode/components/fru.pm | 2 +- .../common/junos/mode/components/operating.pm | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/network/juniper/common/junos/mode/components/alarm.pm b/network/juniper/common/junos/mode/components/alarm.pm index fd132ea44..dec75e8a1 100644 --- a/network/juniper/common/junos/mode/components/alarm.pm +++ b/network/juniper/common/junos/mode/components/alarm.pm @@ -41,7 +41,7 @@ sub check_alarm { $options{name}, $options{value}, $options{instance} ) ); - my $exit = $self->get_severity(section => 'alarm', value => $options{value}); + my $exit = $self->get_severity(section => 'alarm', instance => $options{instance}, value => $options{value}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add( severity => $exit, @@ -66,7 +66,7 @@ sub check { check_alarm($self, instance => 0, name => 'yellow', value => $map_alarm_states{$results->{$oid_jnxYellowAlarmState}}) if (defined($results->{$oid_jnxYellowAlarmState})); - check_alarm($self, instance => 0, name => 'red', value => $map_alarm_states{$results->{$oid_jnxRedAlarmState}}) + check_alarm($self, instance => 1, name => 'red', value => $map_alarm_states{$results->{$oid_jnxRedAlarmState}}) if (defined($results->{$oid_jnxRedAlarmState})); } diff --git a/network/juniper/common/junos/mode/components/fru.pm b/network/juniper/common/junos/mode/components/fru.pm index 9cbb99589..9abc810cf 100644 --- a/network/juniper/common/junos/mode/components/fru.pm +++ b/network/juniper/common/junos/mode/components/fru.pm @@ -93,7 +93,7 @@ sub check { $self->{output}->output_add(long_msg => sprintf("fru '%s' state is %s [instance: %s, type: %s, offline reason: %s]", $name, $result->{jnxFruState}, $instance, $map_fru_type{$type}, $result->{jnxFruOfflineReason})); - my $exit = $self->get_severity(section => 'fru', value => $result->{jnxFruState}); + my $exit = $self->get_severity(section => 'fru', instance => $instance, value => $result->{jnxFruState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Fru '%s' state is %s [offline reason: %s]", $name, $result->{jnxFruState}, diff --git a/network/juniper/common/junos/mode/components/operating.pm b/network/juniper/common/junos/mode/components/operating.pm index 137aa5c79..d0464e3d9 100644 --- a/network/juniper/common/junos/mode/components/operating.pm +++ b/network/juniper/common/junos/mode/components/operating.pm @@ -44,18 +44,22 @@ sub check { jnxOperatingState => { oid => '.1.3.6.1.4.1.2636.3.1.13.1.6', map => \%map_operating_states }, }; - my $results = $self->{snmp}->get_table(oid => $self->{oids_operating}->{jnxOperatingEntry}, start => $mapping->{jnxOperatingState}->{oid}, end => $mapping->{jnxOperatingState}->{oid}); + my $results = $self->{snmp}->get_table(oid => $self->{oids_operating}->{jnxOperatingEntry}, + start => $mapping->{jnxOperatingState}->{oid}, end => $mapping->{jnxOperatingState}->{oid}); - foreach my $instance (sort $self->get_instances(oid_entry => $self->{oids_operating}->{jnxOperatingEntry}, oid_name => $self->{oids_operating}->{jnxOperatingDescr})) { + foreach my $instance (sort $self->get_instances(oid_entry => $self->{oids_operating}->{jnxOperatingEntry}, + oid_name => $self->{oids_operating}->{jnxOperatingDescr})) { my $result = $self->{snmp}->map_instance(mapping => $mapping, results => $results, instance => $instance); - my $desc = $self->get_cache(oid_entry => $self->{oids_operating}->{jnxOperatingEntry}, oid_name => $self->{oids_operating}->{jnxOperatingDescr}, instance => $instance); + my $desc = $self->get_cache(oid_entry => $self->{oids_operating}->{jnxOperatingEntry}, + oid_name => $self->{oids_operating}->{jnxOperatingDescr}, instance => $instance); next if ($self->check_filter(section => 'operating', instance => $instance, name => $desc)); $self->{components}->{operating}->{total}++; $self->{output}->output_add(long_msg => sprintf("operating '%s' state is %s [instance: %s]", $desc, $result->{jnxOperatingState}, $instance)); - my $exit = $self->get_severity(section => 'operating', value => $result->{jnxOperatingState}); + my $exit = $self->get_severity(section => 'operating', instance => $instance, + value => $result->{jnxOperatingState}); if (!$self->{output}->is_status(value => $exit, compare => 'ok', litteral => 1)) { $self->{output}->output_add(severity => $exit, short_msg => sprintf("Operating '%s' state is %s",