Hi I've looked and looked with no joy. I have used the Zabbix API to get the hostgroup of a host
This returns a numberic value and this can be even used to delete the hostgroup. No problem
Can someone please advise how I can use this HostGroupID variable or even the HOSTGROUP_NAME variable to see if the group is empty, please? If it is empty then I can run the delete command to tidy up. This ultimately is the goal.
Thanks in advance
-AndyW
Code:
HostGroupID=`curl -s -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\": \"2.0\",\"method\":\"hostgroup.get\",\"params\":{\"output\":\"extend\",\"filter\":{\"name\":[\""$HOSTGROUP_NAME"\"]}},\"auth\":\""$api_key"\",\"id\":0}" http://$server/zabbix/api_jsonrpc.php | jq -r .result[0].groupid`
Code:
curl -s -H 'Content-Type: application/json-rpc' -d "{\"jsonrpc\": \"2.0\",\"method\":\"hostgroup.delete\",\"params\":[\""${HostGroupID}"\"],\"auth\":\""$api_key"\",\"id\":0}" http://$server/zabbix/api_jsonrpc.php
Thanks in advance
-AndyW
Comment