--=-tV3sxgjzR8AryglYGZQh
Content-Type: text/plain
Content-Transfer-Encoding: 7bit
Followup patch from the discussion a week ago about having nagios not
die on HUP when the configs contain errors.
This patch does a few things, but mainly adds a function similar to
xodtemplate_cache_objects which stores the running config in it's own
'running_config.cache' file. This requires reading a few more config
options from nagios.cfg into memory first, but has the benefit of adding
some sanity checking to them which didn't exist in the xdata/ functions
which reference them. It should also keep an invalid 'objects.cache'
from being written which the cgis could try to read and error out.
So on a HUP from the web interface or command line, if a config error is
encountered in the main nagios.cfg, it will print the problems and an
error about not being able to load the new config to the log and
console, then read 'running_config.cache' and 'objects.cache' back into
memory and keep going. If the error is just in the object definitions,
the new config will be read in and used, while the objects will come
from the cache.
The more I think about it, the more I believe this is a good
feature/behaviour, if there's anything as an admin you don't want
stopped it's probably your monitoring.
Patch is against latest cvs. 2nd patch for documentation included as
well.
--
Matthew Kent
http://magoazul.com
--=-tV3sxgjzR8AryglYGZQh
Content-Disposition: attachment; filename=nagios-2.0a1-safe_reload.patch
Content-Type: text/x-patch; name=nagios-2.0a1-safe_reload.patch; charset=ANSI_X3.4-1968
Content-Transfer-Encoding: 7bit
diff -u3 -r nagios_orig/base/config.c nagios/base/config.c
--- nagios_orig/base/config.c 2004-11-09 22:55:15.000000000 -0500
+++ nagios/base/config.c 2004-11-10 23:28:06.000000000 -0500
@@ -55,6 +55,19 @@
extern char *illegal_object_chars;
extern char *illegal_output_chars;
+extern char *broker_module;
+
+extern char *status_file;
+extern char *comment_file;
+extern char *downtime_file;
+extern char *host_perfdata_command;
+extern char *service_perfdata_command;
+extern char *state_retention_file;
+extern char *object_cache_file;
+extern char *running_config_cache_file;
+
+extern int perfdata_timeout;
+
extern int use_regexp_matches;
extern int use_true_regexp_matching;
@@ -175,10 +188,9 @@
/******************************************************************/
/* read all configuration data */
-int read_all_object_data(char *main_config_file){
+int read_all_object_data(char *main_config_file,int cache){
int result=OK;
int options;
- int cache=FALSE;
#ifdef DEBUG0
printf("read_all_config_data() start\n");
@@ -186,10 +198,6 @@
options=READ_ALL_OBJECT_DATA;
- /* cache object definitions if we're up and running */
- if(verify_config==FALSE && test_scheduling==FALSE)
- cache=TRUE;
-
/* read in all host configuration data from external sources */
result=read_object_config_data(main_config_file,options,cache);
if(result!=OK)
@@ -1378,6 +1386,8 @@
#endif
}
else if(!strcmp(variable,"broker_module")){
+ broker_module=strdup(value);
+
modptr=strtok(value," \n");
argptr=strtok(NULL,"\n");
#ifdef USE_EVENT_BROKER
@@ -1415,26 +1425,155 @@
printf("\t\tauth_file set to '%s'\n",auth_file);
#endif
}
+ else if(!strcmp(variable,"status_file")){
+ if(strlen(value)>MAX_FILENAME_LENGTH-1){
+ strcpy(error_message,"Status file is too long");
+ error=TRUE;
+ break;
+ }
+
+ if(status_file!=NULL)
+ free(status_file);
+ status_file=(char *)strdup(value);
+ strip(status_file);
+#ifdef DEBUG1
+ printf("\t\tstatus_file set to '%s'\n",status_file);
+#endif
+ }
+ else if(!strcmp(variable,"comment_file")){
+ if(strlen(value)>MAX_FILENAME_LENGTH-1){
+ strcpy(error_message,"Comment file is too long");
+ error=TRUE;
+ break;
+ }
+
+ if(comment_file!=NULL)
+ free(comment_file);
+ comment_file=(char *)strdup(value);
+ strip(comment_file);
+#ifdef DEBUG1
+ printf("\t\tcomment_file set to '%s'\n",comment_file);
+#endif
...[email truncated]...
This post was automatically imported from historical nagios-devel mailing list archives
Original poster: [email protected]