A simple python script to open tickets in Jira when Zabbix Alarm is triggering and add a graph to the ticket. It uses a data in json format and parrsing it to get parameters from Zabbix.
zabbix-jira is python module that allows you to create tasks in Jira with grafs by the trigger from Zabbix. It also checks Jira for opening tickets for the specific user and clears the internal DB if the ticket was closed in Jira manually.
- python >= 2.7
- python libs: requests, jira, json, sqlite
- Copy this repo to your zabbix-server:
git clone https://github.com/be4ndr/ZabbixToJira.git
- Copy
zabbix_to_jira.py
to your ZabbixAlertScriptsPath
directory (see your zabbix_server.conf) - Create and configure
ztj_config.py
nearzabbix_to_jira.py
. You can take as an exampleztj_config_default.py
from repo. - Install python libs:
pip install -r requirements.txt
- Create new media type in Zabbix:
If you use Zabbix 3.0 and higher, add this parameters:
{ALERT.SENDTO}
{ALERT.SUBJECT}
Example message:
{"ztj": {"graphs": [{"graphs_period": "1800"}, {"itemid": "{ITEM.ID1}"}, {"triggerid": "{TRIGGER.ID}"}, {"title": "{HOST.HOST} - {TRIGGER.NAME}"}, {"priority": "{TRIGGER.SEVERITY}"}]}}
||Last value:|{ITEM.VALUE1} ({TIME})||
||Server:|{HOST.NAME}, {HOSTNAME}, ({HOST.IP})||
{panel:title=Description}
{TRIGGER.DESCRIPTION}
{panel}
Example recovery message:
{"ztj": {"graphs": [{"triggerid": "{TRIGGER.ID}"}, {"ok": "1"}]}}
||Server:|{HOST.NAME}, {HOSTNAME}, ({HOST.IP})||
||Last value:|{ITEM.VALUE1} ({TIME})||
{panel:title=Description}
Problem resolved!
Time of resolved problem: {DATE} {TIME}
{panel}
"graphs" -- a part of json data responsible for graphs
"graphs_period": "1800" -- set graphs period (default - 3600 seconds)
graphs_width: "900" -- set graphs width (default - 900px)
"graphs_height": "200" -- set graphs height (default - 300px)
"itemid": "{ITEM.ID1}" -- define itemid (from trigger) for attach
"title": "{HOST.HOST} - {TRIGGER.NAME}" -- graph title
"triggerid": "{TRIGGER.ID}"-- define triggerid to link problem and recovery of event
{"priority": "{TRIGGER.SEVERITY}"} -- set priority task like as priority of trigger from Zabbix
"ok": "1" -- use this parameter only in RECOVERY message, if you don't want create a new task about recovery in Jira
You can use Jira format text in your actions: https://jira.atlassian.com/secure/WikiRendererHelpAction.jspa?section=all
You can use the following command to create a ticket in Jira from your command line:
python jirabix.py "jira_username" "ticket_subject" "ticket_desc"
where
- jira_username - username from Jira user profile
- For
ticket_subject
andticket_desc
you may use "test" "test"- If you want to test real text from zabbix action message copy
test/entry.txt
from repo and change the contents of the file on your real data and changezabbix_to_jira.py
:
- If you want to test real text from zabbix action message copy
zbx_body = open("test\\entry.txt", 'r').read()
# zbx_body = sys.argv[2]
And run:
python jirabix.py "jira_username" "ticket_subject
- A new ticket should be created in Jira with attached graph.
- When problem is going to OK, script set the status of the ticket to "Done" and add a recovery message.