summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_by_ssh.c18
-rw-r--r--plugins/check_snmp.c2
-rw-r--r--plugins/check_swap.c24
-rw-r--r--plugins/t/check_curl.t7
-rw-r--r--plugins/t/check_http.t8
5 files changed, 31 insertions, 28 deletions
diff --git a/plugins/check_by_ssh.c b/plugins/check_by_ssh.c
index 39d49070..1ad547ed 100644
--- a/plugins/check_by_ssh.c
+++ b/plugins/check_by_ssh.c
@@ -50,6 +50,7 @@ unsigned int services = 0;
50int skip_stdout = 0; 50int skip_stdout = 0;
51int skip_stderr = 0; 51int skip_stderr = 0;
52int warn_on_stderr = 0; 52int warn_on_stderr = 0;
53bool unknown_timeout = FALSE;
53char *remotecmd = NULL; 54char *remotecmd = NULL;
54char **commargv = NULL; 55char **commargv = NULL;
55int commargc = 0; 56int commargc = 0;
@@ -101,6 +102,13 @@ main (int argc, char **argv)
101 102
102 result = cmd_run_array (commargv, &chld_out, &chld_err, 0); 103 result = cmd_run_array (commargv, &chld_out, &chld_err, 0);
103 104
105 /* SSH returns 255 if connection attempt fails; include the first line of error output */
106 if (result == 255 && unknown_timeout) {
107 printf (_("SSH connection failed: %s\n"),
108 chld_err.lines > 0 ? chld_err.line[0] : "(no error output)");
109 return STATE_UNKNOWN;
110 }
111
104 if (verbose) { 112 if (verbose) {
105 for(i = 0; i < chld_out.lines; i++) 113 for(i = 0; i < chld_out.lines; i++)
106 printf("stdout: %s\n", chld_out.line[i]); 114 printf("stdout: %s\n", chld_out.line[i]);
@@ -180,6 +188,7 @@ process_arguments (int argc, char **argv)
180 {"verbose", no_argument, 0, 'v'}, 188 {"verbose", no_argument, 0, 'v'},
181 {"fork", no_argument, 0, 'f'}, 189 {"fork", no_argument, 0, 'f'},
182 {"timeout", required_argument, 0, 't'}, 190 {"timeout", required_argument, 0, 't'},
191 {"unknown-timeout", no_argument, 0, 'U'},
183 {"host", required_argument, 0, 'H'}, /* backward compatibility */ 192 {"host", required_argument, 0, 'H'}, /* backward compatibility */
184 {"hostname", required_argument, 0, 'H'}, 193 {"hostname", required_argument, 0, 'H'},
185 {"port", required_argument,0,'p'}, 194 {"port", required_argument,0,'p'},
@@ -212,7 +221,7 @@ process_arguments (int argc, char **argv)
212 strcpy (argv[c], "-t"); 221 strcpy (argv[c], "-t");
213 222
214 while (1) { 223 while (1) {
215 c = getopt_long (argc, argv, "Vvh1246fqt:H:O:p:i:u:l:C:S::E::n:s:o:F:", longopts, 224 c = getopt_long (argc, argv, "Vvh1246fqt:UH:O:p:i:u:l:C:S::E::n:s:o:F:", longopts,
216 &option); 225 &option);
217 226
218 if (c == -1 || c == EOF) 227 if (c == -1 || c == EOF)
@@ -234,6 +243,9 @@ process_arguments (int argc, char **argv)
234 else 243 else
235 timeout_interval = atoi (optarg); 244 timeout_interval = atoi (optarg);
236 break; 245 break;
246 case 'U':
247 unknown_timeout = TRUE;
248 break;
237 case 'H': /* host */ 249 case 'H': /* host */
238 hostname = optarg; 250 hostname = optarg;
239 break; 251 break;
@@ -445,6 +457,8 @@ print_help (void)
445 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]")); 457 printf (" %s\n", _("Tell ssh to suppress warning and diagnostic messages [optional]"));
446 printf (UT_WARN_CRIT); 458 printf (UT_WARN_CRIT);
447 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT); 459 printf (UT_CONN_TIMEOUT, DEFAULT_SOCKET_TIMEOUT);
460 printf (" %s\n","-U, --unknown-timeout");
461 printf (" %s\n", _("Make connection problems return UNKNOWN instead of CRITICAL"));
448 printf (UT_VERBOSE); 462 printf (UT_VERBOSE);
449 printf("\n"); 463 printf("\n");
450 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with")); 464 printf (" %s\n", _("The most common mode of use is to refer to a local identity file with"));
@@ -474,7 +488,7 @@ void
474print_usage (void) 488print_usage (void)
475{ 489{
476 printf ("%s\n", _("Usage:")); 490 printf ("%s\n", _("Usage:"));
477 printf (" %s -H <host> -C <command> [-fqv] [-1|-2] [-4|-6]\n" 491 printf (" %s -H <host> -C <command> [-fqvU] [-1|-2] [-4|-6]\n"
478 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n" 492 " [-S [lines]] [-E [lines]] [-W] [-t timeout] [-i identity]\n"
479 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n" 493 " [-l user] [-n name] [-s servicelist] [-O outputfile]\n"
480 " [-p port] [-o ssh-option] [-F configfile]\n", 494 " [-p port] [-o ssh-option] [-F configfile]\n",
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index bd13e579..2601ccd8 100644
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
@@ -376,7 +376,7 @@ main (int argc, char **argv)
376 } 376 }
377 } 377 }
378 378
379 for (line=0, i=0; line < chld_out.lines; line++, i++) { 379 for (line=0, i=0; line < chld_out.lines && i < numoids ; line++, i++) {
380 if(calculate_rate) 380 if(calculate_rate)
381 conv = "%.10g"; 381 conv = "%.10g";
382 else 382 else
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index bb854beb..ff58b15f 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -1,30 +1,30 @@
1/***************************************************************************** 1/*****************************************************************************
2* 2*
3* Monitoring check_swap plugin 3* Monitoring check_swap plugin
4* 4*
5* License: GPL 5* License: GPL
6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net) 6* Copyright (c) 2000 Karl DeBisschop (kdebisschop@users.sourceforge.net)
7* Copyright (c) 2000-2007 Monitoring Plugins Development Team 7* Copyright (c) 2000-2007 Monitoring Plugins Development Team
8* 8*
9* Description: 9* Description:
10* 10*
11* This file contains the check_swap plugin 11* This file contains the check_swap plugin
12* 12*
13* 13*
14* This program is free software: you can redistribute it and/or modify 14* This program is free software: you can redistribute it and/or modify
15* it under the terms of the GNU General Public License as published by 15* it under the terms of the GNU General Public License as published by
16* the Free Software Foundation, either version 3 of the License, or 16* the Free Software Foundation, either version 3 of the License, or
17* (at your option) any later version. 17* (at your option) any later version.
18* 18*
19* This program is distributed in the hope that it will be useful, 19* This program is distributed in the hope that it will be useful,
20* but WITHOUT ANY WARRANTY; without even the implied warranty of 20* but WITHOUT ANY WARRANTY; without even the implied warranty of
21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22* GNU General Public License for more details. 22* GNU General Public License for more details.
23* 23*
24* You should have received a copy of the GNU General Public License 24* You should have received a copy of the GNU General Public License
25* along with this program. If not, see <http://www.gnu.org/licenses/>. 25* along with this program. If not, see <http://www.gnu.org/licenses/>.
26* 26*
27* 27*
28*****************************************************************************/ 28*****************************************************************************/
29 29
30const char *progname = "check_swap"; 30const char *progname = "check_swap";
@@ -150,7 +150,7 @@ main (int argc, char **argv)
150 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123" 150 * The following sscanf call looks for lines looking like: "SwapTotal: 123" and "SwapFree: 123"
151 * This format exists at least on Debian Linux with a 5.* kernel 151 * This format exists at least on Debian Linux with a 5.* kernel
152 */ 152 */
153 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %f %*[k]%*[B]", str, &tmp_KB)) { 153 else if (sscanf (input_buffer, "%*[S]%*[w]%*[a]%*[p]%[TotalFreCchd]%*[:] %lu %*[k]%*[B]", str, &tmp_KB)) {
154 if (verbose >= 3) { 154 if (verbose >= 3) {
155 printf("Got %s with %lu\n", str, tmp_KB); 155 printf("Got %s with %lu\n", str, tmp_KB);
156 } 156 }
@@ -389,7 +389,7 @@ main (int argc, char **argv)
389 TRUE, warn_print, 389 TRUE, warn_print,
390 TRUE, crit_print, 390 TRUE, crit_print,
391 TRUE, 0, 391 TRUE, 0,
392 TRUE, (long) total_swap_mb)); 392 TRUE, (long) total_swap_mb * 1024 * 1024));
393 393
394 return result; 394 return result;
395} 395}
diff --git a/plugins/t/check_curl.t b/plugins/t/check_curl.t
index ada6a045..693f4b25 100644
--- a/plugins/t/check_curl.t
+++ b/plugins/t/check_curl.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 58; 12plan tests => 57;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
@@ -188,11 +188,6 @@ SKIP: {
188 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 188 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
189 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 189 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
190 190
191 $res = NPTest->testCmd(
192 "./$plugin --ssl -H www.e-paycobalt.com"
193 );
194 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
195
196 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" ); 191 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f curl" );
197 is( $res->return_code, 0, "Redirection based on location is okay"); 192 is( $res->return_code, 0, "Redirection based on location is okay");
198 193
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index c137f7b4..0c866229 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -9,7 +9,7 @@ use Test::More;
9use POSIX qw/mktime strftime/; 9use POSIX qw/mktime strftime/;
10use NPTest; 10use NPTest;
11 11
12plan tests => 50; 12plan tests => 49;
13 13
14my $successOutput = '/OK.*HTTP.*second/'; 14my $successOutput = '/OK.*HTTP.*second/';
15 15
@@ -166,12 +166,6 @@ SKIP: {
166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' ); 166 like ( $res->output, '/time_connect=[\d\.]+/', 'Extended Performance Data Output OK' );
167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' ); 167 like ( $res->output, '/time_ssl=[\d\.]+/', 'Extended Performance Data SSL Output OK' );
168 168
169 $res = NPTest->testCmd(
170 "./$plugin --ssl -H www.e-paycobalt.com"
171 );
172 cmp_ok( $res->return_code, "==", 0, "Can read https for www.e-paycobalt.com (uses AES certificate)" );
173
174
175 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" ); 169 $res = NPTest->testCmd( "./$plugin -H www.mozilla.com -u /firefox -f follow" );
176 is( $res->return_code, 0, "Redirection based on location is okay"); 170 is( $res->return_code, 0, "Redirection based on location is okay");
177 171