Description
The ZABBIX monitoring server has been configured to monitor Linux hosts using Zabbix.
Specific operation:
The following operations are performed on the monitored Linux hosts, with the CentOS 6.x system as an example.
First, configure the firewall, open 10050, 10051 TCP and UDP ports
Vi/etc/sysconfig/iptables #编辑防火墙配置文件
-A input-s 192.168.21.127-m state--state new-m tcp-p TCP--dport 10050:10051-j ACCEPT
-A input-s 192.168.21.127-m state--state new-m udp-p UDP--dport 10050:10051-j ACCEPT
: wq! #保存退出
Service iptables Restart #重启防火墙使配置生效
Description: 192.168.21.127 is the IP address of the Zabbix server, which indicates that the port is open only to this IP, and if it is open to all IPs, the rules are as follows:
-A input-m state--state new-m tcp-p TCP--dport 10050:10051-j ACCEPT
-A input-m state--state new-m udp-p UDP--dport 10050:10051-j ACCEPT
Second, to close SELinux
Vi/etc/selinux/config
#SELINUX =enforcing #注释掉
#SELINUXTYPE =targeted #注释掉
Selinux=disabled #增加
: wq! #保存退出
Setenforce 0 #使配置立即生效
Third, install Zabbix client
1. Zabbix Package Download
zabbix-2.2.6
Http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.2.6/zabbix-2.2.6.tar.gz
Upload zabbix-2.2.6.tar.gz to the server/USR/LOCAL/SRC directory below
2. Add Users
Groupadd Zabbix #创建用户组zabbix
Useradd zabbix-g zabbix-s/bin/false #创建用户zabbix, and add user Zabbix to user group Zabbix
3, Installation Zabbix
Ln-s/usr/local/lib/libiconv.so.2/usr/lib/libiconv.so.2 #添加软连接
/sbin/ldconfig #使配置立即生效
Cd/usr/local/src
Tar zxvf zabbix-2.2.6.tar.gz
CD zabbix-2.2.6
./configure--prefix=/usr/local/zabbix--enable-agent #配置
Make #编译
Make install #安装
Ln-s/usr/local/zabbix/sbin/*/usr/local/sbin/#添加系统软连接
Ln-s/usr/local/zabbix/bin/*/usr/local/bin/#添加系统软连接
Note: Compiling and installing the software requires the installation of a system package such as a compilation tool, and CentOS installs using the following command
Yum install apr* autoconf automake Bison cloog-ppl compat* cpp Curl curl-devel fontconfig fontconfig-devel freetype freety pe* freetype-devel gcc gcc-c++ gtk+-devel gd gettext gettext-devel glibc kernel kernel-headers keyutils keyutils-libs-deve L krb5-devel libcom_err-devel libpng* libjpeg* libsepol-devel libselinux-devel libstdc++-devel libtool* libgomp libxml2 L Ibxml2-devel libxpm* libtiff libtiff* libx* make MPFR ncurses* ntp OpenSSL openssl-devel patch pcre-devel perl php-common PHP-GD policycoreutils ppl telnet t1lib t1lib* nasm nasm* wget zlib-devel
4. Add the port corresponding to the Zabbix service
Echo ' zabbix-agent 10050/tcp #Zabbix agent ' >>/etc/services
Echo ' zabbix-agent 10050/udp #Zabbix agent ' >>/etc/services
Echo ' Zabbix-trapper 10051/tcp #Zabbix trapper ' >>/etc/services
Echo ' Zabbix-trapper 10051/udp #Zabbix trapper ' >>/etc/services
Or
Vi/etc/services #编辑, add the following code at the end
# Zabbix
Zabbix-agent 10050/tcp # Zabbix Agent
Zabbix-agent 10050/UDP # Zabbix Agent
Zabbix-trapper 10051/tcp # Zabbix Trapper
Zabbix-trapper 10051/UDP # Zabbix Trapper
: wq! #保存退出
5. Modify the Zabbix configuration file
Vi/usr/local/zabbix/etc/zabbix_agentd.conf #编辑
server=192.168.21.127
include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/
Unsafeuserparameters=1 #启用自定义key
: wq! #保存退出
Note: 192.168.21.127 is the Zabbix server IP address
6. Add Boot Script
Cp/usr/local/src/zabbix-2.2.6/misc/init.d/fedora/core/zabbix_agentd/etc/rc.d/init.d/zabbix_agentd
Vi/etc/rc.d/init.d/zabbix_agentd #编辑
basedir=/usr/local/zabbix/#Zabbix安装目录
: wq! #保存退出
chmod +x/etc/rc.d/init.d/zabbix_agentd #添加脚本执行权限
Chkconfig Zabbix_agentd on #添加开机启动
Service Zabbix_agentd Start #启动Zabbix客户端
PS Ax|grep zabbix_agentd #检查Zabbix客户端是否正常运行
NETSTAT-UTLNP | grep Zabbix #检查Zabbix客户端是否正常运行
Iv. Test Zabbix client and Zabbix server communication is normal
The following code is executed on the Zabbix server
/usr/local/zabbix/bin/zabbix_get-s192.168.21.128-p10050-k "System.uptime"
5049866 #有数据显示说明通信正常
Note: 192.168.21.128 is the Zabbix client IP address
V. Add monitoring of the Linux host
Open in Browser:
http://192.168.21.127/zabbix/#Zabbix服务端访问地址
Configuration-Host
Create a host
Host Name: 192.168.21.128
Group: Linux Servers
Interface for endpoint Agent-IP address: 192.168.21.128
Status: Under Monitoring
Other options are available by default
Switch to Template
Choose
Select: Template OS Linux
Point to add
Archive
At this point, the Zabbix monitoring Linux host setup is complete.