This is a multi-part message in MIME format.
--------------010900080104080306070107
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi Ethan,
Here's a patch for nrpe (CVS 1-FEB-08) that takes advantage of the
system resource controller (SRC) under AIX. The additional code is only
compiled in under AIX (I used the _AIX preprocessor macro - available in
both gcc and the native AIX compiler), and adds a new command line
switch (-S) so the user can indicate that nrpe is running under AIX SRC.
John
--------------010900080104080306070107
Content-Type: text/plain;
name="nrpe-aixsrc-cvs01022008.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="nrpe-aixsrc-cvs01022008.patch"
diff -Naur nrpe/src/nrpe.c nrpe-patched/src/nrpe.c
--- nrpe/src/nrpe.c 2008-01-24 05:45:16.000000000 -0700
+++ nrpe-patched/src/nrpe.c 2008-02-02 10:05:12.000000000 -0700
@@ -79,7 +79,11 @@
int use_inetd=TRUE;
int debug=FALSE;
+#ifdef _AIX
+int use_aix_src=FALSE;
+#endif
+static int wc_wrapper(void);
int main(int argc, char **argv){
@@ -267,6 +271,20 @@
handle_connection(0);
}
+#ifdef _AIX
+ /* else if running under AIX System Resource Controller (SRC),
+ just start listening for requests... */
+ else if (use_aix_src == TRUE) {
+
+ /* make sure we're not root */
+ check_privileges();
+
+ /* wait for connections */
+ if ((result = wc_wrapper()) != OK)
+ return result;
+ }
+#endif
+
/* else daemonize and start listening for requests... */
else if(fork()==0){
@@ -304,31 +322,9 @@
/* make sure we're not root */
check_privileges();
- do{
-
- /* reset flags */
- sigrestart=FALSE;
- sigshutdown=FALSE;
-
- /* wait for connections */
- wait_for_connections();
-
- /* free all memory we allocated */
- free_memory();
-
- if(sigrestart==TRUE){
-
- /* read the config file */
- result=read_config_file(config_file);
-
- /* exit if there are errors... */
- if(result==ERROR){
- syslog(LOG_ERR,"Config file '%s' contained errors, bailing out...",config_file);
- return STATE_CRITICAL;
- }
- }
-
- }while(sigrestart==TRUE && sigshutdown==FALSE);
+ /* wait for connections */
+ if ((result = wc_wrapper()) != OK)
+ return result;
/* remove pid file */
remove_pid_file();
@@ -348,6 +344,40 @@
+static int wc_wrapper(void){
+ int result;
+
+ do{
+
+ /* reset flags */
+ sigrestart=FALSE;
+ sigshutdown=FALSE;
+
+ /* wait for connections */
+ wait_for_connections();
+
+ /* free all memory we allocated */
+ free_memory();
+
+ if(sigrestart==TRUE){
+
+ /* read the config file */
+ result=read_config_file(config_file);
+
+ /* exit if there are errors... */
+ if(result==ERROR){
+ syslog(LOG_ERR,"Config file '%s' contained errors, bailing out...",config_file);
+ return STATE_CRITICAL;
+ }
+ }
+
+ }while(sigrestart==TRUE && sigshutdown==FALSE);
+
+ return OK;
+ }
+
+
+
/* read in the configuration file */
int read_config_file(char *filename){
@@ -1903,6 +1933,9 @@
{"config", required_argument, 0, 'c'},
{"inetd", no_argument, 0, 'i'},
{"daemon", no_argument, 0, 'd'},
+#ifdef _AIX
+ {"aix-src", no_argument, 0, 'S'},
+#endif
{"no-ssl", no_argument, 0, 'n'},
{"help", no_argument, 0, 'h'},
{"license", no_argument, 0, 'l'},
@@ -1914,7 +1947,13 @@
if(argc<2)
return ERROR;
- snprintf(optchars,MAX_INPUT_BUFFER,"c:hVldin");
+#ifdef _AIX
+# define OPTCHARS "c:hVldinS"
+#else
+# define OPTCHARS "c:hVldin"
+#endif
+
+ snprintf(optchars,MAX_INPUT_BUFFER,OPTCHARS);
while(1){
#ifdef HAVE_GETOPT_LONG
@@ -1953,6 +1992,11 @@
case 'n':
use_ssl=FALSE;
break;
+#ifdef _AIX
+ case 'S':
+ use_aix_src=TRUE;
+ break;
+#endif
default:
return ERROR;
break;
--------------010900080104080306070107--
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]