shinken-monitoring / mod-livestatus

Shinken module for presenting data with a MK/Livestatus comptabile interface
GNU Affero General Public License v3.0
15 stars 20 forks source link

contacts: cannot get 'host_notification_period' and 'service_notification_period' to str #54

Closed wenxin-wang closed 9 years ago

wenxin-wang commented 9 years ago

Hi all, When I tried this:

GET contacts
Columns name host_notification_period

I got this:

admin;<object object at 0x7f2ad643c290>
check_mk;24X7
guest;<object object at 0x7f2ad643c270>

And that couldn't be jsonify:

[1428135707] ERROR: [broker-master] Unexpected error: <object object at 0x7f851cc14290> is not JSON serializable ; traceback: Traceback (most recent call last):

Here's my configs:

define contact{
    use                 generic-contact
    contact_name        guest
    email               guest@localhost
    password            whatever
    can_submit_commands 0
}

define contact{
        name                            generic-contact
        register                        0
        host_notifications_enabled      1
        service_notifications_enabled   1
        email                           shinken@localhost
        can_submit_commands             1
        notificationways                email
}

define notificationway{
       notificationway_name            email
       service_notification_period     24x7
       host_notification_period        24x7
       service_notification_options    c,w,r
       host_notification_options       d,u,r,f,s
       service_notification_commands   notify-service-by-email ; send service notifications via email
       host_notification_commands      notify-host-by-email    ; send host notifications via email
}

I found these lines in mappings.py

'host_notification_period': {
    'description': 'The time period in which the contact will be notified about host problems',
    'function': lambda item, req: item.host_notification_period.get_name(),
},

And the lambda returns the same (troublesome) object as above.

So it seems that it's not a livestatus bug, but shinken fails to get those periods right from conctact configurations. But just to make sure, I create a issue here.

By the way, currently shinken allows multiple notificationways in one contact configuration. So which one of the host_notification_periods (and other stuffs) do we get?

ryepup commented 9 years ago

I think #47 is the same problem

wenxin-wang commented 9 years ago

Yes, agreed. I noticed that post right after open this issue. So I'll close this issue and point it to #47.