Ad Widget

Collapse

Creating action through Zabbix API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsbiju
    Junior Member
    • Jul 2014
    • 4

    #1

    Creating action through Zabbix API

    Admin please close this thread. Sorry for raising the query without looking into all the details.
    ================================================== ==========================
    The issue was with opcommand_hst parameter not being specified as an array. Changing it to an array fixed the issue
    ================================================== ==========================
    I am trying to define an action to execute a shell script stored in Zabbix server and I have the following JSON input to the create action API. On execution receiving the error at the bottom from Zabbix. Any help in identifying what is messed in the JSON object is much appreciated.

    {
    "method": "action.create",
    "params": {
    "name": "Trigger action",
    "eventsource": 0,
    "evaltype": 1,
    "status": 0,
    "esc_period": 120,
    "conditions": [
    {
    "conditiontype": 3,
    "operator": 2,
    "value": "MasterAvailability"
    },
    {
    "conditiontype": 5,
    "operator": 0,
    "value": 1
    },
    {
    "conditiontype": 16,
    "operator": 7
    }
    ],
    "operations": [
    {
    "operationtype": 1,
    "opcommand": {
    "command": "/usr/local/bin/echol.sh",
    "type": "0",
    "execute_on": "1"
    },
    "opcommand_hst": 0
    }
    ]
    },
    "auth": "c28cf888ce8363f83a0eb524065d132a",
    "id": 36419,
    "jsonrpc": "2.0"
    }

    Error:
    {
    "code": -32602,
    "message": "Invalid params.",
    "data": "You did not specify targets for action operation command \"/usr/local/bin/echol.sh\"."
    }

    Is there any other parameter in "opcommand" other than the "execute_on" parameter which needs to be specified.
    Last edited by gsbiju; 12-08-2014, 03:54. Reason: Found the issue with the JSON object
  • Dennye
    Junior Member
    • Jan 2016
    • 1

    #2
    You should put the array "opcommand_hst":[{"opcommand_hstid":"","operationid":"","hostid":"" }]

    Comment

    Working...