Page 1 of 1

2 hosts with almost identical names share servicechecks

Posted: Thu Sep 03, 2015 7:10 am
by rhassing
I have defined two hosts:

Code: Select all

define host {
        host_name                       A-ALMEX02
        alias                           Exchange 2010 HUB/CAS ADS
        display_name                    A-ALMEX02
        address                         172.20.0.65
        check_command                   check-host-alive
        initial_state                   o
        max_check_attempts              3
        check_interval                  5
        retry_interval                  1
        active_checks_enabled           1
        passive_checks_enabled          0
        check_period                    24x7
        check_freshness                 1
        event_handler                   host-notify-by-email
        process_perf_data               1
        contact_groups                  Standby_pool2
        notification_interval           15
        notification_period             24x7
        notification_options            d,u,r
        notifications_enabled           1
        register                        1
}

define host {
        host_name                       ALMEX02
        alias                           Exchange 2010 HUB/CAS ADS
        display_name                    ALMEX02
        address                         172.20.4.151
        check_command                   check-host-alive
        initial_state                   o
        max_check_attempts              3
        check_interval                  5
        retry_interval                  1
        active_checks_enabled           1
        passive_checks_enabled          0
        check_period                    24x7
        check_freshness                 1
        event_handler                   host-notify-by-email
        process_perf_data               1
        contact_groups                  Standby_pool2
        notification_interval           15
        notification_period             24x7
        notification_options            d,u,r
        notifications_enabled           1
        register                        1
}
One service check:

Code: Select all

define service {
        #NAGIOSQL_CONFIG_NAME           Disk_usage_D
        host_name                       ALMEX02
        service_description             Disk usage D: - 24x7 Pool 2
        display_name                    Disk usage D: - 24x7 Pool 2
        check_command                   check_snmp_storage!public!^D!90!95
        initial_state                   o
        max_check_attempts              3
        check_interval                  5
        retry_interval                  1
        active_checks_enabled           1
        check_period                    24x7
        check_freshness                 1
        event_handler_enabled           0
        process_perf_data               1
        notification_interval           5
        notification_period             24x7
        notification_options            w,u,c,r,f
        notifications_enabled           1
        contact_groups                  Mail_Standby_Pool_2
        notes_url                       /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$&db=diskgd%2Cbytesfree&db=diskgd%2Cbytesmax&period=day,week,month,year&expand_period=day,week,month,year
        register                        1
}
But still I have the servicecheck on both hosts:
Image

How can this be avoided?

Re: 2 hosts with almost identical names share servicechecks

Posted: Thu Sep 03, 2015 7:14 am
by rhassing
And this is why we don't want it on one host :D
Image

Re: 2 hosts with almost identical names share servicechecks

Posted: Thu Sep 03, 2015 9:48 am
by jdalrymple
I copied and pasted your config into a 4.0.8 (XI 2.7) box and couldn't reproduce the behavior.

I suspect you have some hostgroup foul play going on

Re: 2 hosts with almost identical names share servicechecks

Posted: Thu Sep 03, 2015 9:56 am
by rhassing
I'm using Nagios 4.1.1 in this configuration. I will try to reproduce this as well in a smaller setup.
There are hostgroups defined, but not used for this service.
Both hosts have multiple services defined and also overlapping servicechecks, but this check should exist on just the one host.

Re: 2 hosts with almost identical names share servicechecks

Posted: Thu Sep 03, 2015 10:24 am
by jolson
I tested this on a 4.1.1 box as well:
2015-09-03 10_23_17-Nagios Core - Firefox Developer Edition.png
2015-09-03 10_23_17-Nagios Core - Firefox Developer Edition.png (4.66 KiB) Viewed 2950 times

Re: 2 hosts with almost identical names share servicechecks

Posted: Mon Sep 07, 2015 2:52 am
by rhassing
We found the problem. It seems to be possible to use regular expressions in nagios.cfg. If we turn them off, our problem is solved:

Code: Select all

# REGULAR EXPRESSION MATCHING
# This option controls whether or not regular expression matching
# takes place in the object config files.  Regular expression
# matching is used to match host, hostgroup, service, and service
# group names/descriptions in some fields of various object types.
# Values: 1 = enable regexp matching, 0 = disable regexp matching

use_regexp_matching=0



# "TRUE" REGULAR EXPRESSION MATCHING
# This option controls whether or not "true" regular expression
# matching takes place in the object config files.  This option
# only has an effect if regular expression matching is enabled
# (see above).  If this option is DISABLED, regular expression
# matching only occurs if a string contains wildcard characters
# (* and ?).  If the option is ENABLED, regexp matching occurs
# all the time (which can be annoying).
# Values: 1 = enable true matching, 0 = disable true matching

use_true_regexp_matching=0

Re: 2 hosts with almost identical names share servicechecks

Posted: Tue Sep 08, 2015 9:10 am
by hsmith
rhassing wrote:We found the problem. It seems to be possible to use regular expressions in nagios.cfg. If we turn them off, our problem is solved:

Code: Select all

# REGULAR EXPRESSION MATCHING
# This option controls whether or not regular expression matching
# takes place in the object config files.  Regular expression
# matching is used to match host, hostgroup, service, and service
# group names/descriptions in some fields of various object types.
# Values: 1 = enable regexp matching, 0 = disable regexp matching

use_regexp_matching=0



# "TRUE" REGULAR EXPRESSION MATCHING
# This option controls whether or not "true" regular expression
# matching takes place in the object config files.  This option
# only has an effect if regular expression matching is enabled
# (see above).  If this option is DISABLED, regular expression
# matching only occurs if a string contains wildcard characters
# (* and ?).  If the option is ENABLED, regexp matching occurs
# all the time (which can be annoying).
# Values: 1 = enable true matching, 0 = disable true matching

use_true_regexp_matching=0
Is there anything else we can do to help you out with this issue?

Re: 2 hosts with almost identical names share servicechecks

Posted: Thu Sep 10, 2015 5:25 pm
by rhassing
No, this is solved, thread may be closed :-)