zabbix enterprise-level monitoring (simple operation, page optimization, monitoring host itself, monitoring linux, monitoring Win10)
Table of contents
1. Zabbix installation and deployment
2. Graphical operation: web installation zabbix
Fourth, Zabbix monitors itself
Overall server settings:
CPU name | IP address | system | Function |
weak1 | 192.168.59.137 | linux | server agent |
weak3 | 192.168.59.140 | linux | agent |
Win10 | 192.168.59.128 | windows10 | agent |
1. Zabbix installation and deployment
Experimental environment preparation: (a single server monitors itself)
(1) Environment configuration:
1. Turn off the firewall
systemctl stop firewalld iptables -F setenforce 0
2. Test whether you can access the Internet
nslookup www.baidu.com
3. Configure the local hosts file (in preparation for monitoring other servers later)
4. Configure Aliyun yum source (please pay attention to the host name in the following experimental operations!!!)
cd /etc/yum.repos.d/
wget http://mirrors.aliyun.com/repo/Centos-7.repo
5. Install the lamp platform and the required dependencies
yum install -y httpd mariadb-server mariadb
mariadb-devel php php-mbstring php-mysql php-bcmath php-gd php-xmlrpc php-ldap php-xml libevent libevent-devel net-snmp net-snmp-devel libxml2 libxml2-devel ntpdate curl-devel gcc-c++
//Deploy the lamp environment to provide zabbix access page, some of the PHP options are to provide support for zabbix
6. Synchronization time
ntpdate time.windows.com // Tsinghua University time server
7. Start LAMP corresponding service
systemctl start mariadb
systemctl enable mariadb //Set to boot
systemctl start httpd
systemctl enable httpd
mysqladmin -u root password 123123 //Set a password for the mysql root user
mysql -uroot -p123123 login authentication
8. Prepare the java environment
java -version
javac -version // javac is required when monitoring tomcat
The above environment is not suitable for the need to add a suitable java environment
//Re-deploy the java environment after deleting
which java
rm -rf /usr/bin/java
tar xf jdk-8u91-linux-x64.tar.gz
mv jdk1.8.0_91/ /usr/local/java
vim /etc/profile
Configuration: (add at the end)
export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin
tail -2 /etc/profile
source /etc/profile
java -version
javac -version
which java
9. Install zabbix from source code (unpack, configure, compile, install)
tar xf zabbix-3.4.11.tar.gz -C /usr/src/
cd /usr/src/zabbix-3.4.11/
./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --enable-java && make -j2 && make install
--prefix=/usr/local/Zabbix specifies the installation location
--enable-server --enable-agent enable zabbix and agent
See ./configure –help for details
10. Mariadb database authorization
mysql -u root -p123123
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
grant all on zabbix.* to zabbix@'192.168.59.137' identified by 'zabbix';
//This step is to start authorization for zabbix_server
flush privileges;
cd /usr/src/zabbix-3.4.11/
//Import the mysql data required by zabbix
mysql -uzabbix -pzabbix zabbix < schema.sql
mysql -uzabbix -pzabbix zabbix < images.sql
mysql -uzabbix -pzabbix zabbix < data.sql
Login to view
mysql -u root -p123123
use zabbix;
show tables;
11. Create a zabbix program user and authorize to prevent permission error reporting
useradd -M -s /sbin/nologin zabbix
cd /usr/local/zabbix/
mkdir logs
chown -R zabbix:zabbix ../zabbix/
cp -p etc/zabbix_server.conf{,.bak}
cp -p etc/zabbix_agentd.conf{,.bak}
12. Modify the zabbix configuration file
vim zabbix_server.conf (server)
The configuration is as follows:
LogFile=/usr/local/zabbix/logs/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBHost=192.168.59.137
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
Notes:
LogFile=/usr/local/zabbix/logs/zabbix_server.log #Specify zabbix log location
PidFile=/tmp/zabbix_server.pid #Specify the zabbix pid file location
DBHost=192.168.200.111 #Specify the database host
DBName=zabbix #Specify the database name as zabbix
DBUser=zabbix #Specify the user as zabbix
DBPassword=zabbix #Specify the password as zabbix
DBSocket=/var/lib/mysql/mysql.sock #Specify the sock file of the mariadb database
Include=/usr/local/zabbix/etc/zabbix_server.conf.d/*.conf
vim zabbix_agentd.conf (client)
The configuration is as follows:
PidFile=/tmp/zabbix_agentd.pid
Server=127.0.0.1,192.168.59.137
ServerActive=192.168.59.137
Hostname=shuyang1 #Specify zabbixserver host name
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
ln -s /usr/local/zabbix/sbin/* /usr/local/bin
The zabbix_server command starts after making a soft connection
zabbix_agentd
13. Configure php and apache
mv /usr/src/zabbix-3.4.11/frontends/php/
/var/www/html/zabbix
chown -R apache:apache /var/www/html/zabbix
14. Modify the php configuration file
vim /etc/php.ini
The configuration is as follows:
878 date.timezone = Asia/Shanghai ##time zone
384 max_execution_time = 300 ##Unit seconds, limit the time to receive data through POST, GET and PUT
394 max_input_time = 300 ##The time limit when the php program uploads the file and parses the data
672 post_max_size = 32M ##The maximum size allowed by POST request data
405 memory_limit = 128M ##Set the memory limit of the php program
854 extension=bcmath.so ##Add the extension module bcmath.so that needs to be loaded manually when loading the zabbix program
15. Restart the httpd service and check the port
systemctl restart httpd
netstat -anpt | egrep ':10050|:10051|:80'
2. Graphical operation: web installation zabbix
Visit http://192.168.59.137/zabbix
Click next step
Enter the following information:
host is the address of the current listening machine
The port number is the port 3306 of the database
Name, user, and password are all zabbix
The name can be written or not, the next step (here I fill in as admin)
Confirm the information, click Next
success! finish
Go to the login page (username: admin, password: zabbix)
Enter the full English interface
3. Zabbix page optimization
1. Adjust the zabbix page to a Chinese page
Refresh the interface to display Chinese information
2. Solve the problem of Chinese garbled characters
cd /var/www/html/zabbix/fonts/
Upload a font, as follows
Replace fonts, change attributes
chown -R apache:apache *
Refresh verification: (has become Chinese)
Fourth, Zabbix monitors itself
Add yourself as a monitored machine
The configuration is as follows:
As follows: Continue to configure the template
Click Add first, then Update
As follows: After adding, click Update
As follows: You can already see the monitoring data
Change: The color of ZBX turns green, indicating that the monitoring has data at this time
Enter the monitoring page, graph, select group, user, monitoring information, view
Monitoring succeeded!
Five, monitor the linux host:
[agent configuration] (monitoring the second linux server)
1. Install zabbix from source code (unpack, compile, configure, install)
yum -y install libxml2-devel libcurl-devel pcre-devel ntpdate //Install dependent packages
ntpdate s1a.time.edu.cn //Network time synchronization Tsinghua University source
tar xf zabbix-3.4.11.tar.gz -C /usr/src/
cd /usr/src/zabbix-3.4.11/
./configure --prefix=/usr/local/zabbix --enable-agent --with-net-snmp --with-libcurl --with-libxml2 && make -j2 && make install
Note: --enable-agent enable agent
cp misc/init.d/tru64/zabbix_agentd /etc/init.d/ //copy startup script
vim /etc/init.d/zabbix_agentd
24 DAEMON=/usr/local/zabbix/sbin/zabbix_agentd //Change to the installation path
chmod +x /etc/init.d/zabbix_agentd //Add execution permission
useradd -M -s /sbin/nologin zabbix //create program user
cd /usr/local/zabbix
mkdir logs
chown -R zabbix:zabbix /usr/local/zabbix/
//Authorization installation directory
2. Change the agent configuration file
cp /usr/local/zabbix/etc/zabbix_agentd.conf{,.bak}
vim /usr/local/zabbix/etc/zabbix_agentd.conf
The configuration is as follows:
PidFile=/tmp/zabbix_agentd.pid
Server=192.168.200.111
ServerActive=192.168.200.111
Hostname=agent.zabbix.com
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log
Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf
3. Start the service
service zabbix_agentd start //Start the agent client
Zabbix agent started.
netstat -antp | grip 10050
Graphics operation:
Configuration--->Host--->Create Host
huyang3--->linux server--->192.168.59.140--->add
as follows:
Configuration template: update after adding
Refresh until ZBX turns green, as follows:
Monitor ---> Graphics ---> Group ---> Host ---> Graphics selection view (this memory)
6. Monitor Win10 host:
Wind10 configuration:
Server related information:
Close the firewall, the IP address is 192.168.59.128
1. First create the zabbix folder in the root directory of the C drive
2. Drag the required files into this folder (all files under bin/win64 and conf)
3. Modify the windows configuration file (zabbix.agent.win.conf) in three places as follows
Server=192.168.59.137
ServerActive=192.168.59.137
Hostname=win10
4. Start zabbix in Windows (Note: Please strictly install the document operation for the following operations, otherwise an error will be reported)
5. Install the agent and start the service
cd /zabbix
zabbix_agentd.exe -c zabbix_agentd.win.conf -i install
zabbix_agentd.exe -c zabbix_agentd.win.conf -s start
netstat -an|find "10050" to view the proxy port
Web graphics operations:
Configuration--->Host--->Create Host
Configuration--->host--->win10--->name, new group, ip--->add
Configuration--->Host--->Template-->Indicator Selection--->Add--->Update
Refresh after waiting for a period of time (1-2 minutes) , and operate after ZBX turns green
Note that windows closes the firewall
Monitor ---> Graphics ---> Group ---> Server ---> View Content, as shown below: