From d051c3201929d945c760906847659e7c8c78eddb Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 3 Jan 2012 10:21:38 +0100 Subject: [PATCH] Nagios::Plugin::JUNOS: Added add_common_args(). --- check_junos.pl | 31 +------------------------ perl/lib/Nagios/Plugin/JUNOS.pm | 40 +++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 32 deletions(-) diff --git a/check_junos.pl b/check_junos.pl index 3dab609..e16f7d2 100755 --- a/check_junos.pl +++ b/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 => '', - }, -); - 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}); diff --git a/perl/lib/Nagios/Plugin/JUNOS.pm b/perl/lib/Nagios/Plugin/JUNOS.pm index 72af7fe..5ce9775 100644 --- a/perl/lib/Nagios/Plugin/JUNOS.pm +++ b/perl/lib/Nagios/Plugin/JUNOS.pm @@ -1,6 +1,6 @@ ############################################################################# -# (c) 2012 Sebastian "tokkee" Harl # -# and team(ix) GmbH, Nuernberg, Germany # +# (c) 2011-2012 Sebastian "tokkee" Harl # +# 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 => '', + }, + ); + + foreach my $arg (@args) { + $self->add_arg($arg); + } +} + sub add_check_impl { my $self = shift;