From f4fdf36e4e807e6b858e664fdb8a2f7956b31702 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 3 Jan 2012 08:05:21 +0100 Subject: [PATCH] Nagios::Plugin::JUNOS: Check, if configure() has been called. --- perl/lib/Nagios/Plugin/JUNOS.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/perl/lib/Nagios/Plugin/JUNOS.pm b/perl/lib/Nagios/Plugin/JUNOS.pm index 19ed761..4cad1a0 100644 --- a/perl/lib/Nagios/Plugin/JUNOS.pm +++ b/perl/lib/Nagios/Plugin/JUNOS.pm @@ -33,6 +33,8 @@ package Nagios::Plugin::JUNOS; +use Carp; + use POSIX qw( :termios_h ); use Nagios::Plugin; @@ -193,6 +195,10 @@ sub set_checks my $err_str = "ERROR:"; + if (! defined($self->{'conf'}->{'timeout'})) { + croak "No timeout set -- did you call configure()?"; + } + if (scalar(@checks) == 0) { $self->{'conf'}->{'checks'}[0] = { name => $default, @@ -233,6 +239,10 @@ sub connect my $host = $self->{'conf'}->{'host'}; my $user = $self->{'conf'}->{'user'}; + if ((! $host) || (! $user)) { + croak "Host and/or user not set -- did you call configure()?"; + } + if (! $self->opts->password) { my $term = POSIX::Termios->new(); my $lflag;