Our goal is to define a Zabbix action step that, when executed, will:
While the first point can be covered with a simple e-mail action to RT, we need custom code to take care of the other two. The best way to do this is to define a new media type in Zabbix as a custom alert script. The script will do the following:
Before actually writing the script, let's create the media type and link it to a user (you can assign the media type to any user you want; the custom rt_tickets
user has been used here, as shown in the following screenshot):
While linking the media type to the user, use the RT base URL in the Send to field, so you won't need to define it statically in the script. This is shown in the following screenshot:
Once saved, you'll see all relevant information at a glance in the Media tab, as shown in the following screenshot. Just after the URL address, you'll find the notification periods for the media and, after that, a six-letter code that shows the active severity levels. If you disabled any of them, the corresponding letter would be in gray:
Now, let's create an action step that will send a message to our rt_tickets
user through the custom media type. Needless to say, the rt_tickets
user won't receive any actual message as the alert script will actually create an RT ticket, but all of this is completely transparent from the point of view of a Zabbix action. You can put any information you want in the message body, but, at the very least, you should specify the trigger name in the subject and the event ID, severity, hosts, and items in the body so that the script will parse them and fill them in the appropriate ticket fields. This is shown in the following screenshot:
We are now ready to actually write the script and use it to create tickets from Zabbix.