1182640071 / zabbixalertget Goto Github PK
View Code? Open in Web Editor NEWzabbix二次开发,添加对报警信息的持久存储,可选查看警事件前后半小时数据
zabbix二次开发,添加对报警信息的持久存储,可选查看警事件前后半小时数据
添加数据库收集告警信息 create table zabbix_problem_info (id varchar(20) NOT NULL ,alert_time timestamp without time zone NOT NULL, create_time timestamp without time zone NOT NULL, host varchar(100) NOT NULL , content varchar(2000) NOT NULL , value varchar(100) NOT NULL , item varchar(100) NOT NULL , CONSTRAINT zabbix_problem_info_pkey PRIMARY KEY (id)); 添加action 设置告警信息 Default subject: {"area":"local","TRIGGER.NAME":"{TRIGGER.NAME}","TIME":"{EVENT.DATE} {EVENT.TIME}","HOST":"{HOST.NAME}","VALUE":"{ITEM.VALUE}","ITEM":"{ITEM.NAME}"} 添加告警事件脚本 #!/usr/bin/python #coding=utf-8 import os,sys import psycopg2 , sys import psycopg2.extras from datetime import datetime import random try: _id = "AWS2" + str(datetime.now().strftime('%Y%m%d%H%M%S')) + str(random.randint(0,9)) info = sys.argv[1] x = eval(info) content = x['TRIGGER.NAME'] alert_time = x['TIME'].replace('.','-') host = x['HOST'] value = x['VALUE'] item = x['ITEM'] create_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') conn = psycopg2.connect(host="0.0.0.0",port=5432,user="postgres" ,password="postgres" , database="zabbix") cur = conn.cursor(cursor_factory=psycopg2.extras.DictCursor) sql = 'INSERT INTO zabbix_problem_info(id, alert_time, create_time, host, content, value ,item) VALUES (%s, %s, %s, %s, %s, %s, %s)' values = (_id , alert_time , create_time , host , content , value ,item ) cur.execute(sql , values) conn.commit() conn.close() except Exception , e: conn.close()
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.