Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into almostcore
Browse files Browse the repository at this point in the history
Conflicts:
	base/config.c
	common/macros.c
  • Loading branch information
willixix committed Nov 11, 2012
2 parents 4f43575 + f13adfa commit 73eba36
Show file tree
Hide file tree
Showing 48 changed files with 1,906 additions and 872 deletions.
12 changes: 7 additions & 5 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -328,17 +328,19 @@ install-commandmode:
@echo ""


install-devel: lib/libnagios.a
install-devel: install-headers install-lib

install-headers:
$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)
$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/lib
$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 lib/libnagios.a $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 include/*.h $(DESTDIR)$(INCLUDEDIR)
$(INSTALL) -m 644 lib/*.h $(DESTDIR)$(INCLUDEDIR)/lib
# this file isn't needed and will most likely conflict with
# other packages.
rm -f $(DESTDIR)$(INCLUDEDIR)/nagios/config.h

install-lib: $(SRC_LIB)/libnagios.a
$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
$(INSTALL) -m 644 $(SRC_LIB)/libnagios.a $(DESTDIR)$(LIBDIR)

dox:
@rm -rf Documentation
doxygen doxy.conf
Expand Down
1 change: 1 addition & 0 deletions THANKS
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ since 1999. If I missed your name, let me know.
* Nate Shafer
* Moshe Sharon
* Andy Shellam
* Hayakawa Shinya
* Nick Shore
* Ryan Skorstad
* Michael Smedius
Expand Down
17 changes: 4 additions & 13 deletions base/checks.c
Original file line number Diff line number Diff line change
Expand Up @@ -1332,9 +1332,12 @@ void check_for_orphaned_services(void) {
if(expected_time < current_time) {

/* log a warning */
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: The check of service '%s' on host '%s' looks like it was orphaned (results never came back). I'm scheduling an immediate check of the service...\n", temp_service->description, temp_service->host_name);
logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: The check of service '%s' on host '%s' looks like it was orphaned (results never came back; last_check=%lu; next_check=%lu). I'm scheduling an immediate check of the service...\n", temp_service->description, temp_service->host_name, temp_service->last_check, temp_service->next_check);

log_debug_info(DEBUGL_CHECKS, 1, "Service '%s' on host '%s' was orphaned, so we're scheduling an immediate check...\n", temp_service->description, temp_service->host_name);
log_debug_info(DEBUGL_CHECKS, 1, " next_check=%lu (%s); last_check=%lu (%s);\n",
temp_service->next_check, ctime(&temp_service->next_check),
temp_service->last_check, ctime(&temp_service->last_check));

