当前位置:网站首页>Zabbix报警执行远程命令
Zabbix报警执行远程命令
2022-07-01 17:48:00 【星哥玩云】
日常Zabbix报警案例中,大多都是报警发送邮件,场景里很少有需要报警后执行一个命令(启动服务、清空磁盘空间、关停服务器);而今天就给大家讲讲最近需要做的事:报警后执行远程命令
首先讲讲需求吧, 遥远的一天,小伙伴们用上了mongodb,而且需要大力使用,日后一些数据存储在mongodb;从生产环境迁移数据进mongodb,那么问题来了,经常听到别人说,mongodb量大就挂了。mongodb有些数据是在程序当中被引用到,白天某个时刻挂了,那么用户、客服、运营就呼唤着了。。团队中也在查问题,找原因,请教大神,升级版本,可还是挂了。。 目前挂了就是在启动。。 小伙伴们不可能时常和电脑在一起,有时需要和妹纸在一起调情啦、上高地啦。刚好zabbix动作中有个远程命令功能,那么就通过它来解决问题。。
远程命令整个过程: items -> triggers -> action -> remote commands
配置过程:
1.创建一个mongodb items
Configuration -> Hosts > Items
2.配置mongodb triggers
Configuration -> Hosts > Triggers
3.配置远程命令的actions
Configuraction -> Actions
条件选择触发器值为PROBLEM、触发器为上面的mongodb触发器
执行次数为5次,每次间隔60秒
操作类型为:远程命令
类型为:自定义脚本
命令:具体的指令。内容将贴在下面。
至此整个过程都配完了,,但是现在mongodb挂了,actions会执行启动mongodb命令么。? 肯定不会。
远程命令前提条件,需要在配置文件开启远程命令参数,并启动agentd。
echo 'EnableRemoteCommands=1' >> /usr/local/zabbix/zabbix_agentd.conf
/etc/init.d/zabbix_agentd restart
#注意,远程命令不支持在zabbix agentd active模式。。切记。。
脚本内容:
cat /usr/local/mongodb/start_mongod.sh
#!/bin/bash
/usr/local/mongodb/mongod -f /usr/local/mongodb/mongod.conf >> /tmp/start.log
#注意,zabbix启动用户,需要能执行上述命令,也就是需要sudo赋权
那么现在,已经全部完成,总结一下配置过程
1.在agentd配置文件中开启EnableRemoteCommands参数
2.配置actions里的Remote Comand
3.Commands里的脚本制作
故障演示
干掉mongodb
#killall mongod
过了采集时间,zabbix将会把triggers置为problem,同时触发actions。记录里显示如下
Administration -> Audit -> Actions
如果配置正确,那么audit一定会产生一条remote commnad记录。
有误1,Audit无记录,查下配置文件、actions配置
有误2,Audit有记录,但mongodb却未启动,脚本有问题,调试一下。。
希望这篇文章能帮助大家,tks。 - -
边栏推荐
- 深度优先遍历和广度优先遍历[通俗易懂]
- China PBAT resin Market Forecast and Strategic Research Report (2022 Edition)
- (27) Open operation, close operation, morphological gradient, top hat, black hat
- Roewe rx5's "a little more" product strategy
- Thinkphp6 - CMS multi wechat management system source code
- String的trim()和substring()详解
- Alibaba cloud Li Feifei: China's cloud database has taken the lead in many mainstream technological innovations abroad
- 中国茂金属聚乙烯(mPE)行业研究报告(2022版)
- (16) ADC conversion experiment
- How to write good code - Defensive Programming Guide
猜你喜欢
(28) Shape matching based on contour features
剑指 Offer 20. 表示数值的字符串
Mysql database - Advanced SQL statement (2)
Penetration practice vulnhub range Tornado
Sword finger offer 20 String representing numeric value
Length of learning and changing
[C supplement] [string] display the schedule of a month by date
Rotation order and universal lock of unity panel
New 95 community system whole station source code
Gold, silver and four job hopping, interview questions are prepared, and Ali becomes the champion
随机推荐
Source code of new campus errand / campus task platform on mutual station
Openlayers 自定义气泡框以及定位到气泡框
vulnhub靶场-hacksudo - Thor
Is it reasonable and safe to open a securities account for 10000 shares free of charge? How to say
Petrv2: a unified framework for 3D perception of multi camera images
中国锦纶长丝缝纫线发展预测与投资方向研究报告(2022版)
Data warehouse (3) star model and dimension modeling of data warehouse modeling
[splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON
L'ouverture d'un compte d'actions en ligne est - elle sécurisée? Fiable?
Product service, operation characteristics
中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open
多线程使用不当导致的 OOM
Maizeer: the two batches of products reported by the media have been taken off the shelves and sealed, and consumer appeals are accepted
提交review时ReviewBoard出现500错误解决方法
Report on research and investment prospects of UHMWPE industry in China (2022 Edition)
[beauty detection artifact] come on, please show your unique skill (is this beauty worthy of the audience?)
DNS
The difference and relationship between iteratible objects, iterators and generators
Euler function: find the number of numbers less than or equal to N and coprime with n