Git Product home page Git Product logo

zabbix_dingding's Introduction

环境要求

python2.x python3.x zabbix 2.x 版本以上 dingding

我刚刚学习python没多久,写的不是很好大神勿喷 😶😶😶

个人博客

https://www.aityp.com


效果图🐐

image

版本选择

文件 说明
zabbix_dingding.py 机器人安全配置为网段
zabbix_dingding_sign.py 机器人安全配置为加签(推荐) 使用python3
推荐使用签名验证版本,更安全

python配置

你的python3最好在/usr/bin下面,否则会找不到

ln -s python3 /usr/bin/python3

安装configparser requests模块(需要PIP没有可以看下面安装)

#python2.x
pip install configparser
pip install requests

#python3.x
pip3 install configparser
pip3 install requests

安装pip

cd pip_install
python get-pip.py

钉钉配置

需要新建一个钉钉群,群里面添加一个机器人即可。

点击加入一个机器人

image

添加自定义机器人

image

设置机器人,记住webhook后面会用到

image

webhook后面配置文件会用到! ! ! 安全配置选择加签

pull代码

git clone [email protected]:typ431127/zabbix_dingding.git

配置报警配置文件

cd zabbix_dingding
mkdir -p /etc/zabbix/
mv dingding.conf /etc/zabbix/

编辑配置文件

/etc/zabbix/dingding.conf

[config]
#此文件注意权限
log_dir=/data/logs/zabbix/
log_file=zabbix_dingding.log
#配置图片实例,https://img.alicdn.com/top/i1/LB1lIUlPFXXXXbGXFXXXXXXXXXX
webhook=https://oapi.dingtalk.com/robot/send?access_token=
secret=
  • webhook是你新建机器人webhook,复制粘贴即可,这一步很重要.
  • secret是安全设置里面加签的key,复制粘贴即可

配置报警脚本

zabbix_dingding.py放到你zabbix_serverscripts目录下面即可.

配置权限

chown zabbix:zabbix zabbix_dingding.py
chmod +x zabbix_dingding.py
touch /tmp/zabbix_dingding.log
chown zabbix:zabbix /tmp/zabbix_dingding.log

zabbix web配置

管理---报警媒介类型---创建媒体类型
配置如下 image

用户添加报警媒介---添加

image

收件人是你的钉钉手机号 image 动作配置 image

手动触发报警

image

日志调试

cat /data/logs/zabbix/zabbix_dingding.log

图中所示错误为签名验证key错误,这个时候自行检查dingding.conf中secret配置是否与钉钉机器人中的key一样。

QQ:1500698928

个人微信

image

问题调试方法

如果你的钉钉收不到消息可以使用以下方法进行调试 命令行调试脚本

python3 zabbix_dingding.py 1 2 3

zabbix_dingding's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.