浏览代码

Nagios::Plugin::JUNOS: Overwrite nagios_exit and call $junos->disconnect().

(Then call SUPER::nagios_exit.)
Sebastian Harl 13 年之前
父节点
当前提交
75c3337376
共有 2 个文件被更改,包括 10 次插入2 次删除
  1. 0 2
      check_junos.pl
  2. 10 0
      perl/lib/Nagios/Plugin/JUNOS.pm

+ 0 - 2
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

+ 10 - 0
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;