This article mainly introduces that Zabbix monitoring server has been configured. to use Zabbix to monitor Linux hosts, you can refer to the following instructions:
The Zabbix monitoring server has been configured. now you need to use Zabbix to monitor Linux hosts.
Specific operations:
The following operations are performed on the monitored Linux host. the CentOS 6. x system is used as an example.
1. configure the firewall to enable TCP and UDP ports 10050 and 10051
Vi/etc/sysconfig/iptables # Edit the firewall configuration file
-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! # Save and exit
Service iptables restart # restart the firewall to make the configuration take effect
Note: 192.168.21.127 is the IP address of the Zabbix server, indicating that the port is only open to this IP address. to open it to all IP addresses, 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
II. disable SELINUX
Vi/etc/selinux/config
# SELINUX = enforcing # Comment out
# SELINUXTYPE = targeted # Comment out
SELINUX = disabled # Add
: Wq! # Save and exit
Setenforce 0 # Make the configuration take effect immediately
3. install the Zabbix client
1. download zabbix software package
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/usr/local/src directory on the server.
2. add a user
Groupadd zabbix # Create a user group zabbix
Useradd zabbix-g zabbix-s/bin/false # create user zabbix and add user zabbix to user group zabbix
3. install Zabbix
Ln-s/usr/local/lib/libiconv. so.2/usr/lib/libiconv. so.2 # Add a soft connection
/Sbin/ldconfig # Make the configuration take effect immediately
Cd/usr/local/src
Tar zxvf zabbix-2.2.6.tar.gz
Cd zabbix-2.2.6
./Configure -- prefix =/usr/local/zabbix -- enable-agent # configuration
Make # compile
Make install # install
Ln-s/usr/local/zabbix/sbin/*/usr/local/sbin/# add soft system connection
Ln-s/usr/local/zabbix/bin/*/usr/local/bin/# Add a soft system connection
Note: to compile and install the software, you must first install the compilation tool and other system software packages. CentOS uses the following command to install the software:
Yum install apr * autoconf automake bison cloog-ppl compat * cpp curl-devel fontconfig-devel freetype * freetype-devel gcc-c ++ gtk +-devel gd gettext -devel glibc kernel-headers keyutils-libs-devel krb5-devel libcom_err-devel libpng * libjpeg * libsepol-devel kernel-devel libstdc ++-devel libtool * libgomp lib2 libxml2-devel libXpm * libtiff * libX * make mpfr ncurses * ntp openssl-devel patch pcre-devel perl php-common php-gd yycoreutils ppl telnet t1lib t1lib * 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 # edit and 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! # Save and exit
5. modify the Zabbix configuration file
Vi/usr/local/zabbix/etc/zabbix_agentd.conf # Edit
Server = 192.168.21.127
Include =/usr/local/zabbix/etc/zabbix_agentd.conf.d/
UnsafeUserParameters = 1 # enable custom key
: Wq! # Save and exit
Note: 192.168.21.127 is the IP address of the Zabbix server.
6. add the 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 # Edit
BASEDIR =/usr/local/zabbix/# Zabbix installation directory
: Wq! # Save and exit
Chmod + x/etc/rc. d/init. d/zabbix_agentd # add the script execution permission
Chkconfig zabbix_agentd on # Add boot start
Service zabbix_agentd start # start the Zabbix client
Ps ax | grep zabbix_agentd # check whether the Zabbix client is running normally
Netstat-utlnp | grep zabbix # check whether the Zabbix client is running properly
4. test whether the communications between the Zabbix client and the Zabbix server are normal.
Run the following code on the Zabbix server:
/Usr/local/zabbix/bin/zabbix_get-s192.168.21.128-p10050-k "system. uptime"
5049866 # if data is displayed, the communication is normal.
Note: 192.168.21.128 is the IP address of the Zabbix client.
5. Add monitoring for Linux hosts
Open in the browser:
Http: // 192.168.21.127/zabbix/# Zabbix server access address
Select: Template OS Linux
Add point
Archive
So far, Zabbix has completed Linux host monitoring.
For more articles about how to configure Zabbix to monitor Linux hosts, refer to PHP!