Przeglądaj źródła

fix patch 998291
fix patch 1078934 expect check_ssh fix and check_nt perfdata should stay
on one word like in nagios


git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1004 f882894a-f735-0410-b71e-b25c423dba1c

Benoit Mortier 21 lat temu
rodzic
commit
2ab4d8fc27

+ 8 - 8
plugins/check_http.c

@@ -676,17 +676,17 @@ check_document_dates (const char *headers)
 	} else if (!document_date || !*document_date) {
 	} else if (!document_date || !*document_date) {
 		die (STATE_CRITICAL, _("Document modification date unknown\n"));
 		die (STATE_CRITICAL, _("Document modification date unknown\n"));
 	} else {
 	} else {
-		time_t sd = parse_time_string (server_date);
-		time_t dd = parse_time_string (document_date);
+		time_t srv_data = parse_time_string (server_date);
+		time_t doc_data = parse_time_string (document_date);
 
 
-		if (sd <= 0) {
+		if (srv_data <= 0) {
 			die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date);
 			die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date);
-		} else if (dd <= 0) {
+		} else if (doc_data <= 0) {
 			die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date);
 			die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date);
-		} else if (dd > sd + 30) {
-			die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), dd - sd);
-		} else if (dd < sd - maximum_age) {
-		int n = (sd - dd);
+		} else if (doc_data > srv_data + 30) {
+			die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), (int)doc_data - (int)srv_data);
+		} else if (doc_data < srv_data - maximum_age) {
+		int n = (srv_data - doc_data);
 		if (n > (60 * 60 * 24 * 2))
 		if (n > (60 * 60 * 24 * 2))
 			die (STATE_CRITICAL,
 			die (STATE_CRITICAL,
 			  _("CRITICAL - Last modified %.1f days ago\n"),
 			  _("CRITICAL - Last modified %.1f days ago\n"),

+ 9 - 14
plugins/check_icmp.c

@@ -1,6 +1,8 @@
 /*
 /*
- * check_icmp - A hack of fping2 to work with nagios.
- *              This way we don't have to use the output parser.
+ * $Id$
+ *
+ * This is a hack of fping2 made to work with nagios.
+ * It's fast and removes the necessity of parsing another programs output.
  *
  *
  * VIEWING NOTES:
  * VIEWING NOTES:
  * This file was formatted with tab indents at a tab stop of 4.
  * This file was formatted with tab indents at a tab stop of 4.
@@ -40,14 +42,8 @@
 #include <netinet/in_systm.h>
 #include <netinet/in_systm.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
 
 
-/* Linux has bizarre ip.h and ip_icmp.h */
-/* Taken from the fping distro. Thank you. */
-#if defined( __linux__ )
-#include "linux.h"
-#else
 #include <netinet/ip.h>
 #include <netinet/ip.h>
 #include <netinet/ip_icmp.h>
 #include <netinet/ip_icmp.h>
-#endif /* defined(__linux__) */
 
 
 #include <arpa/inet.h>
 #include <arpa/inet.h>
 #include <netdb.h>
 #include <netdb.h>
@@ -70,9 +66,8 @@ extern char *optarg;
 extern int optind, opterr;
 extern int optind, opterr;
 
 
 /*** Constants ***/
 /*** Constants ***/
-#define REV_DATE	"2004-09-06"
 #define EMAIL		"ae@op5.se"
 #define EMAIL		"ae@op5.se"
-#define VERSION		"0.8"
+#define VERSION		"0.8.1"
 
 
 #ifndef INADDR_NONE
 #ifndef INADDR_NONE
 # define INADDR_NONE 0xffffffU
 # define INADDR_NONE 0xffffffU
@@ -441,7 +436,7 @@ int main(int argc, char **argv)
 				break;
 				break;
 
 
 			case 'v':
 			case 'v':
-				printf("%s: Version %s $Date$\n", prog, VERSION, REV_DATE);
+				printf("%s: Version %s $Date$\n", prog, VERSION);
 				printf("%s: comments to %s\n", prog, EMAIL);
 				printf("%s: comments to %s\n", prog, EMAIL);
 				exit(STATE_OK);
 				exit(STATE_OK);
 
 
@@ -1275,7 +1270,7 @@ void u_sleep(int u_sec)
  * crash on any other errrors
  * crash on any other errrors
  ************************************************************/
  ************************************************************/
 /* TODO: add MSG_DONTWAIT to recvfrom flags (currently 0) */
 /* TODO: add MSG_DONTWAIT to recvfrom flags (currently 0) */
-int recvfrom_wto(int sock, char *buf, int len, struct sockaddr *saddr, int timo)
+int recvfrom_wto(int lsock, char *buf, int len, struct sockaddr *saddr, int timo)
 {
 {
 	int nfound = 0, slen, n;
 	int nfound = 0, slen, n;
 	struct timeval to;
 	struct timeval to;
@@ -1289,8 +1284,8 @@ int recvfrom_wto(int sock, char *buf, int len, struct sockaddr *saddr, int timo)
 
 
 	FD_ZERO(&readset);
 	FD_ZERO(&readset);
 	FD_ZERO(&writeset);
 	FD_ZERO(&writeset);
-	FD_SET(sock, &readset);
-	nfound = select(sock + 1, &readset, &writeset, NULL, &to);
+	FD_SET(lsock, &readset);
+	nfound = select(lsock + 1, &readset, &writeset, NULL, &to);
 	if(nfound < 0) crash("select() in recvfrom_wto");
 	if(nfound < 0) crash("select() in recvfrom_wto");
 
 
 	if(nfound == 0) return -1;				/* timeout */
 	if(nfound == 0) return -1;				/* timeout */

+ 1 - 2
plugins/check_nwstat.c

@@ -909,8 +909,7 @@ void print_help(void)
 
 
 	printf (_("\
 	printf (_("\
 This plugin attempts to contact the MRTGEXT NLM running on a\n\
 This plugin attempts to contact the MRTGEXT NLM running on a\n\
-Novell server to gather the requested system information.\n\n"),
-	        progname);
+Novell server to gather the requested system information.\n\n"));
 
 
 	print_usage();
 	print_usage();
 
 

+ 2 - 0
plugins/check_ping.c

@@ -469,6 +469,8 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
 		die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)"), addr);
 		die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)"), addr);
 	else if (strstr (buf, "unknown host" ))
 	else if (strstr (buf, "unknown host" ))
 		die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)"), addr);
 		die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)"), addr);
+	else if (strstr (buf, "Time to live exceeded"))
+		die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)"), addr);
 
 
 	if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
 	if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
 		if (warn_text == NULL)
 		if (warn_text == NULL)

+ 2 - 1
plugins/check_smtp.c

@@ -218,11 +218,12 @@ main (int argc, char **argv)
 	microsec = deltime (tv);
 	microsec = deltime (tv);
 	elapsed_time = (double)microsec / 1.0e6;
 	elapsed_time = (double)microsec / 1.0e6;
 
 
-	if (result == STATE_OK)
+	if (result == STATE_OK) {
 		if (check_critical_time && elapsed_time > (double) critical_time)
 		if (check_critical_time && elapsed_time > (double) critical_time)
 			result = STATE_CRITICAL;
 			result = STATE_CRITICAL;
 		else if (check_warning_time && elapsed_time > (double) warning_time)
 		else if (check_warning_time && elapsed_time > (double) warning_time)
 			result = STATE_WARNING;
 			result = STATE_WARNING;
+	}
 
 
 	printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"),
 	printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"),
 	        state_text (result), elapsed_time,
 	        state_text (result), elapsed_time,

+ 1 - 1
plugins/check_swap.c

@@ -56,10 +56,10 @@ main (int argc, char **argv)
 	int result = STATE_UNKNOWN;
 	int result = STATE_UNKNOWN;
 	char input_buffer[MAX_INPUT_BUFFER];
 	char input_buffer[MAX_INPUT_BUFFER];
 	char *perf;
 	char *perf;
-	int conv_factor = SWAP_CONVERSION;
 #ifdef HAVE_PROC_MEMINFO
 #ifdef HAVE_PROC_MEMINFO
 	FILE *fp;
 	FILE *fp;
 #else
 #else
+	int conv_factor = SWAP_CONVERSION;
 # ifdef HAVE_SWAP
 # ifdef HAVE_SWAP
 	char *temp_buffer;
 	char *temp_buffer;
 	char *swap_command;
 	char *swap_command;

+ 36 - 35
plugins/utils.h

@@ -16,9 +16,9 @@ suite of plugins. */
 /* $Id$ */
 /* $Id$ */
 
 
 void support (void);
 void support (void);
-char *clean_revstring (const char *revstring);
+char *clean_revstring (const char *);
 void print_revision (const char *, const char *);
 void print_revision (const char *, const char *);
-void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3)));
+void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
 
 
 /* Handle timeouts */
 /* Handle timeouts */
 
 
@@ -57,7 +57,7 @@ struct timeval {
 #endif
 #endif
 
 
 #ifndef HAVE_GETTIMEOFDAY
 #ifndef HAVE_GETTIMEOFDAY
-int gettimeofday(struct timeval *tv, struct timezone *tz);
+int gettimeofday(struct timeval *, struct timezone *);
 #endif
 #endif
 
 
 double delta_time (struct timeval tv);
 double delta_time (struct timeval tv);
@@ -65,46 +65,47 @@ long deltime (struct timeval tv);
 
 
 /* Handle strings safely */
 /* Handle strings safely */
 
 
-void strip (char *buffer);
-char *strscpy (char *dest, const char *src);
-char *strnl (char *str);
-char *strpcpy (char *dest, const char *src, const char *str);
-char *strpcat (char *dest, const char *src, const char *str);
+void strip (char *);
+char *strscpy (char *, const char *);
+char *strnl (char *);
+char *strpcpy (char *, const char *, const char *);
+char *strpcat (char *, const char *, const char *);
 
 
 int max_state (int a, int b);
 int max_state (int a, int b);
 
 
-void usage (const char *msg) __attribute__((noreturn));
-void usage2(const char *msg, const char *arg) __attribute__((noreturn));
-void usage3(const char *msg, int arg) __attribute__((noreturn));
+void usage (const char *) __attribute__((noreturn));
+void usage2(const char *, const char *) __attribute__((noreturn));
+void usage3(const char *, int) __attribute__((noreturn));
+void usage4(const char *);
 
 
-const char *state_text (int result);
+const char *state_text (int);
 
 
 #define max(a,b) (((a)>(b))?(a):(b))
 #define max(a,b) (((a)>(b))?(a):(b))
 #define min(a,b) (((a)<(b))?(a):(b))
 #define min(a,b) (((a)<(b))?(a):(b))
 
 
-char *perfdata (const char *label,
- long int val,
- const char *uom,
- int warnp,
- long int warn,
- int critp,
- long int crit,
- int minp,
- long int minv,
- int maxp,
- long int maxv);
-
-char *fperfdata (const char *label,
- double val,
- const char *uom,
- int warnp,
- double warn,
- int critp,
- double crit,
- int minp,
- double minv,
- int maxp,
- double maxv);
+char *perfdata (const char *,
+ long int,
+ const char *,
+ int,
+ long int,
+ int,
+ long int,
+ int,
+ long int,
+ int,
+ long int);
+
+char *fperfdata (const char *,
+ double,
+ const char *,
+ int,
+ double,
+ int,
+ double,
+ int,
+ double,
+ int,
+ double);
 
 
 /* The idea here is that, although not every plugin will use all of these, 
 /* The idea here is that, although not every plugin will use all of these, 
    most will or should.  Therefore, for consistency, these very common 
    most will or should.  Therefore, for consistency, these very common