Nsca enhancement

Marantz, Roy Roy.Marantz at deshaw.com
Wed Feb 18 22:06:33 CET 2009


Sorry if this should have gone to another mailing list, but I couldn't
find a better place from the nagios.org nor nagiosexchange.org websites
nor a google search.

Following is a short patch to allow the listen syscall backlog parameter
to be overridden.  On Solaris 10 the default is 128 which for my
installation (~28000 passive checks in an hour with a bursty arrival
pattern) leads to many tcpListenDrop and unreliable nsca delivery.

This patch is against nsca v2.7.1

diff -u -r1.1.1.3 -r1.2
--- nsca.c      9 Apr 2007 06:44:37 -0000       1.1.1.3
+++ nsca.c      18 Feb 2009 19:38:04 -0000      1.2
@@ -25,6 +25,7 @@
 static int server_port=DEFAULT_SERVER_PORT;
 static char server_address[16]="0.0.0.0";
 static int socket_timeout=DEFAULT_SOCKET_TIMEOUT;
+static int listen_backlog=SOMAXCONN;

 static char config_file[MAX_INPUT_BUFFER]="nsca.cfg";
 static char alternate_dump_file[MAX_INPUT_BUFFER]="/dev/null";
@@ -347,6 +348,13 @@
                                 return ERROR;
                                 }
                         }
+               else if(!strcmp(varname,"listen_backlog")){
+                       listen_backlog=atoi(varvalue);
+                       if(listen_backlog<=0){
+                               syslog(LOG_ERR,"list_backlog value,
'%s', is not an integer in config file '%s' - Line
%d\n",varvalue,filename,line);
+                               return ERROR;
+                               }
+                        }
                else if(!strcmp(varname,"server_address")){
 
strncpy(server_address,varvalue,sizeof(server_address)
- 1);
                         server_address[sizeof(server_address)-1]='\0';
@@ -707,7 +715,7 @@
                 }

         /* open the socket for listening */
-        if(listen(sock,SOMAXCONN)<0){
+        if(listen(sock,listen_backlog)<0){
                 syslog(LOG_ERR,"Network server listen failure (%d:
%s)\n",errno,strerror(errno));
                 do_exit(STATE_CRITICAL);
                 }


I've also added this to take advantage of the change.

--- nsca.cfg    2006/08/31 14:57:24     1.2
+++ nsca.cfg    2009/02/18 20:31:30
@@ -1,6 +1,6 @@
 ####################################################
 #
-# $Header:
+# $Header:
 #
 # Sample NSCA Daemon Config File
 # Written by: Ethan Galstad (nagios at nagios.org)
@@ -25,7 +25,11 @@

 server_port=5667

-
+# LISTEN BACKLOG
+# Overide the backlog parameter for the listen call, default SOMAXCONN
+# at least on Solaris 10 this is just 128 which is too small for highly
+# districuted setup
+listen_backlog=1024

Let me know if you have any questions.
Roy

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H




More information about the Developers mailing list