Zabbix remote commands

  • by

Running commands on your remtoe servers fired by the user from the Zabbix WEb interface is very usefull. A couple of examples of situations:
– Run a command from the Problems list
– Run a command from a map
– Run a command when a trigger is fired

It is possible to setup commands on the server, proxy or agent of your Zabbix intallation. This example is for a proxy.

Examples of could it do?
– Power cycle a powerbar socket in a datacentre where one of your servers are no longer responsive
– Run a command to restart software which has stalled
– Start a sub-system to rectify issues when a trigger is fired

As root user in server(otherwise you are not able to access this folder):
cd /etc/sudoers.d
echo 'zabbix ALL=(ALL) NOPASSWD: /usr/sbin/zabbix_proxy -R config_cache_reload' | sudo tee zabbix_proxy_config_cache_reload
chmod 0440 zabbix_proxy_config_cache_reload

enable remote commands in proxy:
sudo vi /etc/zabbix/zabbix_proxy.conf
set the follwing to 1
EnableRemoteCommands=1
if your interested to check that things are working also set to 1
LogRemoteCommands=1

On Zabbix Server:
Administration->scripts
add new script
Name -> Refresh proxy config
Type -> Manual Host action
Exectute On -> Zabbix Server (proxy)
Commands -> sudo /usr/sbin/zabbix_proxy -R config_cache_reload
Host group -> Selected
-> select your host group of proxies
-> Update

Once complete you should refresch the config on the Zabbix server or wait a minute. Then the option will become available in the dialogue box for all proxies that are part of the host group you indicated.

 

Try to run this and check the logs of your proxy – if you enabled them to record the record of the script actions.

 

 

Refs:

https://blog.zabbix.com/zabbix-frontend-as-a-control-panel-for-your-devices/15545/