Thank you for sharing this. Just one thing. Is this only auto remove host by your trigger which is as example put here by icmp or it works out of box with let say Zabbix agent is unreachable for 60 minutes? Or it will trigger any problem? I have lot triggers which can be in a problem but not for removing.
I have done all the steps but the host is not deleting from the UI.. can you please help me with this .. if maunally executing getting " 56 3 undefined"
hi ! Do you know why you are giving this error? cannot execute script: ReferenceError: identifier ' CurLHttpRequest' undefined at [anon] (duktape.c83869) internal at [anon] (function:5) prevestsyield
// convert to JSON all input arguments var params = JSON.parse(value); // define new HTTP request var req = new HttpRequest(); // where Zabbix API endpoint is located var json_rpc = params.url + '/api_jsonrpc.php'; // this will be JSON call req.addHeader('Content-Type: application/json'); // prepare the data to be sent var requestData = JSON.stringify({ "jsonrpc": "2.0", "method": "host.delete", "params": [params.hostid], "auth": params.token, "id": 1 }); // send POST request and capture response var response = JSON.parse(req.post(json_rpc, requestData)); // log the response result Zabbix.Log(3, JSON.stringify(response)); // return the hostid (or any other value you need) return params.hostid;
Thank you for sharing this. Just one thing. Is this only auto remove host by your trigger which is as example put here by icmp or it works out of box with let say Zabbix agent is unreachable for 60 minutes? Or it will trigger any problem? I have lot triggers which can be in a problem but not for removing.
Thanks for sharing
Good. 😀
I have done all the steps but the host is not deleting from the UI.. can you please help me with this .. if maunally executing getting
" 56 3 undefined"
hi !
Do you know why you are giving this error?
cannot execute script: ReferenceError: identifier ' CurLHttpRequest' undefined
at [anon] (duktape.c83869) internal
at [anon] (function:5) prevestsyield
// convert to JSON all input arguments
var params = JSON.parse(value);
// define new HTTP request
var req = new HttpRequest();
// where Zabbix API endpoint is located
var json_rpc = params.url + '/api_jsonrpc.php';
// this will be JSON call
req.addHeader('Content-Type: application/json');
// prepare the data to be sent
var requestData = JSON.stringify({
"jsonrpc": "2.0",
"method": "host.delete",
"params": [params.hostid],
"auth": params.token,
"id": 1
});
// send POST request and capture response
var response = JSON.parse(req.post(json_rpc, requestData));
// log the response result
Zabbix.Log(3, JSON.stringify(response));
// return the hostid (or any other value you need)
return params.hostid;