I would like to create triggers automatically for all web checks created in our Zabbix instance. My first thought is to use LLD (low-level discovery) in a template, and then attach that template to the applicable hosts.
I've configured the discovery to use an "External Check" with a script that calls the Zabbix API to fetch the names of all the web checks for the host specified in one of the parameters to the script. I've confirmed this works by itself by calling the script manually, and in Zabbix through my troubleshooting that I'll describe in a bit. This is what the trigger prototype looks like:

The problem is that when I try to save this trigger prototype, it fails saying that the items don't exist, which makes sense, since the items aren't inherently tied to the template where this is being used.
In order to try and trick Zabbix into creating the triggers, I've tried creating both items within the template; once with "Create enabled" disabled, once with "Discover" disabled, once with them both disabled, and once with both of them enabled. Unfortunately none of these attempts have been successful. It appears that the triggers were never created in any case. Only in the case where both options were enabled did the error come up about the items already existing (which makes sense, since the web checks have already been created by this point).
I could definitely change my script to use the API to create the triggers itself and add a cron schedule for it, but it would be nice if we could do it via LLD and use the existing features there. If anyone has ideas on how to get this to work, or some other way of automatically creating triggers for web scenarios in Zabbix, it would be appreciated if you could share. Thanks!
I've configured the discovery to use an "External Check" with a script that calls the Zabbix API to fetch the names of all the web checks for the host specified in one of the parameters to the script. I've confirmed this works by itself by calling the script manually, and in Zabbix through my troubleshooting that I'll describe in a bit. This is what the trigger prototype looks like:
The problem is that when I try to save this trigger prototype, it fails saying that the items don't exist, which makes sense, since the items aren't inherently tied to the template where this is being used.
In order to try and trick Zabbix into creating the triggers, I've tried creating both items within the template; once with "Create enabled" disabled, once with "Discover" disabled, once with them both disabled, and once with both of them enabled. Unfortunately none of these attempts have been successful. It appears that the triggers were never created in any case. Only in the case where both options were enabled did the error come up about the items already existing (which makes sense, since the web checks have already been created by this point).
I could definitely change my script to use the API to create the triggers itself and add a cron schedule for it, but it would be nice if we could do it via LLD and use the existing features there. If anyone has ideas on how to get this to work, or some other way of automatically creating triggers for web scenarios in Zabbix, it would be appreciated if you could share. Thanks!
Comment