Update of /cvsroot/nagios/nagios/base
In directory sc8-pr-cvs1:/tmp/cvs-serv5504/base
Modified Files:
checks.c config.c notifications.c sehandlers.c utils.c
Log Message:
Nasty bug fixes
Index: checks.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/checks.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -C2 -r1.36 -r1.37
*** checks.c 15 Apr 2003 00:13:23 -0000 1.36
--- checks.c 16 Apr 2003 02:57:35 -0000 1.37
***************
*** 4,8 ****
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-13-2003
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-15-2003
*
* License:
***************
*** 1952,1959 ****
int result=STATE_OK;
int return_result=HOST_UP;
! char processed_check_command[MAX_INPUT_BUFFER];
! char raw_check_command[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
- command *temp_command;
time_t current_time;
time_t start_time;
--- 1952,1958 ----
int result=STATE_OK;
int return_result=HOST_UP;
! char processed_command[MAX_INPUT_BUFFER];
! char raw_command[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
time_t current_time;
time_t start_time;
***************
*** 1996,2012 ****
}
- /* find the command we use to check the host */
- temp_command=find_command(hst->host_check_command,NULL);
-
- /* if we couldn't find the command, return with an error */
- if(temp_command==NULL){
-
- #ifdef DEBUG3
- printf("\tCouldn't find the host check command!\n");
- #endif
-
- return HOST_UP;
- }
-
/* grab the host macros */
clear_volatile_macros();
--- 1995,1998 ----
***************
*** 2018,2031 ****
/* get the raw command line */
! strncpy(raw_check_command,temp_command->command_line,sizeof(raw_check_command));
! raw_check_command[sizeof(raw_check_command)-1]='\x0';
! /* process any macros in the check command */
! process_macros(raw_check_command,&processed_check_command[0],(int)sizeof(processed_check_command),0);
#ifdef DEBUG3
! printf("\t\tRaw Command: %s\n",hst->host_check_command);
! printf("\t\tProcessed Command: %s\n",processed_check_command);
#endif
--- 2004,2018 ----
/* get the raw command line */
! get_raw_command_line(hst->host_check_command,raw_command,sizeof(raw_command));
! strip(raw_command);
! /* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),0);
! strip(processed_command);
#ifdef DEBUG3
! printf("\t\tRaw Command: %s\n",raw_command);
! printf("\t\tProcessed Command: %s\n",processed_command);
#endif
***************
*** 2035,2039 ****
/* run the host check command */
! result=my_system(processed_check_command,host_check_timeout,&early_timeout,&exectime,temp_plugin_output,MAX_PLUGINOUTPUT_LENGTH-1);
/* if the check timed out, report an error */
--- 2022,2026 ----
/* run the host check command */
! result=my_system(processed_command,host_check_timeout,&early_timeout,&exectime,temp_plugin_output,MAX_PLUGINOUTPUT_LENGTH-1);
/* if the check timed out, report an error */
***************
*** 2044,2048 ****
/* log the timeout */
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host check command '%s' for host '%s' timed out after %d seconds\n",hst->host_check_command,hst->name,host_check_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
--- 2031,2035 ----
/* log the timeout */
! snprintf(temp_buffer,sizeof(temp_buffer)-1,"Warning: Host check command '%s' for host '%s' timed out after %d seconds\n",processed_command,hst->name,host_check_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
Index: config.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/config.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -r1.21 -r1.22
*** config.c 10 Apr 2003 03:46:00 -0000 1.21
--- config.c 16 Apr 2003 02:57:35 -0000 1.22
***************
*** 4,8 ****
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-09-2003
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-15-2003
*
* License:
***************
*** 2388,2394 ****
printf("Checking obsessive compulsive processor commands...\n");
if(ocsp_command!=NULL){
! temp_command=find_command(ocsp_command,NULL);
if(temp_command==NULL){
! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Obsessive compulsive service processor command '%s' is not defined anywhere!",ocsp_command);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE);
--- 2388,2401 ----
printf("Checking obsessive compulsive processor commands...\n");
if(ocsp_command!=NULL){
!
! strncpy(temp_buffer,ocsp_command,sizeof(temp_buffer));
! temp_buffer[sizeof(temp_buffer)-1]='\x0';
!
! /* get the command name, leave any arguments behind */
! temp_command_name=my_strtok(temp_buffer,"!");
!
! temp_command=find_command(temp_command_name,NULL);
if(temp_command==NULL){
! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Obsessive compulsive service processor command '%s' is not defined anywhere!",temp_command_name);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE);
***************
*** 2397,2403 ****
}
if(ochp_command!=NULL){
! temp_command=find_command(ochp_command,NULL);
if(temp_command==NULL){
! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Obsessive compulsive host processor command '%s' is not defined anywhere!",ochp_command);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE);
--- 2404,2417 ----
}
if(ochp_command!=NULL){
!
! strncpy(temp_buffer,ochp_command,sizeof(temp_buffer));
! temp_buffer[sizeof(temp_buffer)-1]='\x0';
!
! /* get the command name, leave any arguments behind */
! temp_command_name=my_strtok(temp_buffer,"!");
!
! temp_command=find_command(temp_command_name,NULL);
if(temp_command==NULL){
! snprintf(temp_buffer,sizeof(temp_buffer),"Error: Obsessive compulsive host processor command '%s' is not defined anywhere!",temp_command_name);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_VERIFICATION_ERROR,TRUE);
Index: notifications.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/notifications.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** notifications.c 15 Apr 2003 00:13:24 -0000 1.13
--- notifications.c 16 Apr 2003 02:57:35 -0000 1.14
***************
*** 543,549 ****
int notify_contact_of_service(contact *cntct, service *svc, int type){
commandsmember *temp_commandsmember;
! char temp_command_line[MAX_INPUT_BUFFER];
! char raw_command_line[MAX_INPUT_BUFFER];
! char command_line[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
--- 543,550 ----
int notify_contact_of_service(contact *cntct, service *svc, int type){
commandsmember *temp_commandsmember;
! char command_name[MAX_INPUT_BUFFER];
! char *command_name_ptr=NULL;
! char raw_command[MAX_INPUT_BUFFER];
! char processed_command[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
***************
*** 565,585 ****
for(temp_commandsmember=cntct->service_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
/* get the raw command line */
! strncpy(temp_command_line,temp_commandsmember->command,sizeof(temp_command_line)-1);
! temp_command_line[sizeof(temp_command_line)-1]='\x0';
! get_raw_command_line(temp_command_line,&raw_command_line[0],(int)sizeof(raw_command_line));
! /* run the notification command */
! if(strcmp(raw_command_line,"")){
! #ifdef DEBUG4
! printf("\tRaw Command: %s\n",raw_command_line);
! #endif
!
! /* replace macros in the command line */
! process_macros(raw_command_line,&command_line[0],(int)sizeof(command_line),STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS);
#ifdef DEBUG4
! printf("\tProcessed Command: %s\n",command_line);
#endif
--- 566,588 ----
for(temp_commandsmember=cntct->service_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
+ /* get the command name */
+ strncpy(command_name,temp_commandsmember->command,sizeof(command_name));
+ command_name[sizeof(command_name)-1]='\x0';
+ command_name_ptr=strtok(command_name,"!");
+
/* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command));
! strip(raw_command);
! /* process any macros contained in the argument */
! process_macros(raw_command,processed_command,sizeof(processed_command),0);
! strip(processed_command);
! /* run the notification command */
! if(strcmp(processed_command,"")){
#ifdef DEBUG4
! printf("\tRaw Command: %s\n",raw_command);
! printf("\tProcessed Command: %s\n",processed_command);
#endif
***************
*** 588,601 ****
switch(type){
case NOTIFICATION_ACKNOWLEDGEMENT:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;ACKNOWLEDGEMENT (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],temp_command_line,macro_x[MACRO_SERVICEOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTART:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],temp_command_line,macro_x[MACRO_SERVICEOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTOP:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],temp_command_line,macro_x[MACRO_SERVICEOUTPUT]);
break;
default:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;%s;%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],temp_command_line,macro_x[MACRO_SERVICEOUTPUT]);
break;
}
--- 591,604 ----
switch(type){
case NOTIFICATION_ACKNOWLEDGEMENT:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;ACKNOWLEDGEMENT (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTART:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTOP:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
break;
default:
! snprintf(temp_buffer,sizeof(temp_buffer),"SERVICE NOTIFICATION: %s;%s;%s;%s;%s;%s\n",cntct->name,svc->host_name,svc->description,macro_x[MACRO_SERVICESTATE],command_name_ptr,macro_x[MACRO_SERVICEOUTPUT]);
break;
}
***************
*** 605,613 ****
/* run the command */
! my_system(command_line,notification_timeout,&early_timeout,&exectime,NULL,0);
/* check to see if the notification command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Contact '%s' service notification command '%s' timed out after %d seconds\n",cntct->name,temp_commandsmember->command,DEFAULT_NOTIFICATION_TIMEOUT);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_SERVICE_NOTIFICATION | NSLOG_RUNTIME_WARNING,TRUE);
--- 608,616 ----
/* run the command */
! my_system(processed_command,notification_timeout,&early_timeout,&exectime,NULL,0);
/* check to see if the notification command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Contact '%s' service notification command '%s' timed out after %d seconds\n",cntct->name,processed_command,DEFAULT_NOTIFICATION_TIMEOUT);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_SERVICE_NOTIFICATION | NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 1179,1186 ****
int notify_contact_of_host(contact *cntct,host *hst, int type){
commandsmember *temp_commandsmember;
! char temp_command_line[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
! char raw_command_line[MAX_INPUT_BUFFER];
! char command_line[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
double exectime;
--- 1182,1190 ----
int notify_contact_of_host(contact *cntct,host *hst, int type){
commandsmember *temp_commandsmember;
! char command_name[MAX_INPUT_BUFFER];
! char *command_name_ptr;
char temp_buffer[MAX_INPUT_BUFFER];
! char raw_command[MAX_INPUT_BUFFER];
! char processed_command[MAX_INPUT_BUFFER];
int early_timeout=FALSE;
double exectime;
***************
*** 1202,1223 ****
for(temp_commandsmember=cntct->host_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
! /* get the raw command line */
! strncpy(temp_command_line,temp_commandsmember->command,sizeof(temp_command_line)-1);
! temp_command_line[sizeof(temp_command_line)-1]='\x0';
! get_raw_command_line(temp_command_line,&raw_command_line[0],(int)sizeof(raw_command_line));
! /* run the notification command */
! if(strcmp(raw_command_line,"")){
! #ifdef DEBUG4
! printf("\tRaw Command: %s\n",raw_command_line);
! #endif
- /* replace macros in the command line */
- process_macros(raw_command_line,&command_line[0],(int)sizeof(command_line),STRIP_ILLEGAL_MACRO_CHARS|ESCAPE_MACRO_CHARS);
#ifdef DEBUG4
! printf("\tProcessed Command: %s\n",command_line);
#endif
--- 1206,1229 ----
for(temp_commandsmember=cntct->host_notification_commands;temp_commandsmember!=NULL;temp_commandsmember=temp_commandsmember->next){
! /* get the command name */
! strncpy(command_name,temp_commandsmember->command,sizeof(command_name));
! command_name[sizeof(command_name)-1]='\x0';
! command_name_ptr=strtok(command_name,"!");
! /* get the raw command line */
! get_raw_command_line(temp_commandsmember->command,raw_command,sizeof(raw_command));
! strip(raw_command);
+ /* process any macros contained in the argument */
+ process_macros(raw_command,processed_command,sizeof(processed_command),0);
+ strip(processed_command);
! /* run the notification command */
! if(strcmp(processed_command,"")){
#ifdef DEBUG4
! printf("\tRaw Command: %s\n",raw_command);
! printf("\tProcessed Command: %s\n",processed_command);
#endif
***************
*** 1226,1239 ****
switch(type){
case NOTIFICATION_ACKNOWLEDGEMENT:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;ACKNOWLEDGEMENT (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],temp_command_line,macro_x[MACRO_HOSTOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTART:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],temp_command_line,macro_x[MACRO_HOSTOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTOP:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],temp_command_line,macro_x[MACRO_HOSTOUTPUT]);
! break;
default:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;%s;%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],temp_command_line,macro_x[MACRO_HOSTOUTPUT]);
break;
}
--- 1232,1244 ----
switch(type){
case NOTIFICATION_ACKNOWLEDGEMENT:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;ACKNOWLEDGEMENT (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTART:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;FLAPPINGSTART (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
break;
case NOTIFICATION_FLAPPINGSTOP:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;FLAPPINGSTOP (%s);%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]); break;
default:
! snprintf(temp_buffer,sizeof(temp_buffer),"HOST NOTIFICATION: %s;%s;%s;%s;%s\n",cntct->name,hst->name,macro_x[MACRO_HOSTSTATE],command_name_ptr,macro_x[MACRO_HOSTOUTPUT]);
break;
}
***************
*** 1243,1251 ****
/* run the command */
! my_system(command_line,notification_timeout,&early_timeout,&exectime,NULL,0);
/* check to see if the notification timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Contact '%s' host notification command '%s' timed out after %d seconds\n",cntct->name,temp_commandsmember->command,DEFAULT_NOTIFICATION_TIMEOUT);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_HOST_NOTIFICATION | NSLOG_RUNTIME_WARNING,TRUE);
--- 1248,1256 ----
/* run the command */
! my_system(processed_command,notification_timeout,&early_timeout,&exectime,NULL,0);
/* check to see if the notification timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Contact '%s' host notification command '%s' timed out after %d seconds\n",cntct->name,processed_command,DEFAULT_NOTIFICATION_TIMEOUT);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_HOST_NOTIFICATION | NSLOG_RUNTIME_WARNING,TRUE);
Index: sehandlers.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/sehandlers.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** sehandlers.c 15 Apr 2003 00:13:24 -0000 1.16
--- sehandlers.c 16 Apr 2003 02:57:36 -0000 1.17
***************
*** 4,8 ****
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-13-2003
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-15-2003
*
* License:
***************
*** 66,70 ****
char processed_command_line[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
- command *temp_command;
host *temp_host;
int early_timeout=FALSE;
--- 66,69 ----
***************
*** 81,84 ****
--- 80,87 ----
return OK;
+ /* if there is no valid command, exit */
+ if(ocsp_command==NULL)
+ return ERROR;
+
/* find the associated host */
temp_host=find_host(svc->host_name);
***************
*** 103,116 ****
sprintf(macro_x[MACRO_SERVICEATTEMPT],"%d",svc->current_attempt);
! /* find the service processor command */
! temp_command=find_command(ocsp_command,NULL);
!
! /* if there is no valid command, exit */
! if(temp_command==NULL)
! return ERROR;
!
! /* get the raw command line to execute */
! strncpy(raw_command_line,temp_command->command_line,sizeof(raw_command_line));
! raw_command_line[sizeof(raw_command_line)-1]='\x0';
#ifdef DEBUG3
--- 106,112 ----
sprintf(macro_x[MACRO_SERVICEATTEMPT],"%d",svc->current_attempt);
! /* get the raw command line */
! get_raw_command_line(ocsp_command,raw_command_line,sizeof(raw_command_line));
! strip(raw_command_line);
#ifdef DEBUG3
***************
*** 130,134 ****
/* check to see if the command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: OCSP command '%s' for service '%s' on host '%s' timed out after %d seconds\n",ocsp_command,svc->description,svc->host_name,ocsp_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
--- 126,130 ----
/* check to see if the command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: OCSP command '%s' for service '%s' on host '%s' timed out after %d seconds\n",processed_command_line,svc->description,svc->host_name,ocsp_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 149,153 ****
char processed_command_line[MAX_INPUT_BUFFER];
char temp_buffer[MAX_INPUT_BUFFER];
- command *temp_command;
int early_timeout=FALSE;
double exectime;
--- 145,148 ----
***************
*** 163,180 ****
return OK;
/* update macros */
clear_volatile_macros();
grab_host_macros(hst);
! /* find the host processor command */
! temp_command=find_command(ochp_command,NULL);
!
! /* if there is no valid command, exit */
! if(temp_command==NULL)
! return ERROR;
!
! /* get the raw command line to execute */
! strncpy(raw_command_line,temp_command->command_line,sizeof(raw_command_line));
! raw_command_line[sizeof(raw_command_line)-1]='\x0';
#ifdef DEBUG3
--- 158,172 ----
return OK;
+ /* if there is no valid command, exit */
+ if(ochp_command==NULL)
+ return ERROR;
+
/* update macros */
clear_volatile_macros();
grab_host_macros(hst);
! /* get the raw command line */
! get_raw_command_line(ochp_command,raw_command_line,sizeof(raw_command_line));
! strip(raw_command_line);
#ifdef DEBUG3
***************
*** 194,198 ****
/* check to see if the command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: OCHP command '%s' for host '%s' timed out after %d seconds\n",ocsp_command,hst->name,ochp_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
--- 186,190 ----
/* check to see if the command timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: OCHP command '%s' for host '%s' timed out after %d seconds\n",processed_command_line,hst->name,ochp_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 319,323 ****
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Global service event handler command '%s' timed out after %d seconds\n",global_service_event_handler,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
--- 311,315 ----
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Global service event handler command '%s' timed out after %d seconds\n",processed_command_line,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 352,355 ****
--- 344,351 ----
#endif
+ /* bail if there's no command */
+ if(svc->event_handler==NULL)
+ return ERROR;
+
/* clear command macros */
clear_argv_macros();
***************
*** 381,385 ****
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Service event handler command '%s' timed out after %d seconds\n",svc->event_handler,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
--- 377,381 ----
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Service event handler command '%s' timed out after %d seconds\n",processed_command_line,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 492,496 ****
/* check for a timeout in the execution of the event handler command */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Global host event handler command '%s' timed out after %d seconds\n",global_host_event_handler,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
--- 488,492 ----
/* check for a timeout in the execution of the event handler command */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Global host event handler command '%s' timed out after %d seconds\n",processed_command_line,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
***************
*** 524,527 ****
--- 520,527 ----
#endif
+ /* bail if there's no command */
+ if(hst->event_handler==NULL)
+ return ERROR;
+
/* clear command macros */
clear_argv_macros();
***************
*** 553,557 ****
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Host event handler command '%s' timed out after %d seconds\n",hst->event_handler,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
--- 553,557 ----
/* check to see if the event handler timed out */
if(early_timeout==TRUE){
! snprintf(temp_buffer,sizeof(temp_buffer),"Warning: Host event handler command '%s' timed out after %d seconds\n",processed_command_line,event_handler_timeout);
temp_buffer[sizeof(temp_buffer)-1]='\x0';
write_to_logs_and_console(temp_buffer,NSLOG_EVENT_HANDLER | NSLOG_RUNTIME_WARNING,TRUE);
Index: utils.c
===================================================================
RCS file: /cvsroot/nagios/nagios/base/utils.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -r1.39 -r1.40
*** utils.c 10 Apr 2003 03:46:01 -0000 1.39
--- utils.c 16 Apr 2003 02:57:36 -0000 1.40
***************
*** 4,8 ****
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-09-2003
*
* License:
--- 4,8 ----
*
* Copyright (c) 1999-2003 Ethan Galstad (nagios@...)
! * Last Modified: 04-15-2003
*
* License:
***************
*** 421,426 ****
selected_macro=macro_x[MACRO_SERVICEEXECUTIONTIME];
! else if(!strcmp(temp_buffer,"HOSTLATENCY"))
! selected_macro=macro_x[MACRO_HOSTLATENCY];
else if(!strcmp(temp_buffer,"HOSTLATENCY"))
--- 421,426 ----
selected_macro=macro_x[MACRO_SERVICEEXECUTIONTIME];
! else if(!strcmp(temp_buffer,"SERVICELATENCY"))
! selected_macro=macro_x[MACRO_SERVICELATENCY];
else if(!strcmp(temp_buffer,"HOSTLATENCY"))
|