check_snmp.t 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #! /usr/bin/perl -w
  2. use strict;
  3. use Helper;
  4. use Cache;
  5. use Test;
  6. use vars qw($tests);
  7. BEGIN {$tests = 8; plan tests => $tests}
  8. my $null = '';
  9. my $cmd;
  10. my $str;
  11. my $t;
  12. my $community=get_option("snmp_community","SNMP community name");
  13. exit(0) unless (-x "./check_snmp");
  14. $cmd = "./check_snmp -H 127.0.0.1 -C $community -o system.sysUpTime.0 -w 1: -c 1:";
  15. $str = `$cmd`;
  16. $t += ok $?>>8,0;
  17. print "Test was: $cmd\n" if ($?);
  18. chomp $str;
  19. $t += ok $str, '/^SNMP OK - \d+/';
  20. $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 1:1 -c 1:1";
  21. $str = `$cmd`;
  22. $t += ok $?>>8,0;
  23. print "Test was: $cmd\n" if ($?);
  24. chomp $str;
  25. $t += ok $str, '/^SNMP OK - 1\s*$/';
  26. $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w 0 -c 1:";
  27. $str = `$cmd`;
  28. $t += ok $?>>8,1;
  29. print "Test was: $cmd\n" unless ($?);
  30. chomp $str;
  31. $t += ok $str, '/^SNMP WARNING - \*1\*\s*$/';
  32. $cmd = "./check_snmp -H 127.0.0.1 -C $community -o host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 -w :0 -c 0";
  33. $str = `$cmd`;
  34. $t += ok $?>>8,2;
  35. print "Test was: $cmd\n" unless ($?);
  36. chomp $str;
  37. $t += ok $str, '/^SNMP CRITICAL - \*1\*\s*$/';
  38. #host.hrSWRun.hrSWRunTable.hrSWRunEntry.hrSWRunIndex.1 = 1
  39. #enterprises.ucdavis.memory.memAvailSwap.0
  40. #./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)'
  41. exit(0) if defined($Test::Harness::VERSION);
  42. exit($tests - $t);