当前位置:网站首页>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。 - -
边栏推荐
- 中国氮化硅陶瓷基板行业研究与投资前景报告(2022版)
- Penetration practice vulnhub range Tornado
- (28) Shape matching based on contour features
- How to use JMeter function and mockjs function in metersphere interface test
- 【牛客网刷题系列 之 Verilog快速入门】~ 优先编码器电路①
- MySQL -- explain performance optimization
- There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds
- 网上股票开户安全吗?是否可靠?
- About selenium element positioning being overwritten
- [mathematical modeling] [matlab] implementation of two-dimensional rectangular packing code
猜你喜欢

(27) Open operation, close operation, morphological gradient, top hat, black hat

为什么你要考虑使用Prisma

官宣!香港科技大学(广州)获批!

Common design parameters of solid rocket motor
![[PHP foundation] realize the connection between PHP and SQL database](/img/eb/c8953eddfe3b19b0adb5529957d275.jpg)
[PHP foundation] realize the connection between PHP and SQL database

ISO 27001 Information Security Management System Certification

LeetCode中等题之TinyURL 的加密与解密

Gold, silver and four want to change jobs, so we should seize the time to make up

Enter wechat applet

【Try to Hack】vulnhub DC4
随机推荐
中国冰淇淋市场深度评估及发展趋势预测报告(2022版)
目前炒期货在哪里开户最正规安全?怎么期货开户?
SLO is increasingly used to achieve observability | Devops
中国酶制剂市场预测与投资战略研究报告(2022版)
(十七)DAC转换实验
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
Detailed explanation of string's trim() and substring()
Source code of new campus errand / campus task platform on mutual station
June issue | antdb database participated in the preparation of the "Database Development Research Report" and appeared on the list of information technology and entrepreneurship industries
[splishsplash] about how to receive / display user parameters, MVC mode and genparam on GUI and JSON
Blackwich: the roadmap of decarbonization is the first step to realize the equitable energy transformation in Asia
PHP implements sensitive word filtering system "suggestions collection"
Gold, silver and four want to change jobs, so we should seize the time to make up
PIP version problems: PIP problems still occur when installing akshare and using Tsinghua source and Douban source
Fresh, 2022 advanced Android interview must know 100 questions (interview questions + answer analysis)
两数之和c语言实现[通俗易懂]
期货先锋这个软件正规吗安全吗?选择哪家期货公司更安全?
(27) Open operation, close operation, morphological gradient, top hat, black hat
Integer array merge [JS]
There is a new breakthrough in quantum field: the duration of quantum state can exceed 5 seconds