--Y7xTucakfITjPcLV
Content-Type: multipart/mixed; boundary="ibTvN161/egqYuK8"
Content-Disposition: inline
--ibTvN161/egqYuK8
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable
Hello,
We periodically get spurious alerts for socket errors on some hosts
(behind a failing firewall, on a bad link, etc). I see that check_nrpe
already has a way to tell it to not report checks that time out as
critical, and I think it would be helpful to be able treat socket errors
in the same way. Attached are two patches: one that adds the socket
error handling to the existing -u option, and one that adds a new option
so these classes of errors can be handled seperately. I have no strong
arguments for which is the better way of doing it, so I present both.
Cheers,
--=20
--------------------------------------------------------------------------
| Stephen Gran | "I have more information in one place |
| [email protected] | than anybody in the world." -- Jerry |
| http://www.lobefin.net/~steve | Pournelle, an absurd notion, apparently |
| | about the BIX BBS |
--------------------------------------------------------------------------
--ibTvN161/egqYuK8
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="0001-add-new-option-to-return-socket-errors-as-UNKNOWN.patch"
Content-Transfer-Encoding: quoted-printable
=46rom 42420f43086cd7d35f0fcf218d847c2820ce22cc Mon Sep 17 00:00:00 2001
=46rom: Stephen Gran
Date: Thu, 24 Nov 2011 07:21:25 +0000
Subject: [PATCH] add new option to return socket errors as UNKNOWN
Signed-off-by: Stephen Gran
---
src/check_nrpe.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/src/check_nrpe.c b/src/check_nrpe.c
index 03b136e..766188e 100644
--- a/src/check_nrpe.c
+++ b/src/check_nrpe.c
@@ -29,6 +29,7 @@ char *server_name=3DNULL;
char *command_name=3DNULL;
int socket_timeout=3DDEFAULT_SOCKET_TIMEOUT;
int timeout_return_code=3DSTATE_CRITICAL;
+int socket_error_return_code=3DSTATE_CRITICAL;
int sd;
=20
char query[MAX_INPUT_BUFFER]=3D"";
@@ -88,7 +89,8 @@ int main(int argc, char **argv){
printf("\n");
printf("Options:\n");
printf(" -n =3D Do no use SSL\n");
- printf(" -u =3D Make socket timeouts return an UNKNOWN state ins=
tead of CRITICAL\n");
+ printf(" -u =3D Make command timeouts return an UNKNOWN state in=
stead of CRITICAL\n");
+ printf(" -s =3D Make socket errors return an UNKNOWN state inste=
ad of CRITICAL\n");
printf(" =3D The address of the host running the NRPE daemon\=
n");
printf(" [port] =3D The port on which the daemon is running (default=
=3D%d)\n",DEFAULT_SERVER_PORT);
printf(" [timeout] =3D Number of seconds before connection times out (d=
efault=3D%d)\n",DEFAULT_SOCKET_TIMEOUT);
@@ -144,6 +146,8 @@ int main(int argc, char **argv){
=20
/* try to connect to the host at the given port number */
result=3Dmy_tcp_connect(server_name,server_port,&sd);
+ if (result=3D=3DSTATE_CRITICAL)
+ result=3Dsocket_error_return_code;
=20
#ifdef HAVE_SSL
/* do SSL handshake */
@@ -323,6 +327,7 @@ int process_arguments(int argc, char **argv){
{"command", required_argument, 0, 'c'},
{"args", required_argument, 0, 'a'},
{"no-ssl", no_argument, 0, 'n'},
+ {"socket-error-timeout", no_argument, 0, 's'},
{"unknown-timeout", no_argument, 0, 'u'},
{"timeout", required_argument, 0, 't'},
{"port", required_argument, 0, 'p'},
@@ -336,7 +341,7 @@ int process_arguments(int argc, char **argv){
if(argc<2)
return ERROR;
=20
- snprintf(optchars,MAX_INPUT_BUFFER,"H:c
+ snprintf(optchars,MAX_INPUT_BUFFER,"H:c
=20
while(1){
#ifdef HAVE_GETOPT_LONG
@@ -382,6 +387,9 @@ int process_arguments(int argc, char **argv){
case 'n':
use_ssl=3DFALSE;
break;
+ case 's':
+ socket_error_return_code=3DSTATE_UNKNOWN;
+ break;
case 'u':
timeout_return_code=3DSTATE_UNKNOWN;
break;
--=20
1.7.2.5
--ibTvN161/egq
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]