check_procs.t 1.6 KB

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