diff --git a/src/naemon/commands.c b/src/naemon/commands.c index 265f4416..4a4d81a3 100644 --- a/src/naemon/commands.c +++ b/src/naemon/commands.c @@ -1687,6 +1687,10 @@ static int global_command_handler(const struct external_command *ext_command, ti /* disabled */ return ERROR; + case CMD_LOG: + nm_log(NSLOG_EXT_CUSTOM, "%s", ext_command->raw_arguments); + return OK; + default: nm_log(NSLOG_RUNTIME_ERROR, "Unknown global command ID %d", ext_command->id); return ERROR; @@ -3293,6 +3297,10 @@ void register_core_commands(void) core_command = command_create("CHANGE_RETRY_HOST_CHECK_INTERVAL", host_command_handler, "Changes the retry check interval for a particular host.", "host=host_name;timestamp=check_interval"); command_register(core_command, CMD_CHANGE_RETRY_HOST_CHECK_INTERVAL); + + core_command = command_create("LOG", global_command_handler, + "Adds custom entry to the default log file.", NULL); + command_register(core_command, CMD_LOG); } /******************************************************************/ @@ -3434,6 +3442,8 @@ int process_external_command(char *cmd, int mode, GError **error) /* passive checks are logged in checks.c as well, as some my bypass external commands by getting dropped in checkresults dir */ if (log_passive_checks == TRUE) nm_log(NSLOG_PASSIVE_CHECK, "%s", temp_buffer); + } else if (id == CMD_LOG) { + /* skip loging same message twice */ } else if (log_external_commands == TRUE) { nm_log(NSLOG_EXTERNAL_COMMAND, "%s", temp_buffer); } diff --git a/src/naemon/common.h b/src/naemon/common.h index cad32e70..b9c65c94 100644 --- a/src/naemon/common.h +++ b/src/naemon/common.h @@ -323,6 +323,8 @@ NAGIOS_END_DECL #define CMD_ACKNOWLEDGE_HOST_PROBLEM_EXPIRE 173 #define CMD_ACKNOWLEDGE_SVC_PROBLEM_EXPIRE 174 +#define CMD_LOG 175 + /* custom command introduced in Nagios 3.x */ #define CMD_CUSTOM_COMMAND 999 diff --git a/src/naemon/logging.h b/src/naemon/logging.h index 087e4118..c9c74bdc 100644 --- a/src/naemon/logging.h +++ b/src/naemon/logging.h @@ -39,6 +39,7 @@ #define NSLOG_HOST_NOTIFICATION 524288 #define NSLOG_SERVICE_NOTIFICATION 1048576 +#define NSLOG_EXT_CUSTOM 2097152 /***************** DEBUGGING LEVELS *******************/ diff --git a/src/naemon/utils.c b/src/naemon/utils.c index 3b984561..30fe54cd 100644 --- a/src/naemon/utils.c +++ b/src/naemon/utils.c @@ -1083,9 +1083,9 @@ int reset_variables(void) log_passive_checks = DEFAULT_LOG_PASSIVE_CHECKS; log_global_notifications = DEFAULT_log_global_notifications; - logging_options = NSLOG_RUNTIME_ERROR | NSLOG_RUNTIME_WARNING | NSLOG_VERIFICATION_ERROR | NSLOG_VERIFICATION_WARNING | NSLOG_CONFIG_ERROR | NSLOG_CONFIG_WARNING | NSLOG_PROCESS_INFO | NSLOG_HOST_NOTIFICATION | NSLOG_SERVICE_NOTIFICATION | NSLOG_EVENT_HANDLER | NSLOG_EXTERNAL_COMMAND | NSLOG_PASSIVE_CHECK | NSLOG_HOST_UP | NSLOG_HOST_DOWN | NSLOG_HOST_UNREACHABLE | NSLOG_SERVICE_OK | NSLOG_SERVICE_WARNING | NSLOG_SERVICE_UNKNOWN | NSLOG_SERVICE_CRITICAL | NSLOG_INFO_MESSAGE; + logging_options = NSLOG_RUNTIME_ERROR | NSLOG_RUNTIME_WARNING | NSLOG_VERIFICATION_ERROR | NSLOG_VERIFICATION_WARNING | NSLOG_CONFIG_ERROR | NSLOG_CONFIG_WARNING | NSLOG_PROCESS_INFO | NSLOG_HOST_NOTIFICATION | NSLOG_SERVICE_NOTIFICATION | NSLOG_EVENT_HANDLER | NSLOG_EXTERNAL_COMMAND | NSLOG_PASSIVE_CHECK | NSLOG_HOST_UP | NSLOG_HOST_DOWN | NSLOG_HOST_UNREACHABLE | NSLOG_SERVICE_OK | NSLOG_SERVICE_WARNING | NSLOG_SERVICE_UNKNOWN | NSLOG_SERVICE_CRITICAL | NSLOG_INFO_MESSAGE | NSLOG_EXT_CUSTOM; - syslog_options = NSLOG_RUNTIME_ERROR | NSLOG_RUNTIME_WARNING | NSLOG_VERIFICATION_ERROR | NSLOG_VERIFICATION_WARNING | NSLOG_CONFIG_ERROR | NSLOG_CONFIG_WARNING | NSLOG_PROCESS_INFO | NSLOG_HOST_NOTIFICATION | NSLOG_SERVICE_NOTIFICATION | NSLOG_EVENT_HANDLER | NSLOG_EXTERNAL_COMMAND | NSLOG_PASSIVE_CHECK | NSLOG_HOST_UP | NSLOG_HOST_DOWN | NSLOG_HOST_UNREACHABLE | NSLOG_SERVICE_OK | NSLOG_SERVICE_WARNING | NSLOG_SERVICE_UNKNOWN | NSLOG_SERVICE_CRITICAL | NSLOG_INFO_MESSAGE; + syslog_options = NSLOG_RUNTIME_ERROR | NSLOG_RUNTIME_WARNING | NSLOG_VERIFICATION_ERROR | NSLOG_VERIFICATION_WARNING | NSLOG_CONFIG_ERROR | NSLOG_CONFIG_WARNING | NSLOG_PROCESS_INFO | NSLOG_HOST_NOTIFICATION | NSLOG_SERVICE_NOTIFICATION | NSLOG_EVENT_HANDLER | NSLOG_EXTERNAL_COMMAND | NSLOG_PASSIVE_CHECK | NSLOG_HOST_UP | NSLOG_HOST_DOWN | NSLOG_HOST_UNREACHABLE | NSLOG_SERVICE_OK | NSLOG_SERVICE_WARNING | NSLOG_SERVICE_UNKNOWN | NSLOG_SERVICE_CRITICAL | NSLOG_INFO_MESSAGE | NSLOG_EXT_CUSTOM; service_check_timeout = DEFAULT_SERVICE_CHECK_TIMEOUT; host_check_timeout = DEFAULT_HOST_CHECK_TIMEOUT;