Skip to content
This repository has been archived by the owner on Jan 15, 2019. It is now read-only.

[dev.icinga.com #1737] log error on non-existing host/service/contact/*group when sending a command to the core #689

Closed
icinga-migration opened this issue Jul 21, 2011 · 8 comments

Comments

@icinga-migration
Copy link

This issue has been migrated from Redmine: https://dev.icinga.com/issues/1737

Created by mfriedrich on 2011-07-21 06:58:10 +00:00

Assignee: mfriedrich
Status: Resolved (closed on 2011-11-01 11:56:50 +00:00)
Target Version: 1.6
Last Update: 2011-12-03 11:30:13 +00:00 (in Redmine)


like this is happening for passive check results. but it would be great adding such a note to syslog/debuglog too e.g. when setting a scheduled downtime.

happened today, that the try was logged, but the fail was silent.

Changesets

2011-10-20 11:13:40 +00:00 by mfriedrich ffa2c8a

* core: log error on non-existing host/service/contact/*group when sending a command to the core #1737

this adds a bunch of logit functions into conditions
which would just return a plain ERROR. there isn't a
generic solution yet, so we need to handle that within
each cmd function themselves.

refs #1737

Relations:

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-07-21 07:00:18 +00:00

best would be to create a generic function, which is added once and can be extended once (e.g. like issue #638 )

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-08-23 08:53:01 +00:00

  • Status changed from New to Assigned
  • Assigned to set to mfriedrich
  • Target Version set to 1.6

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-10-06 15:00:32 +00:00

somehow like this.

logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Could not find host '%s' provided in external command!\n", temp_file);

logit(NSLOG_RUNTIME_ERROR, TRUE, "Error: Could not find host '%s' and service '%s' provided in external command!\n", temp_file);

question remains what type of error that would be. furthermore, where to output that.

int process_host_command(int cmd, time_t entry_time, char *args) {

        /* find the host */
        if ((temp_host = find_host(host_name)) == NULL)
                return ERROR;

int process_hostgroup_command(int cmd, time_t entry_time, char *args) {

        /* find the hostgroup */
        if ((temp_hostgroup = find_hostgroup(hostgroup_name)) == NULL)
                return ERROR;

int process_service_command(int cmd, time_t entry_time, char *args) {

        /* find the service */
        if ((temp_service = find_service(host_name, svc_description)) == NULL)
                return ERROR;

int process_servicegroup_command(int cmd, time_t entry_time, char *args) {
        /* find the servicegroup */
        if ((temp_servicegroup = find_servicegroup(servicegroup_name)) == NULL)
                return ERROR;

int process_contact_command(int cmd, time_t entry_time, char *args) {

        /* find the contact */
        if ((temp_contact = find_contact(contact_name)) == NULL)
                return ERROR;

int process_contactgroup_command(int cmd, time_t entry_time, char *args) {

        /* find the contactgroup */
        if ((temp_contactgroup = find_contactgroup(contactgroup_name)) == NULL)
                return ERROR;

and possible all add functions.

int cmd_add_comment(int cmd, time_t entry_time, char *args) {

                /* verify that the service is valid */
                if ((temp_service = find_service(host_name, svc_description)) == NULL)
                        return ERROR;

        /* else verify that the host is valid */
        if ((temp_host = find_host(host_name)) == NULL)
                return ERROR;

int cmd_delete_all_comments(int cmd, char *args) {

                /* verify that the service is valid */
                if ((temp_service = find_service(host_name, svc_description)) == NULL)
                        return ERROR;


        /* else verify that the host is valid */
        if ((temp_host = find_host(host_name)) == NULL)
                return ERROR;

and so on ... basically full base/commands.c requires the checkings for valid hosts/services/contacts instead of just returning plain ERROR.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-10-09 19:17:58 +00:00

the output could be generated like done in the check result reaper.

                        /* make sure the service exists */
                        if ((temp_service = find_service(queued_check_result->host_name, queued_check_result->service_description)) == NULL) {

                                logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Check result queue contained results for service '%s' on host '%s', but the service could not be found!  Perhaps you forgot to define the service in your config files?\n", queued_check_result->service_description, queued_check_result->host_name);

                                /* free memory */
                                free_check_result(queued_check_result);
                                my_free(queued_check_result);

                                /* TODO - add new service definition automatically */

                                continue;
                        }

                        if ((temp_host = find_host(queued_check_result->host_name)) == NULL) {

                                /* make sure the host exists */
                                logit(NSLOG_RUNTIME_WARNING, TRUE, "Warning: Check result queue contained results for host '%s', but the host could not be found!  Perhaps you forgot to define the host in your config files?\n", queued_check_result->host_name);

                                /* free memory */
                                free_check_result(queued_check_result);
                                my_free(queued_check_result);

                                /* TODO - add new host definition automatically */

                                continue;
                        }

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-10-20 11:11:41 +00:00

  • Category set to Commands

tests

# vim test_extcommand_1737.sh

#!/bin/sh
# Adjust variables to fit your environment as necessary.

now=`date +%s`
commandfile='/var/icinga/rw/icinga.cmd'

/usr/bin/printf "[%lu] ACKNOWLEDGE_HOST_PROBLEM;Host1;1;1;1;John Doe;Some comment\n" $now > $commandfile


# sh test_extcommand_1737.sh

log

Oct 20 13:10:05 imagine icinga: EXTERNAL COMMAND: ACKNOWLEDGE_HOST_PROBLEM;Host1;1;1;1;John Doe;Some comment
Oct 20 13:10:05 imagine icinga: Error: Could not find host 'Host1' provided in external command!

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-10-20 11:12:50 +00:00

  • Subject changed from warn about wrong host/service when sending a command to the core to log error on non-existing host/service/contact/*group when sending a command to the core

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-10-20 11:16:11 +00:00

  • Status changed from Assigned to Feedback
  • Done % changed from 0 to 100

pushed to dev/core, waiting for further tests.

@icinga-migration
Copy link
Author

Updated by mfriedrich on 2011-11-01 11:56:50 +00:00

  • Status changed from Feedback to Resolved

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant