当前位置:网站首页>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 acetonitrile market forecast and strategic consulting research report (2022 Edition)
- Length of learning and changing
- Research Report on China's enzyme Market Forecast and investment strategy (2022 Edition)
- Develop those things: easycvr cluster device management page function display optimization
- 中国锦纶长丝缝纫线发展预测与投资方向研究报告(2022版)
- SLO is increasingly used to achieve observability | Devops
- SPIE Western optoelectronics exhibition returned offline and successfully held a science and engineering event
- Iommu/smmuv3 code analysis (10) page table operation
- 中国乙腈市场预测与战略咨询研究报告(2022版)
- RadHat搭建内网YUM源服务器
猜你喜欢

(17) DAC conversion experiment

Heavy disclosure! Hundreds of important information systems have been invaded, and the host has become a key attack target

Cassette helicopter and alternating electric field magnetic manometer DPC

Wechat applet blind box - docking wechat payment

Rotation order and universal lock of unity panel

Oom caused by improper use of multithreading

Official announcement! Hong Kong University of science and Technology (Guangzhou) approved!

DNS

How to use JMeter function and mockjs function in metersphere interface test

ISO 27001 Information Security Management System Certification
随机推荐
Smart factory digital management system software platform
[splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON
Integer array merge [JS]
In aks, use secret in CSI driver mount key vault
RadHat搭建内网YUM源服务器
Htt [ripro network disk link detection plug-in] currently supports four common network disks
Oom caused by improper use of multithreading
多线程使用不当导致的 OOM
Common design parameters of solid rocket motor
Intel's open source deep learning tool library openvino will increase cooperation with local software and hardware parties and continue to open
中国生物降解塑料市场预测与投资战略报告(2022版)
期货先锋这个软件正规吗安全吗?选择哪家期货公司更安全?
手机开户股票开户安全吗?那么开户需要带些什么?
An example of data analysis of an old swatch and an old hard disk disassembly and assembly combined with the sensor of an electromagnetic press
股票万1免5证券开户是合理安全的吗,怎么讲
中国乙腈市场预测与战略咨询研究报告(2022版)
Cookies and session keeping technology
Yyds dry inventory MySQL RC transaction isolation level implementation
ACL 2022 | decomposed meta learning small sample named entity recognition
ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing