summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorBenoit Mortier <opensides@users.sourceforge.net>2004-12-05 00:54:09 (GMT)
committerBenoit Mortier <opensides@users.sourceforge.net>2004-12-05 00:54:09 (GMT)
commit2ab4d8fc278413b01ff9c4e4496f892398f80a4c (patch)
tree6d402f5bf1b4673d00f97bbb84b1ea6b4badd060 /plugins
parente9e1fe6ef5720adf355b605ffdbe94cd608cc46c (diff)
downloadmonitoring-plugins-2ab4d8fc278413b01ff9c4e4496f892398f80a4c.tar.gz
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
Diffstat (limited to 'plugins')
-rw-r--r--plugins/check_http.c16
-rw-r--r--plugins/check_icmp.c23
-rw-r--r--plugins/check_nwstat.c3
-rw-r--r--plugins/check_ping.c2
-rw-r--r--plugins/check_smtp.c3
-rw-r--r--plugins/check_swap.c2
-rw-r--r--plugins/utils.h71
7 files changed, 59 insertions, 61 deletions
diff --git a/plugins/check_http.c b/plugins/check_http.c
index 6f8ad9a..dd05821 100644
--- a/plugins/check_http.c
+++ b/plugins/check_http.c
@@ -676,17 +676,17 @@ check_document_dates (const char *headers)
676 } else if (!document_date || !*document_date) { 676 } else if (!document_date || !*document_date) {
677 die (STATE_CRITICAL, _("Document modification date unknown\n")); 677 die (STATE_CRITICAL, _("Document modification date unknown\n"));
678 } else { 678 } else {
679 time_t sd = parse_time_string (server_date); 679 time_t srv_data = parse_time_string (server_date);
680 time_t dd = parse_time_string (document_date); 680 time_t doc_data = parse_time_string (document_date);
681 681
682 if (sd <= 0) { 682 if (srv_data <= 0) {
683 die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date); 683 die (STATE_CRITICAL, _("CRITICAL - Server date \"%100s\" unparsable"), server_date);
684 } else if (dd <= 0) { 684 } else if (doc_data <= 0) {
685 die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date); 685 die (STATE_CRITICAL, _("CRITICAL - Document date \"%100s\" unparsable"), document_date);
686 } else if (dd > sd + 30) { 686 } else if (doc_data > srv_data + 30) {
687 die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), dd - sd); 687 die (STATE_CRITICAL, _("CRITICAL - Document is %d seconds in the future\n"), (int)doc_data - (int)srv_data);
688 } else if (dd < sd - maximum_age) { 688 } else if (doc_data < srv_data - maximum_age) {
689 int n = (sd - dd); 689 int n = (srv_data - doc_data);
690 if (n > (60 * 60 * 24 * 2)) 690 if (n > (60 * 60 * 24 * 2))
691 die (STATE_CRITICAL, 691 die (STATE_CRITICAL,
692 _("CRITICAL - Last modified %.1f days ago\n"), 692 _("CRITICAL - Last modified %.1f days ago\n"),
diff --git a/plugins/check_icmp.c b/plugins/check_icmp.c
index 45bfcc5..361e924 100644
--- a/plugins/check_icmp.c
+++ b/plugins/check_icmp.c
@@ -1,6 +1,8 @@
1/* 1/*
2 * check_icmp - A hack of fping2 to work with nagios. 2 * $Id$
3 * This way we don't have to use the output parser. 3 *
4 * This is a hack of fping2 made to work with nagios.
5 * It's fast and removes the necessity of parsing another programs output.
4 * 6 *
5 * VIEWING NOTES: 7 * VIEWING NOTES:
6 * This file was formatted with tab indents at a tab stop of 4. 8 * This file was formatted with tab indents at a tab stop of 4.
@@ -40,14 +42,8 @@
40#include <netinet/in_systm.h> 42#include <netinet/in_systm.h>
41#include <netinet/in.h> 43#include <netinet/in.h>
42 44
43/* Linux has bizarre ip.h and ip_icmp.h */
44/* Taken from the fping distro. Thank you. */
45#if defined( __linux__ )
46#include "linux.h"
47#else
48#include <netinet/ip.h> 45#include <netinet/ip.h>
49#include <netinet/ip_icmp.h> 46#include <netinet/ip_icmp.h>
50#endif /* defined(__linux__) */
51 47
52#include <arpa/inet.h> 48#include <arpa/inet.h>
53#include <netdb.h> 49#include <netdb.h>
@@ -70,9 +66,8 @@ extern char *optarg;
70extern int optind, opterr; 66extern int optind, opterr;
71 67
72/*** Constants ***/ 68/*** Constants ***/
73#define REV_DATE "2004-09-06"
74#define EMAIL "ae@op5.se" 69#define EMAIL "ae@op5.se"
75#define VERSION "0.8" 70#define VERSION "0.8.1"
76 71
77#ifndef INADDR_NONE 72#ifndef INADDR_NONE
78# define INADDR_NONE 0xffffffU 73# define INADDR_NONE 0xffffffU
@@ -441,7 +436,7 @@ int main(int argc, char **argv)
441 break; 436 break;
442 437
443 case 'v': 438 case 'v':
444 printf("%s: Version %s $Date$\n", prog, VERSION, REV_DATE); 439 printf("%s: Version %s $Date$\n", prog, VERSION);
445 printf("%s: comments to %s\n", prog, EMAIL); 440 printf("%s: comments to %s\n", prog, EMAIL);
446 exit(STATE_OK); 441 exit(STATE_OK);
447 442
@@ -1275,7 +1270,7 @@ void u_sleep(int u_sec)
1275 * crash on any other errrors 1270 * crash on any other errrors
1276 ************************************************************/ 1271 ************************************************************/
1277/* TODO: add MSG_DONTWAIT to recvfrom flags (currently 0) */ 1272/* TODO: add MSG_DONTWAIT to recvfrom flags (currently 0) */
1278int recvfrom_wto(int sock, char *buf, int len, struct sockaddr *saddr, int timo) 1273int recvfrom_wto(int lsock, char *buf, int len, struct sockaddr *saddr, int timo)
1279{ 1274{
1280 int nfound = 0, slen, n; 1275 int nfound = 0, slen, n;
1281 struct timeval to; 1276 struct timeval to;
@@ -1289,8 +1284,8 @@ int recvfrom_wto(int sock, char *buf, int len, struct sockaddr *saddr, int timo)
1289 1284
1290 FD_ZERO(&readset); 1285 FD_ZERO(&readset);
1291 FD_ZERO(&writeset); 1286 FD_ZERO(&writeset);
1292 FD_SET(sock, &readset); 1287 FD_SET(lsock, &readset);
1293 nfound = select(sock + 1, &readset, &writeset, NULL, &to); 1288 nfound = select(lsock + 1, &readset, &writeset, NULL, &to);
1294 if(nfound < 0) crash("select() in recvfrom_wto"); 1289 if(nfound < 0) crash("select() in recvfrom_wto");
1295 1290
1296 if(nfound == 0) return -1; /* timeout */ 1291 if(nfound == 0) return -1; /* timeout */
diff --git a/plugins/check_nwstat.c b/plugins/check_nwstat.c
index d8913bc..2d7e611 100644
--- a/plugins/check_nwstat.c
+++ b/plugins/check_nwstat.c
@@ -909,8 +909,7 @@ void print_help(void)
909 909
910 printf (_("\ 910 printf (_("\
911This plugin attempts to contact the MRTGEXT NLM running on a\n\ 911This plugin attempts to contact the MRTGEXT NLM running on a\n\
912Novell server to gather the requested system information.\n\n"), 912Novell server to gather the requested system information.\n\n"));
913 progname);
914 913
915 print_usage(); 914 print_usage();
916 915
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 4778fcf..9176466 100644
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
@@ -469,6 +469,8 @@ error_scan (char buf[MAX_INPUT_BUFFER], const char *addr)
469 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)"), addr); 469 die (STATE_CRITICAL, _("CRITICAL - Host Unreachable (%s)"), addr);
470 else if (strstr (buf, "unknown host" )) 470 else if (strstr (buf, "unknown host" ))
471 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)"), addr); 471 die (STATE_CRITICAL, _("CRITICAL - Host not found (%s)"), addr);
472 else if (strstr (buf, "Time to live exceeded"))
473 die (STATE_CRITICAL, _("CRITICAL - Time to live exceeded (%s)"), addr);
472 474
473 if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) { 475 if (strstr (buf, "(DUP!)") || strstr (buf, "DUPLICATES FOUND")) {
474 if (warn_text == NULL) 476 if (warn_text == NULL)
diff --git a/plugins/check_smtp.c b/plugins/check_smtp.c
index ab1b950..b6c60c2 100644
--- a/plugins/check_smtp.c
+++ b/plugins/check_smtp.c
@@ -218,11 +218,12 @@ main (int argc, char **argv)
218 microsec = deltime (tv); 218 microsec = deltime (tv);
219 elapsed_time = (double)microsec / 1.0e6; 219 elapsed_time = (double)microsec / 1.0e6;
220 220
221 if (result == STATE_OK) 221 if (result == STATE_OK) {
222 if (check_critical_time && elapsed_time > (double) critical_time) 222 if (check_critical_time && elapsed_time > (double) critical_time)
223 result = STATE_CRITICAL; 223 result = STATE_CRITICAL;
224 else if (check_warning_time && elapsed_time > (double) warning_time) 224 else if (check_warning_time && elapsed_time > (double) warning_time)
225 result = STATE_WARNING; 225 result = STATE_WARNING;
226 }
226 227
227 printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"), 228 printf (_("SMTP %s - %.3f sec. response time%s%s|%s\n"),
228 state_text (result), elapsed_time, 229 state_text (result), elapsed_time,
diff --git a/plugins/check_swap.c b/plugins/check_swap.c
index 3067f85..6e2ab72 100644
--- a/plugins/check_swap.c
+++ b/plugins/check_swap.c
@@ -56,10 +56,10 @@ main (int argc, char **argv)
56 int result = STATE_UNKNOWN; 56 int result = STATE_UNKNOWN;
57 char input_buffer[MAX_INPUT_BUFFER]; 57 char input_buffer[MAX_INPUT_BUFFER];
58 char *perf; 58 char *perf;
59 int conv_factor = SWAP_CONVERSION;
60#ifdef HAVE_PROC_MEMINFO 59#ifdef HAVE_PROC_MEMINFO
61 FILE *fp; 60 FILE *fp;
62#else 61#else
62 int conv_factor = SWAP_CONVERSION;
63# ifdef HAVE_SWAP 63# ifdef HAVE_SWAP
64 char *temp_buffer; 64 char *temp_buffer;
65 char *swap_command; 65 char *swap_command;
diff --git a/plugins/utils.h b/plugins/utils.h
index 4fc1305..bdf1ee1 100644
--- a/plugins/utils.h
+++ b/plugins/utils.h
@@ -16,9 +16,9 @@ suite of plugins. */
16/* $Id$ */ 16/* $Id$ */
17 17
18void support (void); 18void support (void);
19char *clean_revstring (const char *revstring); 19char *clean_revstring (const char *);
20void print_revision (const char *, const char *); 20void print_revision (const char *, const char *);
21void die (int result, const char *fmt, ...) __attribute__((noreturn,format(printf, 2, 3))); 21void die (int, const char *, ...) __attribute__((noreturn,format(printf, 2, 3)));
22 22
23/* Handle timeouts */ 23/* Handle timeouts */
24 24
@@ -57,7 +57,7 @@ struct timeval {
57#endif 57#endif
58 58
59#ifndef HAVE_GETTIMEOFDAY 59#ifndef HAVE_GETTIMEOFDAY
60int gettimeofday(struct timeval *tv, struct timezone *tz); 60int gettimeofday(struct timeval *, struct timezone *);
61#endif 61#endif
62 62
63double delta_time (struct timeval tv); 63double delta_time (struct timeval tv);
@@ -65,46 +65,47 @@ long deltime (struct timeval tv);
65 65
66/* Handle strings safely */ 66/* Handle strings safely */
67 67
68void strip (char *buffer); 68void strip (char *);
69char *strscpy (char *dest, const char *src); 69char *strscpy (char *, const char *);
70char *strnl (char *str); 70char *strnl (char *);
71char *strpcpy (char *dest, const char *src, const char *str); 71char *strpcpy (char *, const char *, const char *);
72char *strpcat (char *dest, const char *src, const char *str); 72char *strpcat (char *, const char *, const char *);
73 73
74int max_state (int a, int b); 74int max_state (int a, int b);
75 75
76void usage (const char *msg) __attribute__((noreturn)); 76void usage (const char *) __attribute__((noreturn));
77void usage2(const char *msg, const char *arg) __attribute__((noreturn)); 77void usage2(const char *, const char *) __attribute__((noreturn));
78void usage3(const char *msg, int arg) __attribute__((noreturn)); 78void usage3(const char *, int) __attribute__((noreturn));
79void usage4(const char *);
79 80
80const char *state_text (int result); 81const char *state_text (int);
81 82
82#define max(a,b) (((a)>(b))?(a):(b)) 83#define max(a,b) (((a)>(b))?(a):(b))
83#define min(a,b) (((a)<(b))?(a):(b)) 84#define min(a,b) (((a)<(b))?(a):(b))
84 85
85char *perfdata (const char *label, 86char *perfdata (const char *,
86 long int val, 87 long int,
87 const char *uom, 88 const char *,
88 int warnp, 89 int,
89 long int warn, 90 long int,
90 int critp, 91 int,
91 long int crit, 92 long int,
92 int minp, 93 int,
93 long int minv, 94 long int,
94 int maxp, 95 int,
95 long int maxv); 96 long int);
96 97
97char *fperfdata (const char *label, 98char *fperfdata (const char *,
98 double val, 99 double,
99 const char *uom, 100 const char *,
100 int warnp, 101 int,
101 double warn, 102 double,
102 int critp, 103 int,
103 double crit, 104 double,
104 int minp, 105 int,
105 double minv, 106 double,
106 int maxp, 107 int,
107 double maxv); 108 double);
108 109
109/* The idea here is that, although not every plugin will use all of these, 110/* The idea here is that, although not every plugin will use all of these,
110 most will or should. Therefore, for consistency, these very common 111 most will or should. Therefore, for consistency, these very common