Difference between revisions of "Zabbix Remote Commands"

From UVOO Tech Wiki
Jump to navigation Jump to search
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
https://blog.zabbix.com/zabbix-remote-commands/7500/
+
- https://www.zabbix.com/documentation/current/manual/config/notifications/action/operation/remote_command
 +
- https://blog.zabbix.com/zabbix-remote-commands/7500/
  
 
# Enable on Agent and Test from Server/Proxy
 
# Enable on Agent and Test from Server/Proxy
Line 18: Line 19:
 
```
 
```
  
## Server
+
## Server Proxy
 
```
 
```
 
zabbix_get -s txd1-sandbox.extendhealth.com -p 10050 -k "system.run[dir]" --tls-connect psk --tls
 
zabbix_get -s txd1-sandbox.extendhealth.com -p 10050 -k "system.run[dir]" --tls-connect psk --tls

Latest revision as of 12:31, 23 July 2021

Enable on Agent and Test from Server/Proxy

Client

  • /etc/zabbix/zabbix_agent2.conf
  • C:\Program Files\Zabbix Agent 2\zabbix_agent2.conf
# AllowKey=system.run[*]
# AllowKey=system.run[hostname]
AllowKey=system.run[dir]

Reload config

sudo systemctl restart zabbix-agent2
restart-service "zabbix agent 2"

Server Proxy

zabbix_get -s txd1-sandbox.extendhealth.com -p 10050 -k "system.run[dir]" --tls-connect psk --tls
-psk-identity <MYID> --tls-psk-file <MYFILEPATH>

Linux allow sudo nopasswd for commands you want to allow agent to run

!!!Be careful when editing sudoers. Use visudo!!!

visudo /etc/sudoers.d/zabbix

# zabbix ALL=NOPASSWD: ALL
zabbix ALL=NOPASSWD: /usr/bin/systemctl restart*
zabbix ALL=NOPASSWD: /usr/bin/systemctl start zabbix-agent2

test on zabbix agent host

sudo -u zabbix sudo systemctl restart zabbix-agent2