shinken-solutions / shinken

Flexible and scalable monitoring framework
http://www.shinken-monitoring.org
GNU Affero General Public License v3.0
1.14k stars 335 forks source link

Service dependency failing because no host_name declared (hostgroup_name present) #418

Closed darksoul42 closed 12 years ago

darksoul42 commented 12 years ago

I seem to have stumbled upon something similar to issue #28, but with service dependencies.

CRITICAL ERROR: I got an unrecoverable error. I have to exit You can log a bug ticket at https://github.com/naparuba/shinken/issues/new to get help Back trace of it: Traceback (most recent call last): File "/tmp/shinken-1.0.1/shinken/daemons/arbiterdaemon.py", line 455, in main self.load_config_file() File "/tmp/shinken-1.0.1/shinken/daemons/arbiterdaemon.py", line 332, in load_config_file self.conf.explode() File "/tmp/shinken-1.0.1/shinken/objects/config.py", line 828, in explode self.servicedependencies.explode(self.hostgroups) File "/tmp/shinken-1.0.1/shinken/objects/servicedependency.py", line 111, in explode sd.dependent_host_name = sd.host_name AttributeError: 'Servicedependency' object has no attribute 'host_name'

Most of my service dependencies are declared this way and this verifies in Nagios :

define servicedependency { hostgroup_name my_hostgroup dependent_service_description myChildService service_description myParentService execution_failure_criteria u notification_failure_criteria u }

naparuba commented 12 years ago

Should be fixed in the lastest code. Can you give a try?

darksoul42 commented 12 years ago

Latest contents of git repository give the following trace:

[1342103144] Critical: I got an unrecoverable error. I have to exit [1342103144] Critical: You can log a bug ticket at https://github.com/naparuba/shinken/issues/new to get help [1342103144] Critical: Back trace of it: Traceback (most recent call last): File "/home/darksoul/shinken/shinken/daemons/arbiterdaemon.py", line 477, in main self.load_config_file() File "/home/darksoul/shinken/shinken/daemons/arbiterdaemon.py", line 317, in load_config_file self.conf.explode() File "/home/darksoul/shinken/shinken/objects/config.py", line 875, in explode self.servicedependencies.explode(self.hostgroups) File "/home/darksoul/shinken/shinken/objects/servicedependency.py", line 144, in explode hnames.extend(hg.members.split(',')) AttributeError: 'Hostgroup' object has no attribute 'members'

Traceback (most recent call last): File "/home/darksoul/shinken/bin/../bin/shinken-arbiter", line 107, in daemon.main() File "/home/darksoul/shinken/shinken/daemons/arbiterdaemon.py", line 477, in main self.load_config_file() File "/home/darksoul/shinken/shinken/daemons/arbiterdaemon.py", line 317, in load_config_file self.conf.explode() File "/home/darksoul/shinken/shinken/objects/config.py", line 875, in explode self.servicedependencies.explode(self.hostgroups) File "/home/darksoul/shinken/shinken/objects/servicedependency.py", line 144, in explode hnames.extend(hg.members.split(',')) AttributeError: 'Hostgroup' object has no attribute 'members'

Again, with a configuration that is recognized by Nagios 3.3.1. It is a bit jarring that the trace does not indicate "which" hostgroup is concerned (in which file, which line).

I create : 1) a hostgroup "my-group" (no explicit members) 2) a host template that will declare membership to above group using a "hostgroups +my-group" 3) services that declare membership to above group using "hostgroup_name my-group"

The result is a minimal host config file, let's say "hostname.cfg" :

define host { use hardware-dell-1850,os-redhat-linux,app-dell-omsa,app-linux-mdraid,app-http,app-syslog host_name hostname alias hostname.domain address x.y.z.w }

Templates for "hardware-dell-1850", "os-redhat-linux", "app-dell-omsa", "app-linux-mdraid", "app-http", "app-syslog" are created as follows : define hostgroup { hostgroup_name app-http alias HTTP enabled servers }

define host { use generic-host name app-http hostgroups +app-http register 0 # Not a true host, just a template }

define service { use generic-service hostgroup_name app-http service_description HTTP servicegroups http-service check_command check_http }

This does mean however that if a service template does not find any host requiring it (i.e belonging to "my-group"), even Nagios will blow up saying it can't find any members.

I think I might be misunderstanding in the first place how service templates should be used in conjunction with groups, and what is already borderline for Nagios ends up being completely confusing for Shinken. (If the service is declared as a template, then it is never instantiated, and I don't want to instantiate it for each of the N hundred servers we are handling :/)

naparuba commented 12 years ago

Hi,

I create a test case with your configuration, and it work. The only difference I put is to change the : register 0 # comment by a register 0 ; comment

Then all is ok, and the hostname/HTTP service is created.

Can you give a try with the ; thing? Thanks.

darksoul42 commented 12 years ago

Sorry for the late answer. I checked with ";" for the comments after "register" and it works. (as per issue 445)

naparuba commented 12 years ago

Ok great, so I close :)