Browse Source

check_junos, Nagios::Plugin::JUNOS: Pass $plugin and $junos to check subs.

Sebastian Harl 13 years ago
parent
commit
85c8c6d28f
2 changed files with 14 additions and 6 deletions
  1. 13 5
      check_junos.pl
  2. 1 1
      perl/lib/Nagios/Plugin/JUNOS.pm

+ 13 - 5
check_junos.pl

@@ -178,9 +178,11 @@ sub send_query
 	return $res;
 }
 
-sub check_interface {
-	my $iface = shift;
-	my $opts  = shift || {};
+sub check_interface
+{
+	my $plugin  = shift;
+	my $iface   = shift;
+	my $opts    = shift || {};
 	my @targets = @_;
 
 	my $name = get_iface_name($iface);
@@ -403,6 +405,8 @@ sub get_liface_marker
 
 sub check_interfaces
 {
+	my $plugin  = shift;
+	my $junos   = shift;
 	my @targets = @_;
 
 	my $opts = {
@@ -427,7 +431,7 @@ sub check_interfaces
 
 	foreach my $iface (@interfaces) {
 		my $name = get_iface_name($iface);
-		my $status = check_interface($iface, $opts, @targets);
+		my $status = check_interface($plugin, $iface, $opts, @targets);
 
 		if ($status == 0) {
 			++$down_count;
@@ -459,7 +463,7 @@ sub check_interfaces
 
 			my @phy_interfaces = get_interfaces($junos, {}, $phy_name);
 			foreach my $phy_iface (@phy_interfaces) {
-				if (check_interface($phy_iface, {}, $phy_name) == 0) {
+				if (check_interface($plugin, $phy_iface, {}, $phy_name) == 0) {
 					++$phys_down_count;
 					push @phys_down_ifaces, "$name -> $phy_name";
 				}
@@ -496,6 +500,8 @@ sub check_interfaces
 
 sub check_chassis_environment
 {
+	my $plugin  = shift;
+	my $junos   = shift;
 	my @targets = @_;
 
 	my $res = send_query($junos, 'get_environment_information');
@@ -589,6 +595,8 @@ sub check_chassis_environment
 
 sub check_system_storage
 {
+	my $plugin  = shift;
+	my $junos   = shift;
 	my @targets = @_;
 
 	my $res = send_query($junos, 'get_system_storage');

+ 1 - 1
perl/lib/Nagios/Plugin/JUNOS.pm

@@ -346,7 +346,7 @@ sub run_checks
 		);
 
 		my $sub = $self->get_check_impl($check->{'name'});
-		$sub->(@targets);
+		$sub->($self, $self->{'junos'}, @targets);
 	}
 }