With remote commands you can define that a certain pre-defined command is automatically executed on the monitored host upon some condition.
Thus remote commands are a powerful mechanism for smart pro-active monitoring.
In the most obvious uses of the feature you can try to:
Configuring an action for remote commands is similar to that for sending a message, the only difference being that Zabbix will execute a command instead of sending a message.
Remote commands are limited to 255 characters. Multiple commands can be executed one after another by placing them on a new line. Remote commands may contain macros. See also the command execution page.
Remote commands are executed even if the target host is in maintenance.
The following tutorial provides step-by-step instructions on how to set up remote commands.
Those remote commands that are executed on Zabbix agent (custom scripts) must be first enabled in the respective zabbix_agentd.conf.
Make sure that the EnableRemoteCommands parameter is set to 1 and uncommented. Restart agent daemon if changing this parameter.
Then, when configuring a new action in Configuration→Actions:
For example:
sudo /etc/init.d/apache restart
In this case, Zabbix will try to restart an Apache process. With this command, make sure that the command is executed on Zabbix agent (mark the respective radio button against Execute on).
Remote commands on Zabbix agent are executed without timeout by the system.run[,nowait] key. On Zabbix server remote commands are executed with timeout as set in the TrapperTimeout parameter of zabbix_server.conf file.
Make sure that the 'zabbix' user has execute permissions for configured commands. One may be interested in using sudo to give access to privileged commands. To configure access, execute as root:
# visudo
Example lines that could be used in sudoers file:
# allows 'zabbix' user to run all commands without password. zabbix ALL=NOPASSWD: ALL
# allows 'zabbix' user to restart apache without password. zabbix ALL=NOPASSWD: /etc/init.d/apache restart
If the target system has multiple interfaces of the selected type (Zabbix agent or IPMI), remote commands will be executed on the default interface.
For IPMI remote commands the following syntax should be used:
<command> [<value>]
where
Restart of Windows on certain condition.
In order to automatically restart Windows upon a problem detected by Zabbix, define the following actions:
PARAMETER | Description |
---|---|
Operation type | 'Remote command' |
Type | 'Custom script' |
Command | c:\windows\system32\shutdown.exe -r -f |
Restart the host by using IPMI control.
PARAMETER | Description |
---|---|
Operation type | 'Remote command' |
Type | 'IPMI' |
Command | reset |
Power off the host by using IPMI control.
PARAMETER | Description |
---|---|
Operation type | 'Remote command' |
Type | 'IPMI' |
Command | power off |