Alignak-monitoring-contrib / alignak-module-snmp-booster

Alignak SNMP booster module
GNU Affero General Public License v3.0
0 stars 3 forks source link

SnmpBoosterScheduler raise 'unicode' object has no attribute 'host' #1

Open fpeyre opened 7 years ago

fpeyre commented 7 years ago

I use the snmpbooster and the service uses it stay at Unknown.

When i see the log of the scheduler, i have the following error:

[2016-11-22 16:37:01 UTC] ERROR: [alignak.scheduler] Exception trace follows: Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/alignak/scheduler.py", line 542, in hook_point
    fun(self)
  File "/usr/local/lib/python2.7/dist-packages/alignak_module_snmp_booster-0.1.0-py2.7.egg/alignak_module_snmp_booster/snmpbooster_scheduler.py", line 153, in hook_get_new_actions
    and c.status == 'scheduled']
AttributeError: 'unicode' object has no attribute 'host'

Here is the line incriminate :

   check_by_host_inter = [((c.ref.host.get_name(),
                                 self.get_frequence(c)
                                 ),
                                c)
                               for c in sche.checks.values()
                               if c.module_type == 'snmp_booster'
and c.status == 'scheduled']

Alignak maybe introduce a change in sche.checks.values() object.

I will investigate to find what change is it change and make a pull request in consequence

EDIT: Ok I have the diff. It is in alignak/checks/objects/check.py In shinken, ref is an integer (https://github.com/naparuba/shinken/blob/1bc52cb/shinken/check.py#L50) In Alignak, ref is a string ( https://github.com/Alignak-monitoring/alignak/blob/e417b92/alignak/action.py#L133

mohierf commented 7 years ago

You got it @fpeyre

Shinken often used some objects, whether Alignak uses an object uuid defined in the AlignakObject class. You can use this uuid as an index in the objects lists (eg. sched.hosts[ref] if ref is an uuid)