summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_mailq.pl8
-rw-r--r--plugins-scripts/t/check_file_age.t103
2 files changed, 41 insertions, 70 deletions
diff --git a/plugins-scripts/check_mailq.pl b/plugins-scripts/check_mailq.pl
index 32f498d..aac1310 100755
--- a/plugins-scripts/check_mailq.pl
+++ b/plugins-scripts/check_mailq.pl
@@ -568,7 +568,9 @@ sub process_arguments(){
568 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number 568 "w=i" => \$opt_w, "warning=i" => \$opt_w, # warning if above this number
569 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number 569 "c=i" => \$opt_c, "critical=i" => \$opt_c, # critical if above this number
570 "t=i" => \$opt_t, "timeout=i" => \$opt_t, 570 "t=i" => \$opt_t, "timeout=i" => \$opt_t,
571 "s" => \$opt_s, "sudo" => \$opt_s 571 "s" => \$opt_s, "sudo" => \$opt_s,
572 "W=i" => \$opt_W, # warning if above this number
573 "C=i" => \$opt_C, # critical if above this number
572 ); 574 );
573 575
574 if ($opt_V) { 576 if ($opt_V) {
@@ -662,8 +664,8 @@ sub print_help () {
662 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n"; 664 print " Feedback/patches to support non-sendmail mailqueue welcome\n\n";
663 print "-w (--warning) = Min. number of messages in queue to generate warning\n"; 665 print "-w (--warning) = Min. number of messages in queue to generate warning\n";
664 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n"; 666 print "-c (--critical) = Min. number of messages in queue to generate critical alert ( w < c )\n";
665 print "-W (--Warning) = Min. number of messages for same domain in queue to generate warning\n"; 667 print "-W = Min. number of messages for same domain in queue to generate warning\n";
666 print "-C (--Critical) = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n"; 668 print "-C = Min. number of messages for same domain in queue to generate critical alert ( W < C )\n";
667 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n"; 669 print "-t (--timeout) = Plugin timeout in seconds (default = $utils::TIMEOUT)\n";
668 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n"; 670 print "-M (--mailserver) = [ sendmail | qmail | postfix | exim | nullmailer ] (default = autodetect)\n";
669 print "-s (--sudo) = Use sudo to call the mailq command\n"; 671 print "-s (--sudo) = Use sudo to call the mailq command\n";
diff --git a/plugins-scripts/t/check_file_age.t b/plugins-scripts/t/check_file_age.t
index ebf673f..8b87670 100644
--- a/plugins-scripts/t/check_file_age.t
+++ b/plugins-scripts/t/check_file_age.t
@@ -20,105 +20,74 @@ my $temp_link = "/tmp/check_file_age.link.tmp";
20 20
21unlink $temp_file, $temp_link; 21unlink $temp_file, $temp_link;
22 22
23$result = NPTest->testCmd( 23$result = NPTest->testCmd("./check_file_age");
24 "./check_file_age"
25 );
26cmp_ok( $result->return_code, '==', 3, "Missing parameters" ); 24cmp_ok( $result->return_code, '==', 3, "Missing parameters" );
27like ( $result->output, $unknownOutput, "Output for unknown correct" ); 25like ( $result->output, $unknownOutput, "Output for unknown correct" );
28 26
29$result = NPTest->testCmd( 27$result = NPTest->testCmd("./check_file_age -f $temp_file");
30 "./check_file_age -f $temp_file"
31 );
32cmp_ok( $result->return_code, '==', 2, "File not exists" ); 28cmp_ok( $result->return_code, '==', 2, "File not exists" );
33like ( $result->output, $criticalOutput, "Output for file missing correct" ); 29like ( $result->output, $criticalOutput, "Output for file missing correct" );
34 30
35write_chars(100); 31write_chars(100);
36$result = NPTest->testCmd( 32$result = NPTest->testCmd("./check_file_age -f $temp_file");
37 "./check_file_age -f $temp_file"
38 );
39cmp_ok( $result->return_code, '==', 0, "File is new enough" ); 33cmp_ok( $result->return_code, '==', 0, "File is new enough" );
40like ( $result->output, $successOutput, "Output for success correct" ); 34like ( $result->output, $successOutput, "Output for success correct" );
41 35
42sleep 2; 36sleep 2;
43 37
44$result = NPTest->testCmd( 38$result = NPTest->testCmd("./check_file_age -f $temp_file -w 1");
45 "./check_file_age -f $temp_file -w 1"
46 );
47cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" ); 39cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old" );
48like ( $result->output, $warningOutput, "Output for warning correct" ); 40like ( $result->output, $warningOutput, "Output for warning correct" );
49 41
50$result = NPTest->testCmd( 42$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1");
51 "./check_file_age -f $temp_file -w 0:1"
52 );
53cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" );
54like ( $result->output, $warningOutput, "Output for warning by range correct" );
55
56$result = NPTest->testCmd(
57 "./check_file_age -f $temp_file -c 1"
58 );
59cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" ); 43cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old" );
60like ( $result->output, $criticalOutput, "Output for critical correct" ); 44like ( $result->output, $criticalOutput, "Output for critical correct" );
61 45
62$result = NPTest->testCmd( 46$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
63 "./check_file_age -f $temp_file -c 0:1"
64 );
65cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" );
66like ( $result->output, $criticalOutput, "Output for critical by range correct" );
67
68$result = NPTest->testCmd(
69 "./check_file_age -f $temp_file -c 1000 -W 100"
70 );
71cmp_ok( $result->return_code, '==', 0, "Checking file size" ); 47cmp_ok( $result->return_code, '==', 0, "Checking file size" );
72 48
73$result = NPTest->testCmd( 49$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
74 "./check_file_age -f $temp_file -c 0:1000 -W 0:100"
75 );
76cmp_ok( $result->return_code, '==', 0, "Checking file size by range" );
77
78$result = NPTest->testCmd(
79 "./check_file_age -f $temp_file -c 1000 -W 100"
80 );
81like( $result->output, $performanceOutput, "Checking for performance Output" ); 50like( $result->output, $performanceOutput, "Checking for performance Output" );
82 51
83$result = NPTest->testCmd( 52$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 100");
84 "./check_file_age -f $temp_file -c 1000 -W 100"
85 );
86like( $result->output, $performanceOutput, "Checking for performance Output from range" ); 53like( $result->output, $performanceOutput, "Checking for performance Output from range" );
87 54
88$result = NPTest->testCmd( 55$result = NPTest->testCmd("./check_file_age -f /non/existent --ignore-missing");
89 "./check_file_age -f /non/existent --ignore-missing"
90 );
91cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" ); 56cmp_ok( $result->return_code, '==', 0, "Honours --ignore-missing" );
92 57
93$result = NPTest->testCmd( 58$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101");
94 "./check_file_age -f $temp_file -c 1000 -W 101"
95 );
96cmp_ok( $result->return_code, '==', 1, "One byte too short" ); 59cmp_ok( $result->return_code, '==', 1, "One byte too short" );
97 60
98$result = NPTest->testCmd( 61$result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101");
99 "./check_file_age -f $temp_file -c 1000 -W 101:"
100 );
101cmp_ok( $result->return_code, '==', 1, "One byte too short by range" );
102
103$result = NPTest->testCmd(
104 "./check_file_age -f $temp_file -c 1000 -C 101"
105 );
106cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" ); 62cmp_ok( $result->return_code, '==', 2, "One byte too short - critical" );
107 63
108$result = NPTest->testCmd( 64SKIP: {
109 "./check_file_age -f $temp_file -c 1000 -C 101:" 65 eval 'use Monitoring::Plugin::Range';
110 ); 66 skip "Monitoring::Plugin::Range module require", 9 if $@;
111cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" ); 67
68 $result = NPTest->testCmd("./check_file_age -f $temp_file -w 0:1");
69 cmp_ok( $result->return_code, '==', 1, "Warning for file over 1 second old by range" );
70 like ( $result->output, $warningOutput, "Output for warning by range correct" );
71
72 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1");
73 cmp_ok( $result->return_code, '==', 2, "Critical for file over 1 second old by range" );
74 like ( $result->output, $criticalOutput, "Output for critical by range correct" );
75
76 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 0:1000 -W 0:100");
77 cmp_ok( $result->return_code, '==', 0, "Checking file size by range" );
78
79 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 101:");
80 cmp_ok( $result->return_code, '==', 1, "One byte too short by range" );
81
82 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -W 0:99");
83 cmp_ok( $result->return_code, '==', 1, "One byte too long by range" );
112 84
113$result = NPTest->testCmd( 85 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 101:");
114 "./check_file_age -f $temp_file -c 1000 -W 0:99" 86 cmp_ok( $result->return_code, '==', 2, "One byte too short by range - critical" );
115 );
116cmp_ok( $result->return_code, '==', 1, "One byte too long by range" );
117 87
118$result = NPTest->testCmd( 88 $result = NPTest->testCmd("./check_file_age -f $temp_file -c 1000 -C 0:99");
119 "./check_file_age -f $temp_file -c 1000 -C 0:99" 89 cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" );
120 ); 90};
121cmp_ok( $result->return_code, '==', 2, "One byte too long by range - critical" );
122 91
123symlink $temp_file, $temp_link or die "Cannot create symlink"; 92symlink $temp_file, $temp_link or die "Cannot create symlink";
124$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10"); 93$result = NPTest->testCmd("./check_file_age -f $temp_link -c 10");