Ad Widget

Collapse

How to get current SLA (not Acceptable SLA) of IT Service by time period via SQL?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • romale
    Member
    • Mar 2013
    • 53

    #1

    How to get current SLA (not Acceptable SLA) of IT Service by time period via SQL?

    Hi,
    need retrieve/calculate a current SLA (not Acceptable SLA) of IT Service by time period via SQL.
    How to do it?
    Thanks
  • neogan
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2011
    • 118

    #2
    Originally posted by romale
    Hi,
    need retrieve/calculate a current SLA (not Acceptable SLA) of IT Service by time period via SQL.
    How to do it?
    Thanks
    Try something like

    SELECT * from service_alerts ;

    Comment

    • romale
      Member
      • Mar 2013
      • 53

      #3
      Originally posted by neogan
      Try something like

      SELECT * from service_alerts ;
      SELECT * from service_alarms;

      how to calculate current SLA after that (via SQL)?

      mysql> select * from service_alarms;
      +----------------+-----------+------------+-------+
      | servicealarmid | serviceid | clock | value |
      +----------------+-----------+------------+-------+
      | 1 | 1 | 1361783131 | 0 |
      | 2 | 1 | 1365670470 | 5 |
      | 3 | 1 | 1365670770 | 0 |
      | 4 | 1 | 1366027170 | 5 |
      | 5 | 1 | 1366028070 | 0 |
      | 6 | 1 | 1366267470 | 5 |
      | 7 | 1 | 1366268370 | 0 |
      | 8 | 1 | 1366796670 | 5 |
      | 9 | 1 | 1366797270 | 0 |
      | 10 | 1 | 1366798170 | 5 |
      ---cut---

      Comment

      • romale
        Member
        • Mar 2013
        • 53

        #4
        A question from another side. How to get current SLA status of all services via API?
        This command for one service only (service id is 1):
        curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"serviceids":"1",intervals":[{"from": "1367697600","to":"1367927887"}]},"jsonrpc":"2.0","method":"service.getsla","id":2 }' http://localhost/zabbix/api_jsonrpc.php

        But how for all service with one command only? (whithout scripting). Is it possible?

        Comment

        • Heilig
          Senior Member
          Zabbix Certified Trainer
          Zabbix Certified SpecialistZabbix Certified Professional
          • Mar 2013
          • 366

          #5
          Run without "serviceids" parameter:
          curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"intervals":[{"from": "1367697600","to":"1367927887"}]},"jsonrpc":"2.0","method":"service.getsla","id" :2 }' http://localhost/zabbix/api_jsonrpc.php

          UPDATE: or
          curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"serviceids": ["1","2","5"],"intervals":[{"from": "1367697600","to":"1367927887"}]},"jsonrpc":"2.0","method":"service.getsla","id" :2 }' http://localhost/zabbix/api_jsonrpc.php
          Retrieving availability information for IT services with ID 1,2,5.
          Last edited by Heilig; 24-05-2013, 18:21.

          Comment

          • romale
            Member
            • Mar 2013
            • 53

            #6
            [SOLVED] How to get current SLA status of all services via API?

            Originally posted by Heilig
            Run without "serviceids" parameter:
            curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"intervals":[{"from": "1367697600","to":"1367927887"}]},"jsonrpc":"2.0","method":"service.getsla","id" :2 }' http://localhost/zabbix/api_jsonrpc.php

            UPDATE: or
            curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"serviceids": ["1","2","5"],"intervals":[{"from": "1367697600","to":"1367927887"}]},"jsonrpc":"2.0","method":"service.getsla","id" :2 }' http://localhost/zabbix/api_jsonrpc.php
            Retrieving availability information for IT services with ID 1,2,5.
            Thank you, that's work!

            Comment

            • Pavels
              Member
              • Oct 2011
              • 83

              #7
              romale, you can also pass multiple service IDs to calculate SLA for a number of IT services.

              Comment

              • romale
                Member
                • Mar 2013
                • 53

                #8
                Originally posted by Pavels
                romale, you can also pass multiple service IDs to calculate SLA for a number of IT services.
                Pavels, what do you mean?

                Another question, what's json path of service ids from result below?:
                curl -i -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","param s":{"intervals":[{"from": "1367870400","to":"1367927555"}]},"jsonrpc":"2.0","method":"service.getsla","id":2 }' http://localhost/zabbix/api_jsonrpc.php


                {"jsonrpc":"2.0","result":{"1":{"status":"0","prob lems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":98.10 1653398653,"okTime":56070,"problemTime":1085,"down timeTime":0}]},"2":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":100," okTime":57155,"problemTime":0,"downtimeTime":0}]},"3":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":100," okTime":57155,"problemTime":0,"downtimeTime":0}]},"4":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":100," okTime":57155,"problemTime":0,"downtimeTime":0}]},"5":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":100," okTime":57155,"problemTime":0,"downtimeTime":0}]}},"id":2}

                Thanks

                Comment

                • Pavels
                  Member
                  • Oct 2011
                  • 83

                  #9
                  romale, I mean that you can use service.getsla to calculate the SLA for multiple triggers. For example:

                  Code:
                  {
                      "serviceids": [
                          "2",
                          "3"
                      ],
                      "intervals": [
                          {
                              "from": "1367697600",
                              "to": "1367927887"
                          }
                      ]
                  }
                  Another question, what's json path of service ids from result below?:
                  curl -i -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"443c3c6ad45368985021f59c4a172804","par am s":{"intervals":[{"from": "1367870400","to":"1367927555"}]},"jsonrpc":"2.0","method":"service.getsla","id" :2 }' http://localhost/zabbix/api_jsonrpc.php


                  {"jsonrpc":"2.0","result":{"1":{"status":"0","p rob lems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":98 .10 1653398653,"okTime":56070,"problemTime":1085,"down timeTime":0}]},"2":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":10 0," okTime":57155,"problemTime":0,"downtimeTime":0}]},"3":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":10 0," okTime":57155,"problemTime":0,"downtimeTime":0}]},"4":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":10 0," okTime":57155,"problemTime":0,"downtimeTime":0}]},"5":{"status":"0","problems":[],"sla":[{"from":"1367870400","to":"1367927555","sla":10 0," okTime":57155,"problemTime":0,"downtimeTime":0}]}},"id":2}
                  Service IDs are properties of the result object, if that's what you mean.

                  Comment

                  • Heilig
                    Senior Member
                    Zabbix Certified Trainer
                    Zabbix Certified SpecialistZabbix Certified Professional
                    • Mar 2013
                    • 366

                    #10
                    You can look ID in the browser address bar when you click on IT Service (go to IT SERVICES AVAILABILITY REPORT).
                    For example (IT service CORE has id 2):
                    IT SERVICES AVAILABILITY REPORT "CORE"
                    127.0.0.1/zabbix/report3.php?serviceid=2&year=2013&period=monthly&sid=ea0ae4082bf529ad

                    Comment

                    • romale
                      Member
                      • Mar 2013
                      • 53

                      #11
                      Thanks to All!

                      Comment

                      • Michael0
                        Member
                        • Jan 2013
                        • 70

                        #12
                        I dont get it, how to interpret the "from" and "to" values?
                        If I want to know the SLA from the actual or the last month?

                        I always get this error back:

                        {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}

                        When I used it without the "serviceids" I get this error back:

                        {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Empty parameters"},"id":2}

                        Comment

                        • romale
                          Member
                          • Mar 2013
                          • 53

                          #13
                          Originally posted by Michael0
                          I dont get it, how to interpret the "from" and "to" values?
                          If I want to know the SLA from the actual or the last month?

                          I always get this error back:

                          {"jsonrpc":"2.0","error":{"code":-32700,"message":"Parse error","data":"Invalid JSON. An error occurred on the server while parsing the JSON text."},"id":null}

                          When I used it without the "serviceids" I get this error back:

                          {"jsonrpc":"2.0","error":{"code":-32602,"message":"Invalid params.","data":"Empty parameters"},"id":2}
                          pls post command, that you use

                          Comment

                          • Michael0
                            Member
                            • Jan 2013
                            • 70

                            #14
                            First I use this which works, to get the authentication key:

                            #!/bin/bash
                            curl -i -X POST -H 'Content-Type:application/json' -d'{"jsonrpc": "2.0","method":"user.authenticate","params":{"user ":"admin","password":"zabbix"},"auth": null,"id":0}' http://localhost/zabbix/api_jsonrpc.php

                            And then this one to get the SLA for serviceids 199 back:

                            #!/bin/bash
                            curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"fd011c9455688c8f1274942c94aaea5d","par am s":{"serviceids":"199",intervals":[{"from": "1352452201","to":"1353057001"}]},"jsonrpc":"2.0","method":"service.getsla","id":1 }' http://localhost/zabbix/api_jsonrpc.php

                            Comment

                            • romale
                              Member
                              • Mar 2013
                              • 53

                              #15
                              Originally posted by Michael0
                              First I use this which works, to get the authentication key:

                              #!/bin/bash
                              curl -i -X POST -H 'Content-Type:application/json' -d'{"jsonrpc": "2.0","method":"user.authenticate","params":{"user ":"admin","password":"zabbix"},"auth": null,"id":0}' http://localhost/zabbix/api_jsonrpc.php

                              And then this one to get the SLA for serviceids 199 back:

                              #!/bin/bash
                              curl -X POST -H 'Content-Type: application/json-rpc' -d '{"auth":"fd011c9455688c8f1274942c94aaea5d","par am s":{"serviceids":"199",intervals":[{"from": "1352452201","to":"1353057001"}]},"jsonrpc":"2.0","method":"service.getsla","id":1 }' http://localhost/zabbix/api_jsonrpc.php
                              you have space symbol in "param s", change it to "params"

                              Comment

                              Working...