The remote command to restart the application zabbix

 

 

 

 

 

 

Experimental environment: Redhat7.2, zabbix4.2

Agent Host: 192.168.112.118

Experiment content: zabbix remote command to restart the application, for example to httpd

zabbix remote commands can be done:

Restart the application (Apache, nginx, MySQL, etc.)

Using IPMI interface to restart the server

Automatic free disk space (delete the old file, remove the / tmp directory, etc.)

If you overload a CPU virtual machine migration to another physical server

A cloud environment, \ hard disk \ Memory \ server CPU under a situation of insufficient other hardware resources, can automatically add past

Configuration

1. Set sudo permissions zabbix client user (other users need to require sudo root privileges)

[root@linux ~]# visudo

Defaults:! Zabbix requiretty #### does not need to be prompted to log terminal

zabbix ALL = (ALL) NOPASSWD: ALL #### zabbix set free user password

2. In the client configuration to support remote command

EnableRemoteCommands = 1

3. Restart the client

[root@linux ~]# systemctl restart zabbix-agent

4. The manual detection terminal availability

In the server-side execution command

zabbix_get -s 192.168.112.118 -k "system.run[df -h]"

Content is detected, indicating that the terminal is available

5. Run, obtaining client state httpd

[root@linux ~]# zabbix_get -s 192.168.112.118 -k "system.run[sudo systemctl status httpd]"

Run error

Insufficient permission to report this error when first check the status of the firewall

Firewall off, see selinux state again

Selinux is turned on, temporary closure selinux

[root@linux ~]# setenforce 0

Again to execute the command terminal

At this time, the state found httpd open state

You can execute a command to turn it off

zabbix_get -s 192.168.112.118 -k "system.run[sudo systemctl stop httpd]"

6. After verifying the availability of remote commands, add zabbix front page monitoring items, set triggers, and add actions to execute remote commands.

7. Add the monitored item:

Custom name, type zabbix client, the key is proc.num [,,, httpd], other custom, click Add.

8. Add the trigger

Custom name and severity of the monitored item selected expression .last () <1

9. Create action, action to create a process for the state named

Create a new trigger conditions, select the name of flip-flop flip-flop equal to eight settings,

Operation: Custom Action step duration, default title, and message content (message content may be set according to their needs)

Creating steps: selecting a remote command

sudo systemctl restart httpd

At the same time execute a command to notify the responsible person, add a new message is sent. Update after update.

Finally, remember to permanently close selinux

 

Guess you like

Origin www.cnblogs.com/yigehezi/p/11230545.html