From 75c3337376f31f3910f65bacf789e4b2252d3f8f Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 3 Jan 2012 10:16:31 +0100 Subject: [PATCH] Nagios::Plugin::JUNOS: Overwrite nagios_exit and call $junos->disconnect(). (Then call SUPER::nagios_exit.) --- check_junos.pl | 2 -- perl/lib/Nagios/Plugin/JUNOS.pm | 10 ++++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/check_junos.pl b/check_junos.pl index 395dfba..3dab609 100755 --- a/check_junos.pl +++ b/check_junos.pl @@ -144,8 +144,6 @@ $plugin->run_checks(); my ($code, $msg) = $plugin->check_messages(join => ', '); -$junos->disconnect(); - $plugin->nagios_exit($code, $msg); sub check_interface diff --git a/perl/lib/Nagios/Plugin/JUNOS.pm b/perl/lib/Nagios/Plugin/JUNOS.pm index 265a128..72af7fe 100644 --- a/perl/lib/Nagios/Plugin/JUNOS.pm +++ b/perl/lib/Nagios/Plugin/JUNOS.pm @@ -438,6 +438,16 @@ sub get_query_object_value return $res->getFirstChild->getNodeValue; } +sub nagios_exit +{ + my $self = shift; + + if ($self->{'junos'}) { + $self->{'junos'}->disconnect(); + } + $self->SUPER::nagios_exit(@_); +} + sub verbose { my $self = shift;