summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--NEWS1
-rw-r--r--THANKS.in2
-rw-r--r--plugins/check_apt.c10
-rw-r--r--plugins/check_http.c4
-rw-r--r--plugins/check_nt.c16
-rw-r--r--plugins/check_ntp_peer.c32
-rw-r--r--plugins/check_smtp.c26
-rw-r--r--plugins/t/check_http.t11
9 files changed, 58 insertions, 45 deletions
diff --git a/.gitignore b/.gitignore
index bda7b27..4dca502 100644
--- a/.gitignore
+++ b/.gitignore
@@ -191,6 +191,7 @@ NP-VERSION-FILE
191/plugins/.libs 191/plugins/.libs
192/plugins/Makefile 192/plugins/Makefile
193/plugins/Makefile.in 193/plugins/Makefile.in
194/plugins/libnpcommon.a
194/plugins/negate 195/plugins/negate
195/plugins/stamp-h* 196/plugins/stamp-h*
196/plugins/urlize 197/plugins/urlize
diff --git a/NEWS b/NEWS
index 3285b3d..70c6353 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,7 @@ This file documents the major additions and syntax changes between releases.
4 ENHANCEMENTS 4 ENHANCEMENTS
5 New check_dbi plugin for checking an (SQL) database using DBI 5 New check_dbi plugin for checking an (SQL) database using DBI
6 Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page) 6 Let OpenSSL load its configuration file (see the OPENSSL_config(3) man page)
7 Add performance data to check_apt
7 Add performance data to check_procs 8 Add performance data to check_procs
8 Added -4/-6 options to check_dig (Ville Mattila) 9 Added -4/-6 options to check_dig (Ville Mattila)
9 New check_oracle --connect option to perform real login 10 New check_oracle --connect option to perform real login
diff --git a/THANKS.in b/THANKS.in
index fdebd65..9fdd882 100644
--- a/THANKS.in
+++ b/THANKS.in
@@ -280,3 +280,5 @@ Alex Bradley
280Brian De Wolf 280Brian De Wolf
281Richard Leitner 281Richard Leitner
282Diego Elio Pettenò 282Diego Elio Pettenò
283Vaclav Ovsik
284Roman Fiedler
diff --git a/plugins/check_apt.c b/plugins/check_apt.c
index 7ec2d55..daeb757 100644
--- a/plugins/check_apt.c
+++ b/plugins/check_apt.c
@@ -112,11 +112,11 @@ int main (int argc, char **argv) {
112 result = max_state(result, STATE_CRITICAL); 112 result = max_state(result, STATE_CRITICAL);
113 } else if(packages_available > 0){ 113 } else if(packages_available > 0){
114 result = max_state(result, STATE_WARNING); 114 result = max_state(result, STATE_WARNING);
115 } else { 115 } else if(result > STATE_UNKNOWN){
116 result = max_state(result, STATE_OK); 116 result = STATE_UNKNOWN;
117 } 117 }
118 118
119 printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s\n"), 119 printf(_("APT %s: %d packages available for %s (%d critical updates). %s%s%s%s|available_upgrades=%d;;;0 critical_updates=%d;;;0\n"),
120 state_text(result), 120 state_text(result),
121 packages_available, 121 packages_available,
122 (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade", 122 (upgrade==DIST_UPGRADE)?"dist-upgrade":"upgrade",
@@ -124,7 +124,9 @@ int main (int argc, char **argv) {
124 (stderr_warning)?" warnings detected":"", 124 (stderr_warning)?" warnings detected":"",
125 (stderr_warning && exec_warning)?",":"", 125 (stderr_warning && exec_warning)?",":"",
126 (exec_warning)?" errors detected":"", 126 (exec_warning)?" errors detected":"",
127 (stderr_warning||exec_warning)?". run with -v for information.":"" 127 (stderr_warning||exec_warning)?". run with -v for information.":"",
128 packages_available,
129 sec_count
128 ); 130 );
129 131
130 return result; 132 return result;
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 9231a55..110875d 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -43,7 +43,6 @@ const char *email = "nagiosplug-devel@lists.sourceforge.net";
43#include "base64.h" 43#include "base64.h"
44#include <ctype.h> 44#include <ctype.h>
45 45
46#define INPUT_DELIMITER ";"
47#define STICKY_NONE 0 46#define STICKY_NONE 0
48#define STICKY_HOST 1 47#define STICKY_HOST 1
49#define STICKY_PORT 2 48#define STICKY_PORT 2
@@ -854,8 +853,7 @@ check_http (void)
854 /* optionally send any other header tag */ 853 /* optionally send any other header tag */
855 if (http_opt_headers_count) { 854 if (http_opt_headers_count) {
856 for (i = 0; i < http_opt_headers_count ; i++) { 855 for (i = 0; i < http_opt_headers_count ; i++) {
857 for ((pos = strtok(http_opt_headers[i], INPUT_DELIMITER)); pos; (pos = strtok(NULL, INPUT_DELIMITER))) 856 xasprintf (&buf, "%s%s\r\n", buf, http_opt_headers[i]);
858 xasprintf (&buf, "%s%s\r\n", buf, pos);
859 } 857 }
860 /* This cannot be free'd here because a redirection will then try to access this and segfault */ 858 /* This cannot be free'd here because a redirection will then try to access this and segfault */
861 /* Covered in a testcase in tests/check_http.t */ 859 /* Covered in a testcase in tests/check_http.t */
diff --git a/plugins/check_nt.c b/plugins/check_nt.c
index 89c4d8d..52bbd1c 100644
--- a/plugins/check_nt.c
+++ b/plugins/check_nt.c
@@ -94,6 +94,7 @@ int main(int argc, char **argv){
94 char *description=NULL,*counter_unit = NULL; 94 char *description=NULL,*counter_unit = NULL;
95 char *minval = NULL, *maxval = NULL, *errcvt = NULL; 95 char *minval = NULL, *maxval = NULL, *errcvt = NULL;
96 char *fds=NULL, *tds=NULL; 96 char *fds=NULL, *tds=NULL;
97 char *numstr;
97 98
98 double total_disk_space=0; 99 double total_disk_space=0;
99 double free_disk_space=0; 100 double free_disk_space=0;
@@ -265,7 +266,10 @@ int main(int argc, char **argv){
265 xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6, 266 xasprintf(&send_buffer,"%s&%u&%s&%s", req_password,(vars_to_check==CHECK_SERVICESTATE)?5:6,
266 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list); 267 (show_all==TRUE) ? "ShowAll" : "ShowFail",value_list);
267 fetch_data (server_address, server_port, send_buffer); 268 fetch_data (server_address, server_port, send_buffer);
268 return_code=atoi(strtok(recv_buffer,"&")); 269 numstr = strtok(recv_buffer,"&");
270 if (numstr == NULL)
271 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
272 return_code=atoi(numstr);
269 temp_string=strtok(NULL,"&"); 273 temp_string=strtok(NULL,"&");
270 output_message = strdup (temp_string); 274 output_message = strdup (temp_string);
271 } 275 }
@@ -275,8 +279,14 @@ int main(int argc, char **argv){
275 279
276 xasprintf(&send_buffer,"%s&7", req_password); 280 xasprintf(&send_buffer,"%s&7", req_password);
277 fetch_data (server_address, server_port, send_buffer); 281 fetch_data (server_address, server_port, send_buffer);
278 mem_commitLimit=atof(strtok(recv_buffer,"&")); 282 numstr = strtok(recv_buffer,"&");
279 mem_commitByte=atof(strtok(NULL,"&")); 283 if (numstr == NULL)
284 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
285 mem_commitLimit=atof(numstr);
286 numstr = strtok(NULL,"&");
287 if (numstr == NULL)
288 die(STATE_UNKNOWN, _("could not fetch information from server\n"));
289 mem_commitByte=atof(numstr);
280 percent_used_space = (mem_commitByte / mem_commitLimit) * 100; 290 percent_used_space = (mem_commitByte / mem_commitLimit) * 100;
281 warning_used_space = ((float)warning_value / 100) * mem_commitLimit; 291 warning_used_space = ((float)warning_value / 100) * mem_commitLimit;
282 critical_used_space = ((float)critical_value / 100) * mem_commitLimit; 292 critical_used_space = ((float)critical_value / 100) * mem_commitLimit;
diff --git a/plugins/check_ntp_peer.c b/plugins/check_ntp_peer.c
index b59c056..76152e1 100644
--- a/plugins/check_ntp_peer.c
+++ b/plugins/check_ntp_peer.c
@@ -241,15 +241,19 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
241 DBG(printf("sending READSTAT request")); 241 DBG(printf("sending READSTAT request"));
242 write(conn, &req, SIZEOF_NTPCM(req)); 242 write(conn, &req, SIZEOF_NTPCM(req));
243 DBG(print_ntp_control_message(&req)); 243 DBG(print_ntp_control_message(&req));
244 /* Attempt to read the largest size packet possible */ 244
245 req.count=htons(MAX_CM_SIZE); 245 do {
246 DBG(printf("recieving READSTAT response")) 246 /* Attempt to read the largest size packet possible */
247 if(read(conn, &req, SIZEOF_NTPCM(req)) == -1) 247 req.count=htons(MAX_CM_SIZE);
248 die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n"); 248 DBG(printf("recieving READSTAT response"))
249 DBG(print_ntp_control_message(&req)); 249 if(read(conn, &req, SIZEOF_NTPCM(req)) == -1)
250 /* discard obviously invalid packets */ 250 die(STATE_CRITICAL, "NTP CRITICAL: No response from NTP server\n");
251 if (ntohs(req.count) > MAX_CM_SIZE) 251 DBG(print_ntp_control_message(&req));
252 die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n"); 252 /* discard obviously invalid packets */
253 if (ntohs(req.count) > MAX_CM_SIZE)
254 die(STATE_CRITICAL, "NTP CRITICAL: Invalid packet received from NTP server\n");
255 } while (!(req.op&OP_READSTAT && ntohs(req.seq) == 1));
256
253 if (LI(req.flags) == LI_ALARM) li_alarm = 1; 257 if (LI(req.flags) == LI_ALARM) li_alarm = 1;
254 /* Each peer identifier is 4 bytes in the data section, which 258 /* Each peer identifier is 4 bytes in the data section, which
255 * we represent as a ntp_assoc_status_pair datatype. 259 * we represent as a ntp_assoc_status_pair datatype.
@@ -312,10 +316,12 @@ int ntp_request(const char *host, double *offset, int *offset_result, double *ji
312 write(conn, &req, SIZEOF_NTPCM(req)); 316 write(conn, &req, SIZEOF_NTPCM(req));
313 DBG(print_ntp_control_message(&req)); 317 DBG(print_ntp_control_message(&req));
314 318
315 req.count = htons(MAX_CM_SIZE); 319 do {
316 DBG(printf("receiving READVAR response...\n")); 320 req.count = htons(MAX_CM_SIZE);
317 read(conn, &req, SIZEOF_NTPCM(req)); 321 DBG(printf("receiving READVAR response...\n"));
318 DBG(print_ntp_control_message(&req)); 322 read(conn, &req, SIZEOF_NTPCM(req));
323 DBG(print_ntp_control_message(&req));
324 } while (!(req.op&OP_READVAR && ntohs(req.seq) == 2));
319 325
320 if(!(req.op&REM_ERROR)) 326 if(!(req.op&REM_ERROR))
321 xasprintf(&data, "%s%s", data, req.data); 327 xasprintf(&data, "%s%s", data, req.data);
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index 79fa482..d477a51 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -99,9 +99,9 @@ char **responses = NULL;
99char *authtype = NULL; 99char *authtype = NULL;
100char *authuser = NULL; 100char *authuser = NULL;
101char *authpass = NULL; 101char *authpass = NULL;
102int warning_time = 0; 102double warning_time = 0;
103int check_warning_time = FALSE; 103int check_warning_time = FALSE;
104int critical_time = 0; 104double critical_time = 0;
105int check_critical_time = FALSE; 105int check_critical_time = FALSE;
106int verbose = 0; 106int verbose = 0;
107int use_ssl = FALSE; 107int use_ssl = FALSE;
@@ -417,9 +417,9 @@ main (int argc, char **argv)
417 elapsed_time = (double)microsec / 1.0e6; 417 elapsed_time = (double)microsec / 1.0e6;
418 418
419 if (result == STATE_OK) { 419 if (result == STATE_OK) {
420 if (check_critical_time && elapsed_time > (double) critical_time) 420 if (check_critical_time && elapsed_time > critical_time)
421 result = STATE_CRITICAL; 421 result = STATE_CRITICAL;
422 else if (check_warning_time && elapsed_time > (double) warning_time) 422 else if (check_warning_time && elapsed_time > warning_time)
423 result = STATE_WARNING; 423 result = STATE_WARNING;
424 } 424 }
425 425
@@ -552,21 +552,19 @@ process_arguments (int argc, char **argv)
552 nresponses++; 552 nresponses++;
553 break; 553 break;
554 case 'c': /* critical time threshold */ 554 case 'c': /* critical time threshold */
555 if (is_intnonneg (optarg)) { 555 if (!is_nonnegative (optarg))
556 critical_time = atoi (optarg); 556 usage4 (_("Critical time must be a positive"));
557 check_critical_time = TRUE;
558 }
559 else { 557 else {
560 usage4 (_("Critical time must be a positive integer")); 558 critical_time = strtod (optarg, NULL);
559 check_critical_time = TRUE;
561 } 560 }
562 break; 561 break;
563 case 'w': /* warning time threshold */ 562 case 'w': /* warning time threshold */
564 if (is_intnonneg (optarg)) { 563 if (!is_nonnegative (optarg))
565 warning_time = atoi (optarg); 564 usage4 (_("Warning time must be a positive"));
566 check_warning_time = TRUE;
567 }
568 else { 565 else {
569 usage4 (_("Warning time must be a positive integer")); 566 warning_time = strtod (optarg, NULL);
567 check_warning_time = TRUE;
570 } 568 }
571 break; 569 break;
572 case 'v': /* verbose */ 570 case 'v': /* verbose */
diff --git a/plugins/t/check_http.t b/plugins/t/check_http.t
index 0a25c77..6299791 100644
--- a/plugins/t/check_http.t
+++ b/plugins/t/check_http.t
@@ -8,7 +8,7 @@ use strict;
8use Test::More; 8use Test::More;
9use NPTest; 9use NPTest;
10 10
11plan tests => 28; 11plan tests => 27;
12 12
13my $successOutput = '/OK.*HTTP.*second/'; 13my $successOutput = '/OK.*HTTP.*second/';
14 14
@@ -45,14 +45,9 @@ cmp_ok( $res->return_code, '==', 0, "Webserver $host_tcp_http responded" );
45like( $res->output, $successOutput, "Output OK" ); 45like( $res->output, $successOutput, "Output OK" );
46 46
47$res = NPTest->testCmd( 47$res = NPTest->testCmd(
48 "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there;fred:here'" 48 "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there' -k 'carl:frown'"
49 ); 49 );
50like( $res->output, '/bob:there\r\nfred:here\r\n/', "Got headers, delimited with ';'" ); 50like( $res->output, '/bob:there\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
51
52$res = NPTest->testCmd(
53 "./check_http $host_tcp_http -wt 300 -ct 600 -v -v -v -k 'bob:there;fred:here' -k 'carl:frown'"
54 );
55like( $res->output, '/bob:there\r\nfred:here\r\ncarl:frown\r\n/', "Got headers with multiple -k options" );
56 51
57$res = NPTest->testCmd( 52$res = NPTest->testCmd(
58 "./check_http $host_nonresponsive -wt 1 -ct 2" 53 "./check_http $host_nonresponsive -wt 1 -ct 2"