I have a Zabbix item named Corrupt Sessions
, that calls a custom check (UserParameter
) with the key corrupt_sessions
. The output of this check is a JSON list.
Say something like:
["abc", "def", "ghi"]
I want to do two things with the result of this item:
Corrupt session IDs: abc, def, ghi
), whenever the number of corrupt sessions increases above some threshold.The first thing I was able to do using a JSONPath preprocessing step inside the Corrupt Sessions
item, with a $.length()
parameter. And this works nicely, I get the number of corrupt sessions.
However, how can I use the same JSON output of this item to come up with the list? This custom check is quite intensive performance wise, therefore I want to avoid calling it twice.
Although, when I tried creating a new item with the same key corrupt_sessions
, I got an error stating:
An item with key "corrupt_sessions" already exists on the template "XYZ".
Now, I can cheat a little and use corrupt_sessions[]
as the key, but the error indicates to me that there should be a better way of re-using the output of the item (to avoid an expensive recheck) for a separate JSONPath preprocessor. (Note that the textual list would only be necessary when the corrupt session count reaches a certain threshold.)
How would one go about this?
I assume you need the list in the alert message.
You can create a dependent item, and apply $.length()
to it. This way you call the custom check one time, but you get two items on Zabbix. Then in the trigger, you will check last(dependent_item)>0 and length(master_item)>0
: this way you can reference the list content as {ITEM.LASTVALUE2}
in the notification.
See