[Functionality proposal]Service on host override service on host group

nap naparuba at gmail.com
Tue Apr 7 10:05:48 CEST 2009


Hi,

I'm currently writing a patch (too much ugly for posting for the
moment...) for allowing a service define on a host override a service
define on a host group. We can override object property by inheritance
(template, multiple inheritance, ...). But with services define on
hosts groups, we cannot change just one or two services. We can modify
the command to take custom object variables and make exception for a
host, but it's not easy. Ce can use external command, but if you lose
the retention.dat, you loose all exceptions. If we can just add a new
service on the host with the same name, we can simply override the
"host group" service with a new one, and all expetions are in the
configuration.

For example, with the "normal" behavior and this definition (srv-1 in
the host group all-server):

define service{
        use     generic-service
        hostgroup_name       all-server
        service_description     service-test
        check_command   check_ping
}

define service{
        use     generic-service
        host_name       srv-1
        service_description     service-test
        check_command   check_local_disk
}

The check_ping (host group definition) win. Whatever you put the
check_local_disk declaration before or after the check_ping one. This
is because of the skiplist_insert use in
xodtemplate_duplicate_services (xdata/xodtemplate.c, line 5221) : the
configuration reads all services in the configurations file, but with
the xodtemplate_duplicate_service (explode of a service for all hosts
of a hostgroup) (line 5187), the "host group" services are add in the
beginning of the list. So, they are sure to won the skiplist_insert
because the loop add services by the beginning.

I add a is_from_hostgroup boolean parameter to the xodtemplate_service
structure. This parameter is FALSE at the creation, but put in TRUE
while a xodtemplate_duplicate_service. I duplicate the loop that add
services in the skip_list:
*the first loop add only the "host" services (by looking at
is_from_hostgroup==FALSE),
*the second loop add only the "host group" services (by looking at
is_from_hostgroup==TRUE).

With this modification, the "host group" services arrived after the
"host" service, so they loose. check_local_disk win.


What do you think about this override system? I'm need such behavior
in my configuration, so I think more people do.
I know this is not the normal behavior, maybe we can add a new
nagios.cfg "allow_service_hostgroup_override", but I think this can
become the new "standard" behavior some day?

If someone is interested by this patch, I'll clean it and I'll post it.

Thanks,


Gabès Jean

------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com




More information about the Developers mailing list