In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
In daily Zabbix alarm cases, most of them are alarm sending emails. In the scene, it is rarely necessary to execute a command (start service, clear disk space, shut down server) after alarm. Today, I will tell you what needs to be done recently: execute remote command after alarm.
First of all, let's talk about demand. One day in the distance, my friends used mongodb, and they needed to use it vigorously. In the future, some data was stored in mongodb; migrating data from the production environment into mongodb, then the problem came. I often heard others say that mongodb hung up when the amount was large. Some data of mongodb is quoted in the program. If it hangs at some time during the day, then users, customer service and operation will call. The party was also investigating the problem, looking for the reason, consulting the great god, upgrading the version, but it still hung up. It's hanging up at the moment, that is, it's starting up. Little friends can not often and computer together, sometimes need to flirt with sister paper together, on the high ground. Just zabbix action has a remote command function, then through it to solve the problem.
Remote commands: items -> triggers -> action -> remote commands
Configuration process:
1. Create a mongodb item
Configuration -> Hosts > Items
2. Configure mongodb triggers
Configuration -> Hosts > Triggers
3. Configure remote command actions
Configuraction -> Actions
Condition selects mongodb trigger with trigger value PROBLEM and trigger value above
The number of executions is 5 with an interval of 60 seconds
The operation type is: remote command
Type: Custom Script
Command: Specific instructions. Content will be posted below.
So far the whole process has been configured, but now mongodb is dead, will actions execute the command to start mongodb? Certainly not.
Remote command prerequisites, you need to enable remote command parameters in the configuration file, and start agentd.
echo 'EnableRemoteCommands=1' >> /usr/local/zabbix/zabbix_agentd.conf
/etc/init.d/zabbix_agentd restart
#Note that remote commands are not supported in zabbix agentd active mode. Remember...
Script content:
cat /usr/local/mongodb/start_mongod.sh
#!/ bin/bash
/usr/local/mongodb/mongod -f /usr/local/mongodb/mongod.conf >> /tmp/start.log
#Note, zabbix starts the user, you need to be able to execute the above command, that is, you need sudo empowerment
So now that it's all done, summarize the configuration process.
1. Turn on the EnableRemoteCommands parameter in the agentd configuration file
2. Configure Remote Comand in actions
3. Scripting in Commands
demonstration of classification
Kill mongodb
#killall mongod
After the acquisition time, zabbix sets triggers to problem and triggers actions. The record reads as follows
Administration -> Audit -> Actions
If configured correctly, audit must produce a remote commnad record.
Error 1. Audit has no record. Check the configuration file and actions configuration.
Error 2. Audit has records, but mongodb is not started. Script has problems. Debug it.
I hope this article helps you all, TS. - -
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.