当前位置:网站首页>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。 - -
边栏推荐
- LeetCode中等题之TinyURL 的加密与解密
- Data warehouse (3) star model and dimension modeling of data warehouse modeling
- Htt [ripro network disk link detection plug-in] currently supports four common network disks
- Shenyu gateway development: enable and run locally
- Reflective XSS vulnerability
- 《中国智慧环保产业发展监测与投资前景研究报告(2022版)》
- 荣威 RX5 的「多一点」产品策略
- 中国乙腈市场预测与战略咨询研究报告(2022版)
- ACM mm 2022 video understanding challenge video classification track champion autox team technology sharing
- Equipment simulation and deduction training system software
猜你喜欢

Penetration practice vulnhub range Keyring

(16) ADC conversion experiment

【牛客网刷题系列 之 Verilog快速入门】~ 优先编码器电路①

(17) DAC conversion experiment

PETRv2:一个多摄像头图像3D感知的统一框架

Oom caused by improper use of multithreading

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

Kernel stray cat stray dog pet adoption platform H5 source code

Source code of new campus errand / campus task platform on mutual station

The new server is packaged with the source code of H5 mall with an operation level value of several thousand
随机推荐
Integer array merge [JS]
In depth evaluation and development trend prediction report of China's ice cream market (2022 Edition)
提交review时ReviewBoard出现500错误解决方法
(12) About time-consuming printing
transform. Forward and vector3 Differences in the use of forward
Openlayers 自定义气泡框以及定位到气泡框
China biodegradable plastics market forecast and investment strategy report (2022 Edition)
New 95 community system whole station source code
(十六)ADC转换实验
Mysql database - Advanced SQL statement (2)
Penetration practice vulnhub range Keyring
Is it reasonable and safe to open a securities account for 10000 shares free of charge? How to say
《中国智慧环保产业发展监测与投资前景研究报告(2022版)》
中国生物降解塑料市场预测与投资战略报告(2022版)
[2. Basics of Delphi grammar] 4 Object Pascal operators and expressions
SQL injection vulnerability (MySQL and MSSQL features)
New patent applications and transfers
China acetonitrile market forecast and strategic consulting research report (2022 Edition)
SLO is increasingly used to achieve observability | Devops
Common design parameters of solid rocket motor