/* decrement the number of running service checks */
if(currently_running_service_checks > 0)
Expand Down Expand Up @@ -1526,18 +1529,6 @@ int is_service_result_fresh(service *temp_service, time_t current_time, int log_
/*************** COMMON ROUTE/HOST CHECK FUNCTIONS ****************/
/******************************************************************/

/* execute a scheduled host check using either the 2.x or 3.x logic */
int perform_scheduled_host_check(host *hst, int check_options, double latency) {

log_debug_info(DEBUGL_FUNCTIONS, 0, "perform_scheduled_host_check()\n");

run_scheduled_host_check(hst, check_options, latency);

return OK;
}



/* schedules an immediate or delayed host check */
void schedule_host_check(host *hst, time_t check_time, int options) {
timed_event *temp_event = NULL;
Expand Down
1 change: 1 addition & 0 deletions base/commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ int launch_command_file_worker(void) {
goto err_close;
}
command_wproc->type = "command file";
command_wproc->source_name = "command file";
command_wproc->ioc = iocache_create(512 * 1024);
if (!command_wproc->ioc) {
logit(NSLOG_RUNTIME_ERROR, TRUE, "Failed to create I/O cache for command file worker: %m\n");
Expand Down
98 changes: 53 additions & 45 deletions base/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,12 +163,14 @@ int read_main_config_file(char *main_config_file) {

/* save the macro */
my_free(mac->x[MACRO_RESOURCEFILE]);
mac->x[MACRO_RESOURCEFILE] = (char *)strdup(value);
mac->x[MACRO_RESOURCEFILE] = nspath_absolute(value, config_file_dir);

/* process the resource file */
read_resource_file(value);
read_resource_file(mac->x[MACRO_RESOURCEFILE]);
}

else if(!strcmp(variable, "loadctl_options"))
error = set_loadctl_options(value, strlen(value)) != OK;
else if(!strcmp(variable, "check_workers"))
num_check_workers = atoi(value);
else if(!strcmp(variable, "query_socket"))
Expand All @@ -182,7 +184,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(log_file);
log_file = (char *)strdup(value);
log_file = nspath_absolute(value, config_file_dir);

/* save the macro */
my_free(mac->x[MACRO_LOGFILE]);
Expand All @@ -204,7 +206,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(debug_file);
debug_file = (char *)strdup(value);
debug_file = nspath_absolute(value, config_file_dir);
}

else if(!strcmp(variable, "max_debug_file_size"))
Expand All @@ -219,7 +221,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(command_file);
command_file = (char *)strdup(value);
command_file = nspath_absolute(value, config_file_dir);

/* save the macro */
my_free(mac->x[MACRO_COMMANDFILE]);
Expand All @@ -235,7 +237,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(temp_file);
temp_file = (char *)strdup(value);
temp_file = nspath_absolute(value, config_file_dir);

/* save the macro */
my_free(mac->x[MACRO_TEMPFILE]);
Expand All @@ -250,21 +252,19 @@ int read_main_config_file(char *main_config_file) {
break;
}

if((tmpdir = opendir((char *)value)) == NULL) {
(void)asprintf(&error_message, "Temp path is not a valid directory");
my_free(temp_path);
temp_path = nspath_absolute(value, config_file_dir);
/* make sure we don't have a trailing slash */
if(temp_path[strlen(temp_path) - 1] == '/')
temp_path[strlen(temp_path) - 1] = '\x0';

if((tmpdir = opendir(temp_path)) == NULL) {
asprintf(&error_message, "Temp path '%s' is not a valid directory", temp_path);
error = TRUE;
break;
}
closedir(tmpdir);

my_free(temp_path);
if((temp_path = (char *)strdup(value))) {
strip(temp_path);
/* make sure we don't have a trailing slash */
if(temp_path[strlen(temp_path) - 1] == '/')
temp_path[strlen(temp_path) - 1] = '\x0';
}

/* save the macro */
my_free(mac->x[MACRO_TEMPPATH]);
mac->x[MACRO_TEMPPATH] = (char *)strdup(temp_path);
Expand All @@ -278,23 +278,19 @@ int read_main_config_file(char *main_config_file) {
break;
}

if((tmpdir = opendir((char *)value)) == NULL) {
(void)asprintf(&error_message, "Check result path is not a valid directory");
my_free(check_result_path);
check_result_path = nspath_absolute(value, config_file_dir);
/* make sure we don't have a trailing slash */
if(check_result_path[strlen(check_result_path) - 1] == '/')
check_result_path[strlen(check_result_path) - 1] = '\x0';

if((tmpdir = opendir(check_result_path)) == NULL) {
asprintf(&error_message, "Check result path '%s' is not a valid directory", check_result_path);
error = TRUE;
break;
}
closedir(tmpdir);

my_free(temp_path);
if((temp_path = (char *)strdup(value))) {
strip(temp_path);
/* make sure we don't have a trailing slash */
if(temp_path[strlen(temp_path) - 1] == '/')
temp_path[strlen(temp_path) - 1] = '\x0';
}

my_free(check_result_path);
check_result_path = (char *)strdup(temp_path);
}

else if(!strcmp(variable, "max_check_result_file_age"))
Expand All @@ -309,7 +305,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(lock_file);
lock_file = (char *)strdup(value);
lock_file = nspath_absolute(value, config_file_dir);
}

else if(!strcmp(variable, "global_host_event_handler")) {
Expand Down Expand Up @@ -444,16 +440,16 @@ int read_main_config_file(char *main_config_file) {
log_initial_states = (atoi(value) > 0) ? TRUE : FALSE;
}

else if(!strcmp(variable, "log_current_states")) {
else if(!strcmp(variable, "log_current_states")) {

if(strlen(value) != 1 || value[0] < '0' || value[0] > '1') {
asprintf(&error_message, "Illegal value for log_current_states");
error = TRUE;
break;
}
if(strlen(value) != 1 || value[0] < '0' || value[0] > '1') {
asprintf(&error_message, "Illegal value for log_current_states");
error = TRUE;
break;
}

log_current_states = (atoi(value) > 0) ? TRUE : FALSE;
}
log_current_states = (atoi(value) > 0) ? TRUE : FALSE;
}

else if(!strcmp(variable, "retain_state_information")) {

Expand Down Expand Up @@ -710,7 +706,7 @@ int read_main_config_file(char *main_config_file) {
}

my_free(log_archive_path);
log_archive_path = (char *)strdup(value);
log_archive_path = nspath_absolute(value, config_file_dir);
}

else if(!strcmp(variable, "enable_event_handlers"))
Expand Down Expand Up @@ -1141,10 +1137,16 @@ int read_main_config_file(char *main_config_file) {
continue;
else if(strstr(input, "state_retention_file=") == input)
continue;
else if(strstr(input, "object_cache_file=") == input)
object_cache_file = (char *)strdup(value);
else if(strstr(input, "precached_object_file=") == input)
object_precache_file = (char *)strdup(value);
else if(strstr(input, "object_cache_file=") == input) {
my_free(object_cache_file);
object_cache_file = nspath_absolute(value, config_file_dir);
my_free(mac->x[MACRO_OBJECTCACHEFILE]);
mac->x[MACRO_OBJECTCACHEFILE] = strdup(object_cache_file);
}
else if(strstr(input, "precached_object_file=") == input) {
my_free(object_precache_file);
object_precache_file = nspath_absolute(value, config_file_dir);
}
else if(!strcmp(variable, "allow_empty_hostgroup_assignment")) {
allow_empty_hostgroup_assignment = (atoi(value) > 0) ? TRUE : FALSE;
}
Expand Down Expand Up @@ -1401,6 +1403,12 @@ int pre_flight_check(void) {
logit(NSLOG_VERIFICATION_WARNING, TRUE, "%s", "Warning: Nothing specified for illegal_macro_output_chars variable!\n");
warnings++;
}
else {
char *p;
for(p = illegal_output_chars; *p; p++) {
illegal_output_char_map[(int)*p] = 1;
}
}

if(verify_config) {
printf("\n");
Expand All @@ -1420,13 +1428,13 @@ int pre_flight_check(void) {

printf("Timing information on configuration verification is listed below.\n\n");

printf("CONFIG VERIFICATION TIMES (* = Potential for speedup with -x option)\n");
printf("CONFIG VERIFICATION TIMES\n");
printf("----------------------------------\n");
printf("Object Relationships: %.6lf sec\n", runtime[0]);
printf("Circular Paths: %.6lf sec *\n", runtime[1]);
printf("Circular Paths: %.6lf sec\n", runtime[1]);
printf("Misc: %.6lf sec\n", runtime[2]);
printf(" ============\n");
printf("TOTAL: %.6lf sec * = %.6lf sec (%.1f%%) estimated savings\n", runtime[3], runtime[1], (runtime[1] / runtime[3]) * 100.0);
printf("TOTAL: %.6lf sec\n", runtime[3]);
printf("\n\n");
}

Expand Down
Loading

0 comments on commit 73eba36

Please sign in to comment.