Zabbix遠程命令執行失敗
問題 : 手機上收到tomcat server【80】 down信息,服務down掉,往往都是有重啟操作。重啟失敗才會報警。如果重啟操作執行了,我們就需要查看為何不能啟動?
Trigger: Tomcat service【80】is down Trigger status: PROBLEM Trigger severity: Disaster Trigger URL: Item values: 1. Tomcat status (192.168.96.200:net.tcp.listen[80]): 0 2. *UNKNOWN* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN* 3. *UNKNOWN* (*UNKNOWN*:*UNKNOWN*): *UNKNOWN* Original event
主機說明:
192.168.96.113: zabbix server
192.168.96.115: zabbix proxy 用於監控主機
192.168.96.200: 被監控的主機
1. 先查看重啟動作是否執行。
服務down掉,往往都是有重啟操作。重啟失敗才會報警。如果重啟操作執行了,我們就需要查看為何不能啟動?首先確保重啟操作是否實行成功。登錄zabbix web端查看動作的執行,【報表】--> 【動作日誌】如下圖:
如圖,可以看到此命令執行失敗,並且提示可能是訪問拒絕。我們需要進一步確認出錯是否為訪問問題。
2. 查看執行命令主機日誌
登錄192.168.96.200,並查看其zabbix agent端日誌。
[root@GPU ~]# tail -5 /var/log/zabbix/zabbix_agentd.log
2325:20170906:192653.587 active check configuration update from [192.168.96.115:10051] started to fail (cannot connect to [[192.168.96.115]:10051]: [4] Interrupted system call) 2325:20170906:192753.599 active check configuration update from [192.168.96.115:10051] is working again 2322:20170906:192754.512 failed to accept an incoming connection: connection from "192.168.96.113" rejected, allowed hosts: "192.168.96.115" 2324:20170906:155824.924 failed to accept an incoming connection: connection from "192.168.96.113" rejected, allowed hosts: "192.168.96.115" 2323:20170906:160824.587 failed to accept an incoming connection: connection from "192.168.96.113" rejected, allowed hosts: "192.168.96.115"
從日誌中我們可以知道,zabbix server 192.168.96.113 試圖與 192.168.96.200建立連接,192.168.96.200拒絕連接,因為他只能允許192.168.96.115。
3. 解決問題
192.168.96.113用代理服務器192.168.96.115采集數據,而遠程命令是無法交由proxy執行(zabbix server 和zabbix proxy 支持的文件看附錄一)。
grep ^[A-Z] /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
EnableRemoteCommands=1
LogRemoteCommands=1
Server=192.168.96.115
ServerActive=192.168.96.115
Hostname=192.168.96.200
Include=/etc/zabbix/zabbix_agentd.d/
可以看到server僅為192.168.96.115,故192.168.96.113無法執行遠程命令。我們需要將server=10.60.96.115修改為server=10.60.96.113,10.60.96.115。
註意 : zabbix agent 配置文件修改需要重啟服務,
centos 6上: ~]# service zabbix-agent start
centos 7 上:~]# systemctl start zabbix-agent
編譯安裝:請找到安裝目錄下的sbin目錄,並運行zabbix_agentd命令。
附錄一:
Function | Supported by proxy |
---|---|
Zabbix agent checks | Yes |
Zabbix agent checks (active) | Yes |
Simple checks | Yes |
Trapper items | Yes |
SNMP checks | Yes |
SNMP traps | Yes |
IPMI checks | Yes |
JMX checks | Yes |
Log file monitoring | Yes |
Internal checks | Yes |
SSH checks | Yes |
Telnet checks | Yes |
External checks | Yes |
Built-in web monitoring | Yes |
Network discovery | Yes |
Low-level discovery | Yes |
Calculating triggers | No |
Processing events | No |
Sending alerts | No |
Remote commands * | No |
Zabbix遠程命令執行失敗