acd122014137866eb667d1a5fe17168ffb3d4082
1 #! /usr/bin/perl -w -I ..
2 #
3 # Simple Network Management Protocol (SNMP) Test via check_snmp
4 #
5 # $Id$
6 #
8 use strict;
9 use Test;
10 use NPTest;
12 use vars qw($tests);
13 BEGIN {$tests = 12; plan tests => $tests}
15 my $t;
17 if ( -x "./check_snmp" )
18 {
19 my $host_snmp = getTestParameter( "host_snmp", "NP_HOST_SNMP", "localhost",
20 "A host providing an SNMP Service");
22 my $snmp_community = getTestParameter( "snmp_community", "NP_SNMP_COMMUNITY", "public",
23 "The SNMP Community string for SNMP Testing" );
25 my $host_nonresponsive = getTestParameter( "host_nonresponsive", "NP_HOST_NONRESPONSIVE", "10.0.0.1",
26 "The hostname of system not responsive to network requests" );
28 my $hostname_invalid = getTestParameter( "hostname_invalid", "NP_HOSTNAME_INVALID", "nosuchhost",
29 "An invalid (not known to DNS) hostname" );
31 my %exceptions = ( 3 => "No SNMP Server present?" );
34 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:",
35 { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - \d+/', %exceptions );
37 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1",
38 { 0 => 'continue', 3 => 'skip' }, '/^SNMP OK - 1\s.*$/', %exceptions );
40 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:",
41 { 1 => 'continue', 3 => 'skip' }, '/^SNMP WARNING - \*1\*\s.*$/', %exceptions );
43 $t += checkCmd( "./check_snmp -H $host_snmp -C $snmp_community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0",
44 { 2 => 'continue', 3 => 'skip' }, '/^SNMP CRITICAL - \*1\*\s.*$/', %exceptions );
46 $t += checkCmd( "./check_snmp -H $host_nonresponsive -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
48 $t += checkCmd( "./check_snmp -H $hostname_invalid -C $snmp_community -o system.sysUpTime.0 -w 1: -c 1:", 3, '/SNMP problem - /' );
50 }
51 else
52 {
53 $t += skipMissingCmd( "./check_snmp", $tests );
54 }
56 exit(0) if defined($Test::Harness::VERSION);
57 exit($tests - $t);