Ad Widget

Collapse

Zabbix API "search" on integers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Yab94
    Junior Member
    • Oct 2012
    • 3

    #1

    Zabbix API "search" on integers

    Hi,
    I am using the zabbix API on a 2.0.3 version.
    I am making a json request for a trigger selection.
    My contraint is to select only the inactives triggers (so status must be different from 0). I don't want to select individualy the other status.

    So i try a

    {
    "params":{
    "excludeSearch":1,
    "search":{"status":1},
    "output":"extend"},
    "method":"trigger.get",
    "jsonrpc":"2.0",
    "id":0,
    "auth":"b32de9735070c2bafbd52bc68c30cdf6"
    }

    But it doesn't work, it send me all the triggers (with all status).

    Can you help me to solve my problem ?
    I suspect the search parameter to only work with strings field because it works with "description" field.

    Regards,
    Yab
  • Yab94
    Junior Member
    • Oct 2012
    • 3

    #2
    I find this in source code :

    frontend/php/include/db.inc.php (l:928)

    Code:
    		if ($tableSchema['fields'][$field]['type'] != DB::FIELD_TYPE_CHAR
    			&& $tableSchema['fields'][$field]['type'] != DB::FIELD_TYPE_TEXT) {
    			continue;
    		}
    It shows that my observation was right, no search on integer field is available...

    Do you have a solution without hacking the api code ?

    Comment

    • Pavels
      Member
      • Oct 2011
      • 83

      #3
      Indeed, you cannot use "search" with integer fields, only "filter.". But the trigger status property can only be either 0 or 1, so you can just use:

      Code:
      "filter": {
        "status": 1
      }

      Comment

      • Yab94
        Junior Member
        • Oct 2012
        • 3

        #4
        May be in most case status can only be 1 or 0... but in my case, the administrators have created other status and will probably create more in the future.

        That's why i said in my first post :

        I don't want to select individualy the other status.
        However, thanks for the answer.

        Comment

        • Pavels
          Member
          • Oct 2011
          • 83

          #5
          Then you'll need to extend the API; there's currently no way to do it.

          Comment

          Working...