[Patch for nrpe-2.5.2] make check_nrpe timeout return STATE_UNKNOWN

Bjoern Beutel bjoern-beutel at arcor.de
Sun Nov 19 11:36:16 CET 2006


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 
>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örn Beutel

----------------------------------------------------------------------------------------

bjoern at james:~$ diff -Naur nrpe-2.5.2/src/check_nrpe.c nrpe-2.5.2_patched/src/check_nrpe.c
--- 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=FALSE;
 int show_license=FALSE;
 int show_version=FALSE;
+int timeout_return_code=STATE_CRITICAL;

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

        if(result!=OK || show_help==TRUE){

-               printf("Usage: check_nrpe -H <host> [-n] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]\n");
+               printf("Usage: check_nrpe -H <host> [-u] [-n] [-p <port>] [-t <timeout>] [-c <command>] [-a <arglist...>]\n");
                printf("\n");
                printf("Options:\n");
                printf(" -n         = Do no use SSL\n");
                printf(" <host>     = The address of the host running the NRPE daemon\n");
                printf(" [port]     = The port on which the daemon is running (default=%d)\n",DEFAULT_SERVER_PORT);
                printf(" [timeout]  = Number of seconds before connection times out (default=%d)\n",DEFAULT_SOCKET_TIMEOUT);
+               printf(" -u         = Socket timeout is not critical, but returns code for unknown state\n");
                printf(" [command]  = The name of the command that the remote daemon should run\n");
                printf(" [arglist]  = Optional arguments that should be passed to the command.  Multiple\n");
                printf("              arguments should be separated by a space.  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=FALSE;
                        break;
+               case 'u':
+                       timeout_return_code=STATE_UNKNOWN;
+                       break;
                default:
                        return ERROR;
                        break;
@@ -417,6 +424,6 @@

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

-       exit(STATE_CRITICAL);
+       exit(timeout_return_code);
         }


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV




More information about the Developers mailing list