Atlassian JIRA

Atlassian JIRA is a popular ticketing system or issue tracker. While it also supports an email gateway for creating issues, we could look at a more advanced way to do that—using the API that JIRA exposes. Media type and user media would have to be created and configured, similar to what we did in the Using scripts as media section earlier in this chapter, although it is proposed that you create a special user for running such scripts.

As for the script itself, something like this would simply create issues with an identical summary, placing the message body from the action configuration in the issue summary:

#!/bin/bash 
json='{"fields":{"project":{"key":"PROJ"},"summary":"Issue automatically created by Zabbix","description":"'"$1"'","issuetype":{"name":"Bug"}}}' 
curl -u username:password -X POST --data "$json" -H "Content-Type: application/json" https://jira.company.tld/rest/api/2/issue/ 

For this to work, make sure to replace the project key, username, password, and URL to the JIRA instance, and possibly also the issue type.

For debugging, add the curl flag -D-. That will print out the headers.

This could be extended in  a variety of ways. For example, we could pass the subject from the action properties as the first parameter, and encode the trigger severity among other pipe-delimited things. Our script would then parse out the trigger severity and set the JIRA priority accordingly. That would be quite specific for each implementation, although, hopefully, this example provided a good starting point.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset