aboutsummaryrefslogtreecommitdiff
path: root/plugins/t/check_snmp.t
diff options
context:
space:
mode:
authorGravatar Peter Bray <illumino@users.sourceforge.net> 2005-07-25 01:47:15 +0000
committerGravatar Peter Bray <illumino@users.sourceforge.net> 2005-07-25 01:47:15 +0000
commitcdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1 (patch)
tree62b074eaca618762fb03f94708ec3def50037697 /plugins/t/check_snmp.t
parent05853f47eb6e608de993cc59343c73b96b9b33e2 (diff)
downloadmonitoring-plugins-cdc06cc3e2c4670d3cd46b0a03adcf7e6958eff1.tar.gz
[1185704] New Testing Infrastructure.
Complete rewrite of the original testing infrastructure and all test cases (to use the new infrastructure) See NPTest.pm and issue 1185704 for more details. git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1207 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/t/check_snmp.t')
-rw-r--r--plugins/t/check_snmp.t91
1 files changed, 48 insertions, 43 deletions
diff --git a/plugins/t/check_snmp.t b/plugins/t/check_snmp.t
index 162b0b9b..b45b6c01 100644
--- a/plugins/t/check_snmp.t
+++ b/plugins/t/check_snmp.t
@@ -1,52 +1,57 @@
-#! /usr/bin/perl -w
+#! /usr/bin/perl -w -I ..
+#
+# Simple Network Management Protocol (SNMP) Test via check_snmp
+#
+# $Id$
+#
use strict;
-use Helper;
-use Cache;
use Test;
-use vars qw($tests);
+use NPTest;
-BEGIN {$tests = 8; plan tests => $tests}
+use vars qw($tests);
+BEGIN {$tests = 12; plan tests => $tests}
-my $null = '';
-my $cmd;
-my $str;
my $t;
-my $community=get_option("snmp_community","SNMP community name");
-
-exit(0) unless (-x "./check_snmp");
-
-$cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:";
-$str = `$cmd`;
-$t += ok $?>>8,0;
-print "Test was: $cmd\n" if ($?);
-chomp $str;
-$t += ok $str, '/^SNMP OK - \d+/';
-
-$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1";
-$str = `$cmd`;
-$t += ok $?>>8,0;
-print "Test was: $cmd\n" if ($?);
-chomp $str;
-$t += ok $str, '/^SNMP OK - 1\s*$/';
-
-$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:";
-$str = `$cmd`;
-$t += ok $?>>8,1;
-print "Test was: $cmd\n" unless ($?);
-chomp $str;
-$t += ok $str, '/^SNMP WARNING - \*1\*\s*$/';
-
-$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0";
-$str = `$cmd`;
-$t += ok $?>>8,2;
-print "Test was: $cmd\n" unless ($?);
-chomp $str;
-$t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/';
-
-#host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1
-#enterprises.ucdavis.memory.memAvailSwap.0
-#./check_snmp 127.0.0.1 -C staff -o enterprises.ucdavis.diskTable.dskEntry.dskAvail.1,enterprises.ucdavis.diskTable.dskEntry.dskPercent.1 -w 100000: -c 50000: -l Space on root -u 'bytes free (','% used)'
+
+if ( -x "./check_snmp" )
+{
+ my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost",
+ "A host providing an SNMP Service");
+
+ my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public",
+ "The SNMP Community string for SNMP Testing" );
+
+ my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
+ "The hostname of system not responsive to network requests" );
+
+ my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
+ "An invalid (not known to DNS) hostname" );
+
+ my %exceptions = ( 3 => "No SNMP Server present?" );
+
+
+ $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:",
+ { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions );
+
+ $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1",
+ { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s*$/', %exceptions );
+
+ $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:",
+ { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s*$/', %exceptions );
+
+ $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0",
+ { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions );
+
+ $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
+
+ $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
+
+}
+else
+{
+ $t += skipMissingCmd( "./check_snmp", $tests );
+}
exit(0) if defined($Test::Harness::VERSION);
exit($tests - $t);