summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_snmp.t
diff options
context:
space:
mode:
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 @@
1#! /usr/bin/perl -w 1#! /usr/bin/perl -w -I ..
2#
3# Simple Network Management Protocol (SNMP) Test via check_snmp
4#
5# $Id$
6#
2 7
3use strict; 8use strict;
4use Helper;
5use Cache;
6use Test; 9use Test;
7use vars qw($tests); 10use NPTest;
8 11
9BEGIN {$tests = 8; plan tests => $tests} 12use vars qw($tests);
13BEGIN {$tests = 12; plan tests => $tests}
10 14
11my $null = '';
12my $cmd;
13my $str;
14my $t; 15my $t;
15my $community=get_option("snmp_community","SNMP community name"); 16
16 17if ( -x "./check_snmp" )
17exit(0) unless (-x "./check_snmp"); 18{
18 19 my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost",
19$cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:"; 20 "A host providing an SNMP Service");
20$str = `$cmd`; 21
21$t += ok $?>>8,0; 22 my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public",
22print "Test was: $cmd\n" if ($?); 23 "The SNMP Community string for SNMP Testing" );
23chomp $str; 24
24$t += ok $str, '/^SNMP OK - \d+/'; 25 my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
25 26 "The hostname of system not responsive to network requests" );
26$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1"; 27
27$str = `$cmd`; 28 my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
28$t += ok $?>>8,0; 29 "An invalid (not known to DNS) hostname" );
29print "Test was: $cmd\n" if ($?); 30
30chomp $str; 31 my %exceptions = ( 3 => "No SNMP Server present?" );
31$t += ok $str, '/^SNMP OK - 1\s*$/'; 32
32 33
33$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:"; 34 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:",
34$str = `$cmd`; 35 { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions );
35$t += ok $?>>8,1; 36
36print "Test was: $cmd\n" unless ($?); 37 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1",
37chomp $str; 38 { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s*$/', %exceptions );
38$t += ok $str, '/^SNMP WARNING - \*1\*\s*$/'; 39
39 40 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:",
40$cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0"; 41 { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s*$/', %exceptions );
41$str = `$cmd`; 42
42$t += ok $?>>8,2; 43 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0",
43print "Test was: $cmd\n" unless ($?); 44 { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s*$/', %exceptions );
44chomp $str; 45
45$t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/'; 46 $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
46 47
47#host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1 48 $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
48#enterprises.ucdavis.memory.memAvailSwap.0 49
49#./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)' 50}
51else
52{
53 $t += skipMissingCmd( "./check_snmp", $tests );
54}
50 55
51exit(0) if defined($Test::Harness::VERSION); 56exit(0) if defined($Test::Harness::VERSION);
52exit($tests - $t); 57exit($tests - $t);