shinken-solutions / shinken

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

shinken-discovery AttributeError #1542

Open ryepup opened 9 years ago

ryepup commented 9 years ago

Getting a AttributeError: 'Config' object has no attribute 'create_reversed_list' error when trying to run shinken-discovery. Shinken is a recent installation via pip.

$ shinken-discovery -c /etc/shinken/discovery/discovery.cfg -o /etc/shinken/shared/ -r nmap -m "NMAPTARGETS=localhost"
Macros ['NMAPTARGETS=localhost']
Got macros [('NMAPTARGETS', 'localhost')]
[1426616679] WARNING: [Shinken] There is no arbiter, I add one in localhost:7770
Traceback (most recent call last):
  File "/usr/bin/shinken-discovery", line 144, in <module>
    d = DiscoveryManager(cfg_input, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, backend=backend, modules_path=modules_path, merge=merge)
  File "/usr/local/lib/python2.7/dist-packages/shinken/discovery/discoverymanager.py", line 344, in __init__
    self.conf.create_reversed_list()
AttributeError: 'Config' object has no attribute 'create_reversed_list'

Seems to be discussed a little on this create_reversed_list not defined forum thread, where they trace it to 3e8ab43b712cf32c7243a6d7b60a79baf2411de3.

ryepup commented 9 years ago

looking at the code, I think this might be fixed in the 2.4 release

gst commented 9 years ago

looking at the code, I think this might be fixed in the 2.4 release

yep. well, at least the discovery manager doesn't anymore call this removed function..

shame on the one having removed the function initially but left that call to it from the discovery manager ;)

Seb-Solon commented 9 years ago

Discovery is not really well supported anyway, I'm closing this :)

claneys commented 9 years ago

Well, discovery manager is nice. Why doesn't support it anymore ?

claneys commented 9 years ago

I'll try to make discovery works again. Comment discoverymanager lines that aren't used now, but facing a new exception :

Traceback (most recent call last):
  File "/usr/bin/shinken-discovery", line 144, in <module>
    d = DiscoveryManager(cfg_input, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, backend=backend, modules_path=modules_path, merge=merge)
  File "/usr/lib/python2.6/site-packages/Shinken-2.2_RC1-py2.6.egg/shinken/discovery/discoverymanager.py", line 352, in __init__
    self.conf.is_correct()
  File "/usr/lib/python2.6/site-packages/Shinken-2.2_RC1-py2.6.egg/shinken/objects/config.py", line 1501, in is_correct
    if not cur.is_correct():
  File "/usr/lib/python2.6/site-packages/Shinken-2.2_RC1-py2.6.egg/shinken/objects/item.py", line 1035, in is_correct
    if not i.is_correct():
  File "/usr/lib/python2.6/site-packages/Shinken-2.2_RC1-py2.6.egg/shinken/objects/host.py", line 495, in is_correct
    for c in cls.illegal_object_name_chars:
AttributeError: type object 'Host' has no attribute 'illegal_object_name_chars'

That's weird, illegal_object_name_chars is in Config Class, and I just don't know how that property pass from Config to Host using class_inherit.

claneys commented 9 years ago

Reinstalled version 2.0.3 and still have the error.

  File "/usr/bin/shinken-discovery", line 144, in <module>
    d = DiscoveryManager(cfg_input, macros, overwrite, runners, output_dir=output_dir, dbmod=dbmod, backend=backend, modules_path=modules_path, merge=merge)
  File "/usr/lib/python2.6/site-packages/Shinken-2.0.3-py2.6.egg/shinken/discovery/discoverymanager.py", line 353, in __init__
    self.conf.is_correct()
  File "/usr/lib/python2.6/site-packages/Shinken-2.0.3-py2.6.egg/shinken/objects/config.py", line 1483, in is_correct
    if not cur.is_correct():
  File "/usr/lib/python2.6/site-packages/Shinken-2.0.3-py2.6.egg/shinken/objects/item.py", line 833, in is_correct
    if not i.is_correct():
  File "/usr/lib/python2.6/site-packages/Shinken-2.0.3-py2.6.egg/shinken/objects/host.py", line 476, in is_correct
    for c in cls.illegal_object_name_chars:
AttributeError: type object 'Host' has no attribute 'illegal_object_name_chars'
gst commented 9 years ago

the 'illegal_object_name_chars' attribute is "duplicated/copied" in Host + Service + Contact by this mean actually :

    # We load every useful parameter so no need to access global conf later
    # Must be called after a change in a global conf parameter
    def load_global_conf(cls, conf):
        """ Used to put global values in the sub Class like
        hosts or services """
        # conf have properties, if 'enable_notifications':
        # { [...] 'class_inherit': [(Host, None), (Service, None),
        #  (Contact, None)]}
        # get the name and put the value if None, put the Name
        # (not None) if not (not clear?)
        for prop, entry in conf.properties.items():
            # If we have a class_inherit, and the arbiter really send us it
            # if 'class_inherit' in entry and hasattr(conf, prop):
            if hasattr(conf, prop):
                for (cls_dest, change_name) in entry.class_inherit:
                    if cls_dest == cls:  # ok, we've got something to get
                        value = getattr(conf, prop)
                        if change_name is None:
                            setattr(cls, prop, value)
                        else:
                            setattr(cls, change_name, value)