[Nagios-devel] [Patch for nrpe-2.5.2] make check_nrpe timeout

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Guest

[Nagios-devel] [Patch for nrpe-2.5.2] make check_nrpe timeout

Post by Guest »

Hello,

on May 29th, Tony den Haan wrote:
> I ran into nagios mailing me CRITICALs when it couldn't connect to remote
> nrpe daemon. This looks a bit strange, since it couldn't possible know if
> a filesystem if full or whatever when it can't query daemon.
> I suggest making check_nrpe return STATUS_UNKNOWN in alarm_handler(),
> instead of STATUS_CRITICAL.

Ethan Galstad answered:
>I'll put this on my TODO list for NRPE. I'll add a command line option=20
>that will allow either CRITICAL or UNKNOWN on timeouts for check_nrpe.

We had the same problem at work, which was quite acute since it woke up our=
call-on
duty during night-time several times per month.
So I added an option "-u" (uncritical timeout) to "check_nrpe.c",
which makes check_nrpe.c return STATUS_UNKNOWN in alarm_handler().
See below for the diffs.

Best regards,

Bj=F6rn Beutel

=2D------------------------------------------------------------------------=
=2D--------------

bjoern@james:~$ diff -Naur nrpe-2.5.2/src/check_nrpe.c nrpe-2.5.2_patched/s=
rc/check_nrpe.c
=2D-- nrpe-2.5.2/src/check_nrpe.c 2006-04-10 03:42:30.000000000 +0200
+++ nrpe-2.5.2_patched/src/check_nrpe.c 2006-11-19 11:24:28.000000000 +0100
@@ -35,6 +35,7 @@
int show_help=3DFALSE;
int show_license=3DFALSE;
int show_version=3DFALSE;
+int timeout_return_code=3DSTATE_CRITICAL;

#ifdef HAVE_SSL
SSL_METHOD *meth;
@@ -82,13 +83,14 @@

if(result!=3DOK || show_help=3D=3DTRUE){

=2D printf("Usage: check_nrpe -H [-n] [-p ] [-t =
] [-c ] [-a ]\n");
+ printf("Usage: check_nrpe -H [-u] [-n] [-p ] [=
=2Dt ] [-c ] [-a ]\n");
printf("\n");
printf("Options:\n");
printf(" -n =3D Do no use SSL\n");
printf(" =3D The address of the host running the=
NRPE daemon\n");
printf(" [port] =3D The port on which the daemon is run=
ning (default=3D%d)\n",DEFAULT_SERVER_PORT);
printf(" [timeout] =3D Number of seconds before connection=
times out (default=3D%d)\n",DEFAULT_SOCKET_TIMEOUT);
+ printf(" -u =3D Socket timeout is not critical, but=
returns code for unknown state\n");
printf(" [command] =3D The name of the command that the re=
mote daemon should run\n");
printf(" [arglist] =3D Optional arguments that should be p=
assed to the command. Multiple\n");
printf(" arguments should be separated by a sp=
ace. If provided, this must be\n");
@@ -320,6 +322,7 @@
{"command", required_argument, 0, 'c'},
{"args", required_argument, 0, 'a'},
{"no-ssl", no_argument, 0, 'n'},
+ {"uncritical-timeout", no_argument, 0, 'u'},
{"timeout", required_argument, 0, 't'},
{"port", required_argument, 0, 'p'},
{"help", no_argument, 0, 'h'},
@@ -332,6 +335,7 @@
if(argc<2)
return ERROR;

+ snprintf(optchars,MAX_INPUT_BUFFER,"H:c:a:t:p:nuhl");
snprintf(optchars,MAX_INPUT_BUFFER,"H:c:a:t:p:nhl");

while(1){
@@ -378,6 +382,9 @@
case 'n':
use_ssl=3DFALSE;
break;
+ case 'u':
+ timeout_return_code=3DSTATE_UNKNOWN;
+ break;
default:
return ERROR;
break;
@@ -417,6 +424,6 @@

printf("CHECK_NRPE: Socket timeout after %d seconds.\n",socket_time=
out);

=2D exit(STATE_CRITICAL);
+ exit(timeout_return_code);
}






This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]
Locked