Below is a practical, “copy-paste-then-adapt” guide that ServiceNow admins normally follow to find out whether the Zabbix event that opened (or updated) an Incident / Alert is still in PROBLEM state or has already flipped back to OK.
- Prerequisites (what must already exist)
• A Zabbix → ServiceNow integration that writes two pieces of data on every Incident / Alert record it creates or updates:
– u_zbx_event_id (the numeric Zabbix eventid)
– u_zbx_trigger_id (optional but handy)
• A ServiceNow credential record that can call the Zabbix API (HTTPS POST to https:///api_jsonrpc.php).
- Decide HOW you want to check
A) Real-time “push” (preferred)
Configure the Zabbix webhook to send event_update = true.
When the trigger changes back to OK, Zabbix pushes another payload containing the same eventid and value=0.
Your Scripted REST inbound action (or IntegrationHub flow) just updates the corresponding Incident: set State = Resolved / Closed.
→ You never have to poll ServiceNow manually.
B) On-demand / ad-hoc (what the question seems to ask)
A user clicks a UI Action (“Refresh Zabbix Status”) on the Incident form.
The Action runs a short background script that calls the Zabbix API on the fly and tells the analyst whether the event is still active.
→ See Section 3 for the code.
C) Scheduled polling
A Scheduled Script / Flow runs every N minutes, fetches all Incidents with State ≠ Closed and u_zbx_event_id ≠ null, bulk-queries Zabbix, and closes those whose value=0.
Uses exactly the same code as B, just in batch.
- Snippet: “Is my Zabbix event still active?”
Step 3.1 Create a REST message definition
System Web Services ➜ REST Message
Name : Zabbix - event.get
Endpoint : https://<ZABBIX-URL>/api_jsonrpc.php
HTTP method : POST
HTTP headers: Content-Type: application/json
Default request body (use {eventId} & {token} variables):
{
"jsonrpc": "2.0",
"method" : "event.get",
"params" : {
"eventids": "${eventId}",
"output" : ["eventid","value","acknowledged","clock"]
},
"auth" : "${token}",
"id" : 1
}
Step 3.2 UI Action on the Incident form
// Client-side button
action.setName('Refresh Zabbix Status');
action.setOnClick('refreshZbx()');
function refreshZbx() {
g_form.submit(); // save any edits first
GlideAjax.refreshZbxStatus(g_form.getValue('u_zbx_event_id'));
}
Step 3.3 Server-side GlideAjax Script Include
var refreshZbxStatus = Class.create();
refreshZbxStatus.prototype = {
type: 'refreshZbxStatus',
// callable from client
refreshZbxStatus: function(eventId) {
var rm = new sn_ws.RESTMessageV2('Zabbix - event.get', 'default');
rm.setStringParameterNoEscape('eventId', eventId);
rm.setStringParameterNoEscape('token', gs.getProperty('zabbix.api.token'));
var resp = rm.execute();
var body = JSON.parse(resp.getBody());
if (!body.result || body.result.length == 0) {
return 'Event not found in Zabbix!';
}
var isActive = body.result[0].value == "1"; // 1 = PROBLEM, 0 = OK
if (isActive) {
// Optionally update the ticket
var inc = new GlideRecord('incident');
if (inc.get('u_zbx_event_id', eventId)) {
inc.setValue('work_notes', 'Checked with Zabbix: Problem STILL ACTIVE');
inc.update();
}
return 'Problem still active in Zabbix.';
} else {
// Auto-resolve the ticket
var inc = new GlideRecord('incident');
if (inc.get('u_zbx_event_id', eventId)) {
inc.setValue('state', 6); // Resolved
inc.setValue('close_notes', 'Auto-closed by Zabbix (OK event)');
inc.update();
}
return 'Event is OK in Zabbix. Incident resolved.';
}
}
};
Now the analyst hits “Refresh Zabbix Status” and instantly sees a popup with either “Problem still active” or “Event OK – ticket closed.”
- Understanding the returned values
Zabbix event.get ➔ result[0].value
1 = PROBLEM (still active)
0 = OK (cleared)
If you’d rather query the trigger instead of the event, swap to:
method : "trigger.get",
params : {
"triggerids": "${triggerId}",
"output" : ["description","value"],
"selectLastEvent": ["eventid","value"]
}
Then value carries the same meaning (1 = PROBLEM, 0 = OK).
- Common gotchas
• Token expiry: Zabbix auth tokens usually last 1 hour unless you renew them—store and refresh automatically.
• Event vs trigger: An event is immutable; a trigger flips value. Pick the approach that matches your correlation logic.
• Timeouts / SSL errors: Make sure ServiceNow MID Server (if used) can reach Zabbix over HTTPS and that the cert is in the MID’s trust store.
• Multiple problems on same trigger: Correlate by eventid, not triggerid, if you want a 1-to-1 match between Incident and a specific occurrence.
- TL;DR
- Capture
eventid (and optionally triggerid) on every Zabbix-generated record in ServiceNow.
- Either push updates straight from Zabbix (
event_update=true) or call Zabbix’s event.get / trigger.get API from ServiceNow.
- Check
value; 1 = still active, 0 = cleared; update the Incident accordingly.
That’s it—now you (or an automated scheduled job) can definitively answer “Is that Zabbix event still active?” straight from within ServiceNow.