Ad Widget

Collapse

How to obtain total duration of specific trigger in PROBLEM over month?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jamie
    Junior Member
    • Nov 2018
    • 2

    #1

    How to obtain total duration of specific trigger in PROBLEM over month?

    Hello,

    We have been using Zabbix extensivly for several years and we love it. Currently we monitor around 1700 hosts - it's great so thankyou all for building such a brilliant piece of software.

    As a systems team we are monitoring up/down of specific system processes or even entire systems with ICMP etc.

    The business now would like to see more 'availibility of service' reports in terms of time.

    We can build scripts to perform end to end testing of a service and create a trigger from that no problem.

    What I would like to do is some how pull out the total duration in time that a specific trigger is in a PROBLEM state. Either via API or directly.

    If I can get this figure I can cunch the numbers in some more scripts to feed into management reports. If I could get this figure on a per day, week and monthly basis that would be fantastic.

    Can anyone help me figure out how to pull this data out? I really do not want to look at introduction another platform just for this when the data is clearly in the system somewhere.

    Thanks in advance.
    - Jamie
  • Jamie
    Junior Member
    • Nov 2018
    • 2

    #2
    Slight update here but I am a bit stuck.

    Some further research shows that the IT Services tool is what we want. We have this working and can see some data of availability number vs SLA.

    Now we want to get this from the API via the service.getsla() call.

    We are using pyzabbix but can't seem to get the expected response

    HTML Code:
    #!/usr/bin/python3.6
    
    from pyzabbix import ZabbixAPI
    
    import pprint
    import sys
    import logging
    
    
    stream = logging.StreamHandler(sys.stdout)
    stream.setLevel(logging.DEBUG)
    log = logging.getLogger('pyzabbix')
    log.addHandler(stream)
    log.setLevel(logging.DEBUG)
    
    zapi = ZabbixAPI("http://x.x.x.x/zabbix")
    zapi.login("user", "passs")
    
    print("Connected to Zabbix API Version %s" % zapi.api_version())
    
    
    result = zapi.service.getsla(output='extended', serviceids=1, intervals=['1544054400','1543449600'])
    
    
    
    pprint.pprint(result)
    Now the issue is that the 'from' and 'to' responses are not what we passed in - it always seems to just take the first charachter of what was passed in, in this case 1 (from 1544054400' and '1543449600)

    HTML Code:
    Connected to Zabbix API Version 2.2.9
    {'1': {'problems': [],
           'sla': [{'downtimeTime': 0,
                    'from': '1',
                    'okTime': 0,
                    'problemTime': 0,
                    'sla': 100,
                    'to': '1'},
                   {'downtimeTime': 0,
                    'from': '1',
                    'okTime': 0,
                    'problemTime': 0,
                    'sla': 100,
                    'to': '1'}],
           'status': '0'}}
    If we turn debug mode on - we see the JSON RPC sent correctly so I really don't know whats going on here.

    HTML Code:
    JSON-RPC Server Endpoint: http://x.x.x.x/zabbix/api_jsonrpc.php
    Sending: {
        "jsonrpc": "2.0",
        "method": "user.login",
        "params": {
            "user": "-----",
            "password": "-------"
        },
        "id": 0
    }
    Response Code: 200
    Response Body: {
        "jsonrpc": "2.0",
        "result": "88b4024ec99074b2e7cce0a828689a77",
        "id": 0
    }
    Sending: {
        "jsonrpc": "2.0",
        "method": "apiinfo.version",
        "params": {},
        "id": 1
    }
    Response Code: 200
    Response Body: {
        "jsonrpc": "2.0",
        "result": "2.2.9",
        "id": 1
    }
    Connected to Zabbix API Version 2.2.9
    Sending: {
        "jsonrpc": "2.0",
        "method": "service.getsla",
        "params": {
            "output": "extended",
            "serviceids": 1,
            "intervals": [
                "1544054400",
                "1543449600"
            ]
        },
        "id": 2,
        "auth": "88b4024ec99074b2e7cce0a828689a77"
    }
    Response Code: 200
    Response Body: {
        "jsonrpc": "2.0",
        "result": {
            "1": {
                "status": "0",
                "problems": [],
                "sla": [
                    {
                        "from": "1",
                        "to": "1",
                        "sla": 100,
                        "okTime": 0,
                        "problemTime": 0,
                        "downtimeTime": 0
                    },
                    {
                        "from": "1",
                        "to": "1",
                        "sla": 100,
                        "okTime": 0,
                        "problemTime": 0,
                        "downtimeTime": 0
                    }
                ]
            }
        },
        "id": 2
    }
    {'1': {'problems': [],
           'sla': [{'downtimeTime': 0,
                    'from': '1',
                    'okTime': 0,
                    'problemTime': 0,
                    'sla': 100,
                    'to': '1'},
                   {'downtimeTime': 0,
                    'from': '1',
                    'okTime': 0,
                    'problemTime': 0,
                    'sla': 100,
                    'to': '1'}],
           'status': '0'}}
    Any ideas or help would be greatly appreciated.

    Comment

    • shilpab
      Junior Member
      • Jun 2020
      • 17

      #3
      Hello,

      Did this work for you/. Even i am looking for the same feature where the total number of hours the trigger is generated for a day.

      Comment

      Working...