Results 1 to 8 of 8

Thread: [RESOLVED] Livestatus with mongologs

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Location
    Russia, Ekaterinburg
    Posts
    22

    [RESOLVED] Livestatus with mongologs

    Hi.
    Shinken 1.2.4 with mongologs. Multisite ?heck_MK-1.2.0p4 not show logs.

    I tried to get the logs manually:
    #!/usr/bin/python
    # -*- encoding: utf-8; py-indent-offset: 4 -*-
    import livestatus

    def get_logs():
    connection_to_livestatus = livestatus.SingleSiteConnection("tcp:127.0.0. 1:50000&quot
    logs = connection_to_livestatus.query_table(
    "GET log\n"
    "Columns: class message\n"
    "Filter: log_time >= 1359269773\n"
    "Filter: host_name = localhost\n"
    "ResponseHeader: fixed16\n"
    "Limit: 501\n&quot
    return logs

    logs = get_logs()
    for line in logs:
    print line
    And here they are:
    [3, u'[1362018949] SERVICE NOTIFICATION: admin;localhost;NetworkUsage;CRITICAL;notify-service-by-email;eth0:UP (0.0Mbps/0.0Mbps/0.0/0.0/0.0/0.0), eth1OWN: 1 int NOK : CRITICAL']
    [3, u'[1362018949] SERVICE NOTIFICATION: guest;localhost;NetworkUsage;CRITICAL;notify-service-by-email;eth0:UP (0.0Mbps/0.0Mbps/0.0/0.0/0.0/0.0), eth1OWN: 1 int NOK : CRITICAL']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Cpu;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Load;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Memory;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;NetworkUsage;2;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Load;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Memory;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Cpu;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019164] SERVICE ALERT: localhost;Load;OK;SOFT;2;Load : 0.25 0.12 0.07 : OK']
    [1, u'[1362019297] SERVICE ALERT: localhost;Memory;OK;SOFT;2;Ram : 12%, Swap : 0% : ; OK']
    [1, u'[1362019322] SERVICE ALERT: localhost;Cpu;OK;SOFT;2;4 CPU, average load 1.5% < 80% : OK']
    but if I enable "Filter: class = 3"
    #!/usr/bin/python
    # -*- encoding: utf-8; py-indent-offset: 4 -*-
    import livestatus

    def get_logs():
    connection_to_livestatus = livestatus.SingleSiteConnection("tcp:127.0.0. 1:50000&quot
    logs = connection_to_livestatus.query_table(
    "GET log\n"
    "Columns: class message\n"
    "Filter: log_time >= 1359269773\n"
    "Filter: host_name = localhost\n"
    "Filter: class = 3\n"
    "ResponseHeader: fixed16\n"
    "Limit: 501\n&quot
    return logs

    logs = get_logs()
    for line in logs:
    print line
    I get no logs in result

    I have no problem with logsqlite.

    Thanks for help.

  2. #2
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,130

    Re: Livestatus with mongologs

    What means class = 3?
    No direct support by personal message. Please open a thread so everyone can see the solution

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Location
    Russia, Ekaterinburg
    Posts
    22

    Re: Livestatus with mongologs

    Sorry, I described the problem is not fully.

    The class of the message as integer (0:info, 1:state, 2rogram, 3:notification, 4assive, 5:command)
    Multisite to get logs, events, notifications use filter:
    "Filter: class = 1\n"
    "Filter: class = 3\n"
    "Or: 2\n"
    No matter what the class is selected(from 0 to 5), when I check manually. I do not get logs.
    It doesn't work if i use:
    Filter: class > 0
    Or:
    Filter: class < 5 0
    But I get log with filter:
    Filter: class != 3

    I think that value of the class is not integer.

  4. #4
    Junior Member
    Join Date
    Oct 2012
    Location
    Russia, Ekaterinburg
    Posts
    22

    Re: Livestatus with mongologs

    Hi again.
    I was wrong.
    I changed on "class" to "logclass" in /shinken/modules/logstore_mongodb.py
    def make_mongo_filter(self, operator, attribute, reference):
    # The filters are text fragments which are put together to form a sql where-condition finally.
    # Add parameter Class (Host, Service), lookup datatype (default string), convert reference
    # which attributes are suitable for a sql statement
    good_attributes = ['time', 'attempt', 'logclass', 'command_name', 'comment', 'contact_name', 'host_name', 'plugin_output', 'service_description', 'state', 'state_type', 'type']
    good_operators = ['=', '!=']
    Now logs/events/notifications are working in mongologs.
    Please check everything correctly

  5. #5
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,130

    Re: Livestatus with mongologs

    I'm looking at adding this to the test_livestatus_mongodb.py to check this
    No direct support by personal message. Please open a thread so everyone can see the solution

  6. #6
    Senior Member
    Join Date
    Aug 2011
    Posts
    201

    Re: Livestatus with mongologs

    Hi
    I want to use something like this.... but don't know too much about python...
    I want to put this code at shinken/libexec folder into one script and filter whitin start and end date passed as args.

    Can you help me about how to do the "import livestatus"?? i got an error and don't know how to point file where is defined this class (i supose it is at shinken/shinken/clients/livestatus.py, but..)

    thanks


    [quote author=igup link=topic=796.msg4426#msg4426 date=1362021312]
    Hi.
    Shinken 1.2.4 with mongologs. Multisite ?heck_MK-1.2.0p4 not show logs.

    I tried to get the logs manually:
    #!/usr/bin/python
    # -*- encoding: utf-8; py-indent-offset: 4 -*-
    import livestatus

    def get_logs():
    connection_to_livestatus = livestatus.SingleSiteConnection("tcp:127.0.0. 1:50000&quot
    logs = connection_to_livestatus.query_table(
    "GET log\n"
    "Columns: class message\n"
    "Filter: log_time >= 1359269773\n"
    "Filter: host_name = localhost\n"
    "ResponseHeader: fixed16\n"
    "Limit: 501\n&quot
    return logs

    logs = get_logs()
    for line in logs:
    print line
    And here they are:
    [3, u'[1362018949] SERVICE NOTIFICATION: admin;localhost;NetworkUsage;CRITICAL;notify-service-by-email;eth0:UP (0.0Mbps/0.0Mbps/0.0/0.0/0.0/0.0), eth1OWN: 1 int NOK : CRITICAL']
    [3, u'[1362018949] SERVICE NOTIFICATION: guest;localhost;NetworkUsage;CRITICAL;notify-service-by-email;eth0:UP (0.0Mbps/0.0Mbps/0.0/0.0/0.0/0.0), eth1OWN: 1 int NOK : CRITICAL']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Cpu;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Load;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;Memory;2;Manually set to Critical by admin']
    [4, u'[1362019150] PASSIVE SERVICE CHECK: localhost;NetworkUsage;2;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Load;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Memory;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019151] SERVICE ALERT: localhost;Cpu;CRITICAL;SOFT;1;Manually set to Critical by admin']
    [1, u'[1362019164] SERVICE ALERT: localhost;Load;OK;SOFT;2;Load : 0.25 0.12 0.07 : OK']
    [1, u'[1362019297] SERVICE ALERT: localhost;Memory;OK;SOFT;2;Ram : 12%, Swap : 0% : ; OK']
    [1, u'[1362019322] SERVICE ALERT: localhost;Cpu;OK;SOFT;2;4 CPU, average load 1.5% < 80% : OK']
    but if I enable "Filter: class = 3"
    #!/usr/bin/python
    # -*- encoding: utf-8; py-indent-offset: 4 -*-
    import livestatus

    def get_logs():
    connection_to_livestatus = livestatus.SingleSiteConnection("tcp:127.0.0. 1:50000&quot
    logs = connection_to_livestatus.query_table(
    "GET log\n"
    "Columns: class message\n"
    "Filter: log_time >= 1359269773\n"
    "Filter: host_name = localhost\n"
    "Filter: class = 3\n"
    "ResponseHeader: fixed16\n"
    "Limit: 501\n&quot
    return logs

    logs = get_logs()
    for line in logs:
    print line
    I get no logs in result

    I have no problem with logsqlite.

    Thanks for help.
    [/quote]

  7. #7
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,130

    Re: Livestatus with mongologs

    There is no livestatus class in Shinken as far as I know, so should come from check_mk.
    No direct support by personal message. Please open a thread so everyone can see the solution

  8. #8
    Shinken project leader
    Join Date
    May 2011
    Location
    Bordeaux (France)
    Posts
    2,130

    Re: Livestatus with mongologs

    No direct support by personal message. Please open a thread so everyone can see the solution

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •