Why you need to understand the monitoring architecture
For example: our eight-member team is called "Ghost Eight Immortals"; if we want to fight with others, the 13-member team is called "Thirteen Taibao". According to the name, we can't do it. Even if we have done it, our The loss is definitely greater than others.
Therefore, according to different network environment, monitoring scale and other comprehensive factors, choose a suitable monitoring architecture.
- The direct connection architecture is also called the server-client architecture. It is suitable for occasions where the network environment is simple and the scale of monitoring is small. For example, it is like "the peerless double pride", with only two people.
- The proxy architecture is suitable for monitoring medium-sized networks.
- Node architecture, translate Chinese nodes, each node has its own configuration file and database, when the main server fails, the node can still ensure the integrity of the architecture, suitable for large-scale distributed monitoring environment, Beijing, Tianjin, etc. have many network areas. Monitoring not only ensures that the delay is small, but also does not affect other nodes in the event of a failure.
Reminder: Use zabbix as the monitoring server, and the monitoring objects are Linux servers, Windows servers, and network devices. The switch adopts GNS3 simulator to simulate.
1. Build a network environment to ensure network connectivity
Sw2#en //Enter user mode
Sw2#conf t //Enter privileged mode
Sw2(config)#int ran f0/0 -3 //Enter f0/0 to f0/3 interface
Sw2(config-if-range)# no sh //Open interface
Sw2(config-if-range)#exit //Exit interface configuration mode
Sw2(config)#int vlan 1 //Enter vlan1
Sw2(config-if)# ip add 192.168.2.254 255.255.255.0 //Set vlan1ip address
Sw2(config)# no sh //Open the interface
Test network environment : Test that the router can ping each device Windows, Linux host and zabbix server
2. Configure the Zabbix server 192.168.2.1
Note: In the experimental environment, turn off the firewall and set the setenfoce to permissive mode
1. Install MariaDB (the configuration of yum warehouse is omitted)
[[email protected] ~]# mount /dev/cdrom /mnt/ //Mount the system CD
[[email protected] ~]# yum -y install mariadb-server mariadb //install mariadb
[[email protected] ~]# systemctl start mariadb .service //Start mariadb
[[email protected] ~]# systemctl enable mariadb.service //Set self-starting
[[email protected] ~]# mysqladmin -u root password '123456' //Set mysql-root password
2. Install zabbix
[[email protected] ~]# umount /mnt //Uninstall the system disk
[[email protected] ~]# eject
[[email protected] ~]# mount /dev/cdrom /mnt/ //Mount the zabbix installation package and
give it to friends Upload CSDN, the link is the zabbix monitoring system series installation package
[[email protected] ~]# yum clean all //Use another yum warehouse to install in the previous step, you must empty the yum source, otherwise, an error will be reported
[[email protected] ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
//Install zabbix and the required software, if you also monitor the zabbix server itself, you need to install an agent
[[email protected] ~]# mysql -u root -p //Log in to the database
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; //Create the database required by zabbix
MariaDB [(none)]> grant all privileges on zabbix.* to [email protected] identified by '123456'; //Create user required by zazbbix
3. Edit the configuration file
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.1/create.sql.gz | mysql -uzabbix -p zabbix //Import the database script (input the set zabbix password)
[ [email protected] ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak //Back up the main zabbix configuration file
[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf // Edit the main configuration file
The reference configuration is as follows:
4. Install zabbix web interface
[[email protected] ~]# vim /etc/httpd/conf.d/zabbix.conf //Modify the web time zone file
[[email protected] ~]# systemctl start httpd //Restart the httpd service
5. Log in to the zabbix management platform (graphical interface).
Open the browser to visit the URL: http://zabbix IP address/zabbix
login control interface to
solve the Chinese garbled
[[email protected] ~]# cp /mnt/simkai.ttf /usr/share/zabbix/fonts/ //Copy the font package in the CD to the local
[[email protected] ~]# chmod 755 /usr/share/zabbix/fonts /simkai.ttf //Set permissions
[[email protected] ~]# vim /usr/share/zabbix/include/defines.inc.php //Modify the php configuration file Change the
font name of line 47 to simkai
Three, use zabbix to monitor equipment
- Monitor the Linux host (install the agent on the Linux host that needs to be monitored)
Note: Edit the zabbix agent configuration file /etc/zabbix_agentd.conf, you must specify the IP address of the zabbix server, which must be configured on each host where the agent is installed, Here you need to specify the IP address of the zabbix server, if it is on the same server, you don’t need to modify it.
Host configuration of the monitored Linux system
Install the zabbix
agent : rpm -ivh /mnt/zabbix-agent-3.2.6-1.el7.x86_64.rpm Edit the agent configuration file: vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.2.1 // 客户端被动等待指定服务器来查询数据（填zabbix服务器地址） ServerActive=192.168.2.1 // 客户端主动提交数据到指定的服务器（填zabbix服务器地址） Hostname=linux-server001 //修改
Zabbix server management web page settings
View monitoring view
- Monitor network equipment (note: the picture is router monitoring, the switch method is the same)
switch(config) # snmp-server community centos RO //Set the read-only community polled by the server
switch(config) # snmp-server enable traps //Allow the sending of trap messages
switch(config) # snmp-server host 192.168.2.1 centos //Set the community
that sends trap messages Note: For individual devices, the red command part will report an error, as shown in the figure below:
Solution: Replace the command with switch( config) # snmp-server enable traps config
Zabbix server management page settings
Create graphical view
View monitoring view
- Monitor the Windows host (take Windows 7 as an example, the method is the same for other Windows versions)
1) Windows host settings
decompress the Windows client compressed package zabbix_agents_3.2.0.win.zip, there will be two folders win32 and win64 in the bin directory, according to Windows The version of the system is chosen by itself.
To facilitate the configuration, create the directory zabbix in the root directory of the c drive, find the /bin directory-select the 32/64 version (depending on your machine)-copy the files in the directory and the conf/Zabbix_agentd.win.conf file to The C:/Zabbix directory of the machine.
Note: It must be run as an administrator (system administrator user), it is recommended to open it with WordPad, (notepad, the character format will be messy) modify zabbix——agentd.win.conf file
Server=192.168.2.1 // zabbix server address
ServerActive= 192.168.2.1 //
zabbix server address Hostname=windows-server001 // Keep the same as the following steps, zabbix management page configuration name.
-i install -s start -c specify configuration -x stop -d uninstall
If an error is reported, it may be created The folder is read-only by default, remove the read-only check; it may also be that the currently logged-in user has insufficient permissions and is not a system administrator. As shown below:
choose to run as an administrator
2) Zabbix server management page settings
View monitoring view
4. Zabbix custom monitoring project (can monitor a certain service, such as: web, FTP, mysql)
1) Operate on the monitored host
Create a directory for storing monitoring scripts
mkdir -p / etc/zabbix/zabbix_scripts/
Create a monitoring script named check_apache.sh
vim /etc/zabbix/zabbix_scripts/check_apache.sh //Note that the name of the process to be monitored does not appear in the script name
#!/bin/bash result=`ps -ef |grep httpd | grep -v grep` if [ -n "$result" ] //脚本参数 -n判断是否存在 then echo "1" else echo "0" fi
Modify the configuration to allow special characters in the script
line 284, remove the # sign, and change the parameter 0 to 1
and create the name userparameter_ apache in the /etc/zabbix/zabbix_agent.d/ directory .conf file
Add custom monitoring items to this file, the format is UserParameter=<key value>,<command>
Restart the zabbix agent service: systemctl restart zabbix-agent
Zabbix Server management page settings (first click to add monitoring items, I have added successfully, so the following is "update", the first setting, the lower left corner is "add")
Reverse verification: turn off the web service (simulation exception)
forward verification: Start the web service, the red mark position becomes 1
1. Zabbix agent [127.0.0.1] received an empty response
Place the mouse in the red English and prompt: Received empty response from Zabbix Agent at [127.0.0.1]. Assuming that agent dropped connection because of access permissions.
Translation: An empty response was received in the Zabbix agent [127.0.0.1]. Suppose the agent is disconnected due to access rights.
Analysis: The interface address must be filled in with the address of the monitored terminal, and the proxy address 127.0.0.1 network device cannot set this address, so filling in the correct address can solve the problem.
Solution: Change to the address of the access port where the agent is installed, that is, the Windows host address 192.168.2.3, refresh it several times
2. The route that did not reach the host 192.168.2.3
Translated red English prompt: failed to obtain the value from the agent, did not reach the route of the host 192.168.2.3
Analysis: IP address problem, two problems were found after investigation:
1. The Windows host forgot to configure the ip address; 2. The Windows host installs the agent step, and the ip address of the agent configuration file is filled in incorrectly;
Solution: In the virtual machine environment, only Windows snapshots can be restored and redoed.
3. The monitored end of the Linux system cannot start the agent program. It
can track system logs, a lot of information, and find key reminders. A local policy is required to allow access and there is no PID file.
The previous tip indicates that it is obvious that the firewall or setenfoce has rejected this request for service. The latter one usually has no ip address, a typical composite problem. These two problems can be solved at the same time.
Solution: Turn off the firewall, set setenfoce to permissive mode, and configure ip