Ad Widget

Collapse

monitor api with curl and count json

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ab-tech
    Junior Member
    • Sep 2020
    • 20

    #1

    monitor api with curl and count json

    Hello,
    i need to monitor an url with curl (or web scenario) and count result.

    for example i'm able to (from server cli) to:
    Code:
    curl -k -u <user>:<password> -X POST https://10.200.200.1:10443/rest/interface/wifi/registration-table/print -H "content-type: application/json" | jq '. | length'
    this return a value, for example 25.
    i would collect this value in zabbix...

    i try to create new item (http agent) or web scenario but i can't "read" correct value.

    i can run a cli command, such as curl ........
    in a item on zabbix?

    or maybe i need to create a script on server?

    thank you​
  • Answer selected by Hamardaban at 29-01-2024, 18:08.
    cyber
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Dec 2006
    • 4807

    Web scenario is not suitable for this. It is meant to check website availability, but it will not pull any data for later processing.
    item with type "http agent" should do the trick... you pull the data and then, as it is json, that is returned, you do some jsonpath preprocessing https://www.zabbix.com/documentation..._functionality length() is present there...

    Comment

    • cyber
      Senior Member
      Zabbix Certified SpecialistZabbix Certified Professional
      • Dec 2006
      • 4807

      #2
      Web scenario is not suitable for this. It is meant to check website availability, but it will not pull any data for later processing.
      item with type "http agent" should do the trick... you pull the data and then, as it is json, that is returned, you do some jsonpath preprocessing https://www.zabbix.com/documentation..._functionality length() is present there...

      Comment

      • ab-tech
        Junior Member
        • Sep 2020
        • 20

        #3
        big thank you.

        i setup an item with http agent and in preprocessing add
        name = JSONPath
        Parameters = $.length()

        now i have a total of cont.

        thank you again

        Comment

        Working...