Browse Source

Nagios::Plugin::JUNOS: Added add_common_args().

Sebastian Harl 13 years ago
parent
commit
d051c32019
2 changed files with 39 additions and 32 deletions
  1. 1 30
      check_junos.pl
  2. 38 2
      perl/lib/Nagios/Plugin/JUNOS.pm

+ 1 - 30
check_junos.pl

@@ -90,33 +90,6 @@ Warning and critical thresholds may be specified in the format documented at
 http://nagiosplug.sourceforge.net/developer-guidelines.html#THRESHOLDFORMAT.",
 );
 
-my @args = (
-	{
-		spec    => 'host|H=s',
-		usage   => '-H, --host=HOSTNAME',
-		desc    => 'Hostname/IP of Juniper box to connect to',
-		default => 'localhost',
-	},
-	{
-		spec    => 'port|p=i',
-		usage   => '-p, --port=PORT',
-		desc    => 'Port to connect to',
-		default => 22,
-	},
-	{
-		spec    => 'user|U=s',
-		usage   => '-U, --user=USERNAME',
-		desc    => 'Username to log into box as',
-		default => 'root',
-	},
-	{
-		spec    => 'password|P=s',
-		usage   => '-P, --password=PASSWORD',
-		desc    => 'Password for login username',
-		default => '<prompt>',
-	},
-);
-
 my %checks = (
 	interfaces          => \&check_interfaces,
 	chassis_environment => \&check_chassis_environment,
@@ -125,9 +98,7 @@ my %checks = (
 
 my $junos = undef;
 
-foreach my $arg (@args) {
-	$plugin->add_arg($arg);
-}
+$plugin->add_common_args();
 
 foreach my $check (keys %checks) {
 	$plugin->add_check_impl($check, $checks{$check});

+ 38 - 2
perl/lib/Nagios/Plugin/JUNOS.pm

@@ -1,6 +1,6 @@
 #############################################################################
-# (c) 2012 Sebastian "tokkee" Harl <sh@teamix.net>                          #
-#          and team(ix) GmbH, Nuernberg, Germany                            #
+# (c) 2011-2012 Sebastian "tokkee" Harl <sh@teamix.net>                     #
+#               and team(ix) GmbH, Nuernberg, Germany                       #
 #                                                                           #
 # This file is part of "team(ix) Monitoring Plugins"                        #
 # URL: http://oss.teamix.org/projects/monitoringplugins/                    #
@@ -107,6 +107,42 @@ sub add_arg
 	);
 }
 
+sub add_common_args
+{
+	my $self = shift;
+
+	my @args = (
+		{
+			spec    => 'host|H=s',
+			usage   => '-H, --host=HOSTNAME',
+			desc    => 'Hostname/IP of Juniper box to connect to',
+			default => 'localhost',
+		},
+		{
+			spec    => 'port|p=i',
+			usage   => '-p, --port=PORT',
+			desc    => 'Port to connect to',
+			default => 22,
+		},
+		{
+			spec    => 'user|U=s',
+			usage   => '-U, --user=USERNAME',
+			desc    => 'Username to log into box as',
+			default => 'root',
+		},
+		{
+			spec    => 'password|P=s',
+			usage   => '-P, --password=PASSWORD',
+			desc    => 'Password for login username',
+			default => '<prompt>',
+		},
+	);
+
+	foreach my $arg (@args) {
+		$self->add_arg($arg);
+	}
+}
+
 sub add_check_impl
 {
 	my $self = shift;