问题描述
监控客户机端配置监控项–检测sshd服务是否开启
[root@centos7-client1 zabbix_agentd.d]# cat sshd.conf
UserParameter=ssh_port,/bin/bash /server/scripts/check_ssh.sh
[root@centos7-client1 zabbix_agentd.d]# cat /server/check_ssh.sh
#!/bin/bash
netstat -lntup | grep "sshd" >/dev/null 2>&1
echo $?
监控服务端测试,报错
[root@centos7-server1 ~]# zabbix_get -s 192.168.238.136 -p 10050 -k ssh_port
情况反映
Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.
问题分析
zabbix_get是以zabbix(安装时创建的)身份执行,涉及到权限问题
netstat -p 非sudo用户是无权限使用的
问题解决
给命令文件加s或是将该用户加到sudoers文件下
[root@centos7-client1 zabbix_agentd.d]# chmod +s /bin/netstat
[root@centos7-server1 ~]# zabbix_get -s 192.168.238.136 -p 10050 -k ssh_port
0