Code

test GNU_SOURCE and include features.h if present to clear warning about asprintf...
[nagiosplug.git] / plugins / t / check_snmp.t
1 #! /usr/bin/perl -w
3 use strict;
4 use Helper;
5 use Cache;
6 use Test;
7 use vars qw($tests);
9 BEGIN {$tests = 8; plan tests => $tests}
11 my $null = '';
12 my $cmd;
13 my $str;
14 my $t;
15 my $community=get_option("snmp_community","SNMP community name");
17 exit(0) unless (-x "./check_snmp");
19 $cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:";
20 $str = `$cmd`;
21 $t += ok $?>>8,0;
22 print "Test was: $cmd\n" if ($?);
23 chomp $str;
24 $t += ok $str, '/^SNMP OK - \d+/';
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 $str = `$cmd`;
28 $t += ok $?>>8,0;
29 print "Test was: $cmd\n" if ($?);
30 chomp $str;
31 $t += ok $str, '/^SNMP OK - 1\s*$/';
33 $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:";
34 $str = `$cmd`;
35 $t += ok $?>>8,1;
36 print "Test was: $cmd\n" unless ($?);
37 chomp $str;
38 $t += ok $str, '/^SNMP WARNING - \*1\*\s*$/';
40 $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0";
41 $str = `$cmd`;
42 $t += ok $?>>8,2;
43 print "Test was: $cmd\n" unless ($?);
44 chomp $str;
45 $t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/';
47 #host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1
48 #enterprises.ucdavis.memory.memAvailSwap.0
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)'
51 exit(0) if defined($Test::Harness::VERSION);
52 exit($tests - $t);