check_procs.t 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #! /usr/bin/perl -w -I ..
  2. #
  3. # Process Tests via check_procs
  4. #
  5. #
  6. use strict;
  7. use Test::More;
  8. use NPTest;
  9. my $t;
  10. if (`uname -s` eq "SunOS\n" && ! -x "/usr/local/nagios/libexec/pst3") {
  11. plan skip_all => "Ignoring tests on solaris because of pst3";
  12. } else {
  13. plan tests => 12;
  14. }
  15. my $result;
  16. $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000" );
  17. is( $result->return_code, 0, "Checking less than 10000 processes" );
  18. like( $result->output, '/^PROCS OK: [0-9]+ process(es)?$/', "Output correct" );
  19. $result = NPTest->testCmd( "./check_procs -w 100000 -c 100000 -s Z" );
  20. is( $result->return_code, 0, "Checking less than 100000 zombie processes" );
  21. like( $result->output, '/^PROCS OK: [0-9]+ process(es)? with /', "Output correct" );
  22. $result = NPTest->testCmd( "./check_procs -w 0 -c 100000" );
  23. is( $result->return_code, 1, "Checking warning if processes > 0" );
  24. like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)?$/', "Output correct" );
  25. $result = NPTest->testCmd( "./check_procs -w 0 -c 0" );
  26. is( $result->return_code, 2, "Checking critical if processes > 0" );
  27. like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)?$/', "Output correct" );
  28. $result = NPTest->testCmd( "./check_procs -w 0 -c 0 -s S" );
  29. is( $result->return_code, 2, "Checking critical if sleeping processes" );
  30. like( $result->output, '/^PROCS CRITICAL: [0-9]+ process(es)? with /', "Output correct" );
  31. $result = NPTest->testCmd( "./check_procs -w 0 -c 100000 -p 1" );
  32. is( $result->return_code, 1, "Checking warning for processes by parentid = 1" );
  33. like( $result->output, '/^PROCS WARNING: [0-9]+ process(es)? with PPID = 1/', "Output correct" );