summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d36016a)
raw | patch | inline | side by side (parent: d36016a)
author | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Wed, 19 Jun 2002 05:11:52 +0000 (05:11 +0000) | ||
committer | Subhendu Ghosh <sghosh@users.sourceforge.net> | |
Wed, 19 Jun 2002 05:11:52 +0000 (05:11 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@55 f882894a-f735-0410-b71e-b25c423dba1c
diff --git a/plugins/check_dig.c b/plugins/check_dig.c
index 57609acdce705930d0742ea5fc9d349abf6a3699..384b380b8ba5afa291e7847ca8257f349b700639 100644 (file)
--- a/plugins/check_dig.c
+++ b/plugins/check_dig.c
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
/* If we get anything on STDERR, at least set warning */
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
printf ("%s", input_buffer);
if (!strcmp (output, ""))
strcpy (output, 1 + index (input_buffer, ':'));
/* close the pipe */
if (spclose (child_process)) {
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
if (!strcmp (output, ""))
strcpy (output, "nslookup returned error status");
}
diff --git a/plugins/check_dns.c b/plugins/check_dns.c
index eaff43728ae24f81dcf23235bde4019ca6e1d446..a0d6e85e5d9b9340e4a4dbe9ed8035c69140769e 100644 (file)
--- a/plugins/check_dns.c
+++ b/plugins/check_dns.c
/* scan stderr */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
if (error_scan (input_buffer) != STATE_OK) {
- result = max (result, error_scan (input_buffer));
+ result = max_state (result, error_scan (input_buffer));
output = strscpy (output, 1 + index (input_buffer, ':'));
}
}
/* close stdout */
if (spclose (child_process)) {
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
if (!strcmp (output, ""))
output = strscpy (output, "nslookup returned error status");
}
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index f6531a5416e31aee0c9d923863c4646566fee3a6..9a2dd5570ba2b3b73f41fc5ec6ac775c6b341c05 100644 (file)
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
if (verbose)
printf ("%s", input_buffer);
- status = max (status, textscan (input_buffer));
+ status = max_state (status, textscan (input_buffer));
}
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
- status = max (status, STATE_WARNING);
+ status = max_state (status, STATE_WARNING);
if (verbose)
printf ("%s", input_buffer);
- status = max (status, textscan (input_buffer));
+ status = max_state (status, textscan (input_buffer));
}
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- status = max (status, STATE_WARNING);
+ /* need to use max_state not max */
+ status = max_state (status, STATE_WARNING);
printf ("FPING %s - %s\n", state_text (status), server_name);
terminate (status, "FPING %s - %s (loss=%f%%, rta=%f ms)\n",
state_text (status), server_name, loss, rta);
+ }
+ else if(strstr (buf, "xmt/rcv/%loss") ) {
+ /* no min/max/avg if host was unreachable in fping v2.2.b1 */
+ losstr = strstr (buf, "=");
+ losstr = 1 + strstr (losstr, "/");
+ losstr = 1 + strstr (losstr, "/");
+ loss = strtod (losstr, NULL);
+ if (loss == 100)
+ status = STATE_CRITICAL;
+ else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
+ status = STATE_CRITICAL;
+ else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
+ status = STATE_WARNING;
+ else
+ status = STATE_OK;
+
+ terminate (status, "FPING %s - %s (loss=%f%% )\n",
+ state_text (status), server_name, loss );
+
}
else {
- status = max (status, STATE_WARNING);
+ status = max_state (status, STATE_WARNING);
}
return status;
diff --git a/plugins/check_hpjd.c b/plugins/check_hpjd.c
index 9d1878a4509035e6b5054962a015172d93a74641..b45dfcc7bd1b721a9ce9c863683b3bcbc980e7b6 100644 (file)
--- a/plugins/check_hpjd.c
+++ b/plugins/check_hpjd.c
/* WARNING if output found on stderr */
if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* if there wasn't any output, display an error */
if (line == 0) {
diff --git a/plugins/check_nagios.c b/plugins/check_nagios.c
index 04258354c9e3f33b59e451e61a53dce5193d7b47..ea79d24795941bab29f2eb138599d3fd7477e0a2 100644 (file)
--- a/plugins/check_nagios.c
+++ b/plugins/check_nagios.c
/* If we get anything on stderr, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* reset the alarm handler */
alarm (0);
diff --git a/plugins/check_ping.c b/plugins/check_ping.c
index 420f148c140bdcf77883e6d083a7b23d5411a6ca..835d9c1b444728bb2a502d907117caf66b3cdc45 100644 (file)
--- a/plugins/check_ping.c
+++ b/plugins/check_ping.c
/* close the pipe - WARNING if status is set */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
return result;
}
diff --git a/plugins/check_snmp.c b/plugins/check_snmp.c
index 2f970b3d0a05cdbb1f22484220ab4b8faef9d8d6..8e977e82f726be5852252ebe116eb2121746ed40 100644 (file)
--- a/plugins/check_snmp.c
+++ b/plugins/check_snmp.c
char oid[MAX_INPUT_BUFFER] = "";
char *label = NULL;
char *units = NULL;
+char *port = NULL;
char string_value[MAX_INPUT_BUFFER] = "";
char **labels = NULL;
char **unitv = NULL;
iresult = STATE_WARNING;
}
- result = max (result, iresult);
+ result = max_state (result, iresult);
if (nlabels > 1 && i < nlabels && labels[i] != NULL)
outbuff = ssprintf
/* WARNING if output found on stderr */
if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* close stderr */
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
if (nunits > 0)
printf ("%s %s -%s\n", label, state_text (result), outbuff);
if (units == NULL)
units = strscpy (NULL, "");
+ if (port == NULL)
+ port = strscpy(NULL,"161");
+
+ if (port == NULL)
+ port = strscpy(NULL,"161");
+
return c;
}
case 'r':
case 'l':
case 'u':
+ case 'p':
i++;
}
" (default is \"public\")\n"
" -u, --units=STRING\n"
" Units label(s) for output data (e.g., 'sec.').\n"
+ " -p, --port=STRING\n"
+ " TCP port number target is listening on.\n"
" -d, --delimiter=STRING\n"
" Delimiter to use when parsing returned data. Default is \"%s\"\n"
" Any data on the right hand side of the delimiter is considered\n"
diff --git a/plugins/check_vsz.c b/plugins/check_vsz.c
index c8ca82bd1705a9eb7e71b5639955338649023a2c..f53eeae370062e8076a12a2ccb3ec4409d8af7b3 100644 (file)
--- a/plugins/check_vsz.c
+++ b/plugins/check_vsz.c
terminate (STATE_UNKNOWN,
"check_vsz: could not malloc message (1)");
sprintf (message, "%s %s(%d)", message, proc_name, proc_size);
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
}
if (proc_size > crit) {
result = STATE_CRITICAL;
"check_vsz: could not malloc message (2)");
sprintf (message, "%s %d", message, proc_size);
if (proc_size > warn) {
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
}
if (proc_size > crit) {
result = STATE_CRITICAL;
/* If we get anything on STDERR, at least set warning */
while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
(void) fclose (child_stderr);
/* close the pipe */
if (spclose (child_process))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
if (result == STATE_OK)
printf ("ok (all VSZ<%d): %s\n", warn, message);
diff --git a/plugins/urlize.c b/plugins/urlize.c
index 83c37dac94e90dbfad5cb58a0550223834ddef03..c04ac0e37b1d2f2f3acfc9695003bf01aeef3d37 100644 (file)
--- a/plugins/urlize.c
+++ b/plugins/urlize.c
/* WARNING if output found on stderr */
if (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr))
- result = max (result, STATE_WARNING);
+ result = max_state (result, STATE_WARNING);
/* close stderr */
(void) fclose (child_stderr);
diff --git a/plugins/utils.c b/plugins/utils.c
index 49e4d3d76d03d2bcd566840be6d1949932c5eb01..8bec1cf12c2d811edfbbcbee42e67334956f535c 100644 (file)
--- a/plugins/utils.c
+++ b/plugins/utils.c
#define max(a,b) ((a)>(b))?(a):(b)
+/* **************************************************************************
+ * max_state(result, STATE_x)
+ * compares STATE_x to result and returns result if STATE_x is less than a based on the following
+ * STATE_UNKNOWN < STATE_OK < STATE_WARNING < STATE_CRITICAL
+ *
+ * Note that numerically the above does not hold
+ ****************************************************************************/
+
+int
+max_state(int a, int b)
+{
+ if(a == STATE_CRITICAL){
+ return a;
+ }
+ else if (a == STATE_WARNING) {
+
+ if (b == STATE_CRITICAL){
+ return b;
+ }else {
+ return a;
+ }
+ }
+ else if (a == STATE_OK) {
+
+ if ( b== STATE_CRITICAL || b == STATE_WARNING) {
+ return b;
+ }else{
+ return a;
+ }
+ }
+ else {
+ /* a == UNKNOWN */
+ return b;
+ }
+
+
+}
+
char *
my_basename (char *path)
{
diff --git a/plugins/utils.h.in b/plugins/utils.h.in
index a21d63d6c3bcc342dea89b98a7173e088c3267ae..46b152a3b743c38bc17229130c26331f3f1432e6 100644 (file)
--- a/plugins/utils.h.in
+++ b/plugins/utils.h.in
-/* header file for nagios plugins uitls.c */
+/* header file for nagios plugins utils.c */
/* this file should be included in all plugins */
char *strpcpy (char *dest, const char *src, const char *str);
char *strpcat (char *dest, const char *src, const char *str);
+/* Handle comparisions for STATE_* */
+int max_state(int, int);
+
#define max(a,b) ((a)>(b))?(a):(b)
#define usage(msg) {\
(a)==0?"OK":\
(a)==1?"WARNING":\
(a)==2?"CRITICAL":\
-(a)==-2?"DEPENDENT":\
+(a)==3?"UNKNOWN":\
+(a)==4?"DEPENDENT":\
"UNKNOWN"
/* The idea here is that, although not every plugin will use all of these,