本章续上篇Zabbix安装部署之后。继续做后续分享:
1、首先做个visudo,为了减少zabbix和root之间的来回切换,减少不必要的时间:
#visudo
ALL ALL=(ALL) NOPASSWD: ALL
2、其次,做zabbix启动脚本,减少去/usr/local/zabbix/sbin启动:
sudo cp /home/zabbix/zabbix-2.2.7/misc/init.d/fedora/core/zabbix_server /etc/init.d/
3、制定启动脚本的家目录
sudo vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix
4、zabbix_agent的配置
sudo vim /usr/local/zabbix/etc/zabbix_agentd.conf
ListenPort=10050 #zabbix_agent监听的port
Server=192.168.38.4 #zabbix_server的地址
Hostname=192.168.38.4 #被监控主机IP
EnableRemoteCommands=1 #允许执行远程命令
配置完成重启agent的客户端。
5、zabbix_agentd实例测试
列出items
[zabbix@localhost sbin]$ ./zabbix_agentd -p | grep uptime
system.uptime
6、测试key
[zabbix@localhost bin]$ ./zabbix_get -s 192.168.38.4 -k ‘system.uptime‘
3655
7、其他主机添加客户端:
zabbix_server:192.168.38.4
zabbix_agent:192.168.38.3
zabbix_agent:192.168.38.5
分别在192.168.38.3和192.168.38.5上建用户zabbix,做visudo:
分别cpzabbix_server上的编译安装目录到另外2台zabbix_agent上
[zabbix@localhost local]$ sudo scp -r zabbix 192.168.38.3:/usr/local/
[zabbix@localhost local]$ sudo scp -r zabbix 192.168.38.5:/usr/local/
授权zabbix目录的权限为zabbix:
[zabbix@localhost local]$ sudo chown zabbix:zabbix zabbix -R
8、zabbix_agent的配置(下面的配置在192.168.38.5上也做一份)
sudo vim /usr/local/zabbix/etc/zabbix_agentd.conf
ListenPort=10050 #zabbix_agent监听的port
Server=192.168.38.4 #zabbix_server的地址
Hostname=192.168.38.3 #被监控主机IP
EnableRemoteCommands=1 #允许执行远程命令
启动zabbix_agent:
cd /usr/local/zabbix/sbin
./zabbix_agentd
9、查看zabbix_agent的端口:
[zabbix@localhost sbin]$ netstat -antlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2721/./zabbix_agent
tcp 0 52 192.168.38.3:22 192.168.38.101:49475 ESTABLISHED -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 ::1:25 :::* LISTEN -
10、zabbix_server端做key测试:
[zabbix@localhost bin]$ ./zabbix_get -s 192.168.38.3 -k ‘system.uptime‘
4539
本文出自 “LINUX Super梦” 博客,请务必保留此出处http://215687833.blog.51cto.com/6724358/1774143
原文地址:http://215687833.blog.51cto.com/6724358/1774143