Jira与Zabbix结合

Posted DevOps

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Jira与Zabbix结合相关的知识,希望对你有一定的参考价值。

zabbix-jira

zabbix-jira is python module that allows you to create tasks in Jira with grafs by the trigger from Zabbix.

Requirements:

  • python >= 2.7

  • python libs: requests, jira

Installation:

  1. Copy this repo to your zabbix-server: git clone https://github.com/OSidorenkov/zabbix-jira.git

  2. Copy jirabix.py to your Zabbix AlertScriptsPath directory (see your zabbix_server.conf)

  3. Create and configure config.py near jirabix.py. You can take as an example config.py.example from repo.

  4. Install python libs: pip install requirements.txt

Configuration:

  • Create new media type in Zabbix:

If you use Zabbix 3.0 and higher, add this parameters:

{ALERT.SENDTO} {ALERT.SUBJECT} {ALERT.MESSAGE}
  • Add this media to your read user in Zabbix

Jira与Zabbix结合

Add in "Send to" field jira username (see the profile user in Jira)

  • Configure your Actions:

Jira与Zabbix结合

Example message:

Last value:{ITEM.VALUE1} ({TIME}) zbx;graphs zbx;graphs_period=1800 zbx;itemid:{ITEM.ID1} zbx;triggerid:{TRIGGER.ID} zbx;title:{HOST.HOST} - {TRIGGER.NAME} zbx;priority:{TRIGGER.SEVERITY} Server: {HOSTNAME} ({HOST.IP}) Desc: {TRIGGER.DESCRIPTION}

Jira与Zabbix结合

Example recovery message:

Server: {HOSTNAME} ({HOST.IP}) zbx;triggerid:{TRIGGER.ID} zbx;ok:1 Description: Problem resolved! Time of resolved problem: {DATE} {TIME}

Annotations

zbx;graphs -- enables attached graphs zbx;graphs_period=10800 -- set graphs period (default - 3600 seconds) zbx;graphs_width=700 -- set graphs width (default - 900px) zbx;graphs_height=300 -- set graphs height (default - 300px) zbx;itemid:{ITEM.ID1} -- define itemid (from trigger) for attach zbx;title:{HOST.HOST} - {TRIGGER.NAME} -- graph title zbx;triggerid:{TRIGGER.ID} -- define triggerid to link problem and recovery of event zbx;priority:{TRIGGER.SEVERITY} -- set priority task like as priority of trigger from Zabbix zbx;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

Test script

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 and ticket_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 change jirabix.py like this:
       
      Jira与Zabbix结合
       And run:
      python jirabix.py "jira_username" "ticket_subject

Result

  • See how creates the ticket with graf from Zabbix:


Jira与Zabbix结合


  • When problem is going to OK, script convert the ticket to "Done" status with comment from zabbix recovery message:


Jira与Zabbix结合




欢迎关注运维自研堂订阅号,运维自研堂是一个技术分享平台,主要是运维自动化开发:linux、python、django、saltstack、tornado、bootstrap、redis、golang、docker、etcd等经验分享。





开源    创新     共享


投稿&商务合作

Mail:idevops168@163.com       QQ:785249378


牛人并不可怕,可怕的是牛人比我们还努力!






以上是关于Jira与Zabbix结合的主要内容,如果未能解决你的问题,请参考以下文章

Jenkins - JIRA - GitLab 集成技巧(流程自动化概念)

技巧:结合Zabbix与SNMP监控嵌入式设备

Docker运行grafana与zabbix结合

如何将 SQLite 数据库与片段结合起来?

将 Dash 与 Alfred 结合起来

Zabbix结合bat脚本与计划任务开启window远程桌面