Label archiving: Zabbix monitoring

One click installation script of Zabbix Server 5

Zabbix One Click Installation Script

The Zabbix one click installation script is maintained for a long time. It supports highly customized, interactive, and multi version selection of multi technology stacks. Nginx/PHP/MySQL/MariaDB/Zabbix/Administrator/phpMyAdmin/Grafana can be installed as required, which is applicable to CentOS 7~8 systems with x86_64 bit architecture.

Installation mode : Nginx/Zabbix compilation and installation, MySQL/MariaDB binary installation, and Grafana rpm installation All installation packages are from the software official. In addition, since most of the official software is downloaded from foreign sources slowly, please ensure the SSH terminal connection status during the download.

Script Properties

  • Support Nginx-1.21 and Grafana-7.4;
  • Support selective installation of Zabbix Server/Agent;
  • Support multiple database versions (MySQL-8, MariaDB-10.5);
  • Support multiple PHP versions (PHP-7.4, PHP-8.0);
  • Support multiple database management tools (Adminer-4, phpMyAdmin-5);

Latest version (2022-04-18)

After connecting to your Linux server using the SSH connection tool, copy and execute the following command to start the installation:

 curl -O  https://renwole.com/sh/install_zabbix_v0.9.2.sh  && bash install_zabbix_v0.9.2.sh

Installation process description: https://renwole.com/ilnmp/install-zabbix

Information about Zabbix after installation:

  • Zabbix UI entry: http://IP/ui
  • Zabbix management platform account password: Admin/zabbix
  • Zabbix database/account/password: zabbix/zabbix/zabbix

Information about Grafana after installation:

  • Grafana installation using rpm
  • Grafana UI Portal: http://IP:3000
  • Grafana UI login account/password: admin/admin

Script Support Module

Module Name describe
enable-server Enable Zabbix Server
enable-agent Enable Zabbix agent
enable-proxy Enabling the Zabbix proxy can collect data on behalf of a single Zabbix server to share the load
enable-ipv6 Enable support for IPV6 protocol
enable-java Enable Zabbix Java gateway to support monitoring JMX applications
with-mysql Enable MySQL as the back-end storage database
with-iconv Enable transcoding, such as GBK to UTF-8, to prevent garbled codes
with-libcurl Components required to enable Web monitoring, VMware monitoring, and SMTP (mail sending)
with-libxml2 Enabling components required for VMware monitoring
with-ssh2 SSH checks are performed as agentless monitoring. The Zabbix Agent is not required for SSH check
with-openipmi Enable IPMI protocol to monitor server temperature, fan speed, etc
with-net-snmp Enable SNMP protocol to monitor printers, routers, UPS and other devices
The above modules have been automatically added and enabled in the compilation and installation of zabbix.

Application installation directory

Software name route explain
Nginx/PHP/MySQL/Zabbix /apps/server All ILNMP Application installation and data storage directory
Zabbix ConfigFile /apps/server/zabbix/etc Zabbix Server monitoring installation directory
Grafana Rpm installation mode path system default The configuration file is under/etc/

Update logs and historical versions View and download

Centos 7 Zabbix Agent Client Source Code Compilation, Installation and Configuration

The Zabbix Agent is installed on a remote system and needs to be monitored through the Zabbix server. The Zabbix Agent collects resource utilization and application data on the client system and provides this information to the Zabbix server. Zabbix supports Ping, ZBX, SNMP, JMX, IPMI and other monitoring methods.

1. Install expansion packs and dependent packs

 $ yum -y install epel-release $ yum install pcre pcre-devel openssl openssl-devel -y

2. Add Zabbix users and groups

 $ groupadd zabbix $ useradd zabbix -g zabbix -s /sbin/nologin

3. Install Zabbix Agent

Download address://www.zabbix.com/download

 $ cd /tmp $ tar -zxvf zabbix-3.4.2.tar.gz $ cd zabbix-3.4.2 $ ./ configure --prefix=/usr/local/zabbix --enable-agent --with-mysql --with-openssl $ make && make install

4. Create the Zabbix log directory and generate the (PSK) key

 $ mkdir -p /usr/local/zabbix/logs/ $ chown -R zabbix.zabbix /usr/local/zabbix $ sh -c "openssl rand -hex 32 > /usr/local/zabbix/etc/zabbix_agentd.psk" $ cat /usr/local/zabbix/etc/zabbix_agentd.psk fd1ac849e5f787dfc04300ae997d158e6f6f0c2209d66e7d2e687da2032ecbae

5. Configure zabbix_agentd.conf

The following is the content after configuration:

 $ egrep -v "(^#|^$)" /usr/local/zabbix/etc/zabbix_agentd.conf EnableRemoteCommands=1 #Whether the remote command from the zabbix server can be executed PidFile=/usr/local/zabbix/zabbix_agentd.pid LogFile=/usr/local/zabbix/logs/zabbix_agentd.log Server=10.10.204.65 #Zabbix Server IP Address ServerActive=10.10.204.65 #The address is the same as above, and the monitoring content is actively sent to the Zabbix Server Hostname=101020465 #The content of the local host name should be consistent with the Host Name configured on the Zabbix Server HostMetadataItem=system.uname #Used for item to obtain data User=zabbix UnsafeUserParameters=1 #Whether to enable the user-defined key. The user-defined key is required when Zabbix monitors MySQL, tomcat and other data
 #The following uses the pre shared key (PSK) to protect the connection between the server and the client TLSConnect=psk TLSAccept=psk TLSPSKIdentity=PSK 001 TLSPSKFile=/usr/local/zabbix/etc/zabbix_agentd.psk

Note: For more optimization of agent configuration parameters, see here Zabbix agent (UNIX)

6. Create the system ctl system Zabbix agent unit file

 $ vim /usr/lib/systemd/system/zabbix-agent.service [Unit] Description=Zabbix Agent After=syslog.target After=network.target [Service] Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_agentd.conf" #EnvironmentFile=/usr/local/zabbix/etc/zabbix_agentd.conf.d/ Type=forking Restart=on-failure #PIDFile=/tmp/zabbix_agentd.pid KillMode=control-group ExecStart=/usr/local/zabbix/sbin/zabbix_agentd -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s [Install] WantedBy=multi-user.target

7. Start the Zabbix Agentd client service and join the startup

 $ systemctl start zabbix-agent $ systemctl enable zabbix-agent

8. Set Firewalld firewall

 $ firewall-cmd --permanent --add-port=10050/tcp $ firewall-cmd --reload

The installation of Zabbix Agent is complete. Later, I will write about the use and optimization of zabbix.

Zabbix Servers 3.4 Source Code Compilation and Installation

PS:

In fact, it is very simple to install zabbix. You can search a lot of online materials and basically install it in yum mode, which is simple and convenient. Because of this, I did not write the relevant configuration documents. The installation method is usually yum installation, source code installation or container installation. Recently, a netizen proposed it. I took it seriously and wrote the whole process of compiling and installing Linux Centos 7 Zabbix (Zabbix server). Later, I will also write some articles on the use and optimization of Zabbix.

Official recommendation:

Zabbix is an enterprise level distributed open source monitoring solution. It can monitor various network applications and server health and integrity software. The Zabbix server stores its data in a relational database supported by MySQL, MariaDB, PostgreSQL, or Oracle. All reports, statistics, and configuration parameters of Zabbix can be accessed and set through the Web based front-end page. And Zabbix is open source and free.

1. Installation environment (Hyper-V virtual machine):

 $ hostnamectl Static hostname: localhost.localdomain Icon name: computer-vm Chassis: vm Machine ID: renwoles1d8743989a40cb81db696400 Boot ID: renwoles272f4aa59935dcdd0d456501 Virtualization: microsoft Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-514.2.2.el7.x86_64 Architecture: x86-64

2. Since the front end of the Zabbix UI is written in PHP, it must run on a Web server that supports the PHP scripting language. Prerequisites:

Centos 7 Compile and Install nginx
Production of Compiling and Installing PHP 7 in Centos 7
Linux JAVA JDK JRE environment variable installation and configuration
Centos 7 binary installation MariaDB (MySQL) database

3. If your server already has a PHP environment, please skip step 2 and continue with the following configuration:

Configuring php.ini must meet the following requirements:

 max_execution_time = 300 max_input_time = 300 memory_limit = 128M post_max_size = 32M date.timezone = Asia/Shanghai mbstring.func_overload=2 #Zabbix PHP LDAP authentication is enabled (optional) extension = "/usr/local/php/lib/php/extensions/no-debug-zts-20160303/ldap.so"

4. Install dependent packages and create groups&users

 $ yum -y install epel-release && yum -y update $ yum install -y net-snmp-devel OpenIPMI-devel libssh2-devel iksemel-devel $ groupadd zabbix $ useradd -g zabbix zabbix

5. Install Zabbix Server

Download address://www.zabbix.com/download

 $ cd /tmp $ tar -zxvf zabbix-3.4.2.tar.gz $ cd zabbix-3.4.2 $ ./ configure --prefix=/usr/local/zabbix \ --sysconfdir=/usr/local/zabbix/etc \ --enable-server \ --enable-agent \ --with-mysql=/usr/bin/mysql_config \ --with-net-snmp \ --with-libcurl \ --with-libxml2 \ --enable-proxy \ --enable-ipv6 \ --enable-java \ --with-ssh2 \ --with-iconv \ --with-openipmi \ --with-ldap \ --with-openssl \ --with-jabber \ $ make $ make install

be careful: –enable-agent Optional, this parameter is mainly used for the client (the monitored).

Note: If you do not install the JAVA environment, please remove the – enable java option, which is mainly used to monitor Tomcat.

6. Create and grant Zabbix configuration file directory permission

 $ mkdir -p /usr/local/zabbix/logs $ chown -R zabbix.zabbix /usr/local/zabbix

7. Copy the source code of the Zabbix UI front-end program to the Nginx Web directory

 $ cp -rf /tmp/zabbix-3.4.2/frontends/php/* /apps/web/zabbix $ chown -R www.www /apps/web/zabbix

8. Create the database name: zabbix User: zabbix Password: renwolecom and give the user all permissions for the database:

 $ mysql -uroot -p Enter password: (Enter the root database password and press Enter) MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@"%" identified by 'renwolecom'; MariaDB [(none)]> flush privileges; MariaDB [(none)]> quit;

9. Import Zabbix related structure table files into Zabbix database in order

Import order schema.sql table structure>images. sql image library>data.sql initial script

 $ cd /tmp/zabbix-3.4.2/database/mysql $ mysql -uzabbix -prenwolecom zabbix < schema.sql $ mysql -uzabbix -prenwolecom zabbix < images.sql $ mysql -uzabbix -prenwolecom zabbix < data.sql

10. Configure zabbix_server.conf

The contents after configuration are as follows:

 $ egrep -v "^$|^#|^;" /usr/local/zabbix/etc/zabbix_server.conf LogFile=/usr/local/zabbix/logs/zabbix_server.log PidFile=/usr/local/zabbix/zabbix_server.pid LogFileSize=0 DBHost=10.10.204.62 DBName=zabbix DBUser=zabbix DBPassword=renwolecom JavaGateway=10.10.204.62 JavaGatewayPort=10052 StartJavaPollers=5 StartPingers=4 Timeout=4 AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts LogSlowQueries=3000 Include=/usr/local/zabbix/etc/zabbix_server.conf.d/

be careful: Since the parameter configurations of each production environment are different, I only list the basic commonly used configuration files, View more configuration parameters

11. Create the system ctl system Zabbix servers unit file

 $ vim /usr/lib/systemd/system/zabbix.service
 [Unit] Description=Zabbix Server After=syslog.target After=network.target [Service] Environment="CONFFILE=/usr/local/zabbix/etc/zabbix_server.conf" EnvironmentFile=-/usr/local/zabbix/etc/zabbix_server.conf.d Type=forking Restart=on-failure PIDFile=/usr/local/zabbix/zabbix_server.pid KillMode=control-group ExecStart=/usr/local/zabbix/sbin/zabbix_server -c $CONFFILE ExecStop=/bin/kill -SIGTERM $MAINPID RestartSec=10s TimeoutSec=0 [Install] WantedBy=multi-user.target

12. Start zabbix and add automatic startup

 $ systemctl start zabbix $ systemctl enable zabbix

13. Firewall Settings

 $ firewall-cmd --permanent --add-port=10051/tcp $ firewall-cmd --permanent --add-port=80/tcp $ firewall-cmd --reload

Installation is complete.

Next, you can use IP Or domain name to access the Zabbix monitoring management system. For specific settings, please refer to Zabbix Server Web The wizard prompts you to set it.

After setting, the Zabbix default account: Admin password: zabbix (Note that the account is case sensitive) After login, it is an English interface. Just click the villain icon in the upper right corner (current user settings) to locate Language Items, selecting Chinese (zh_CN) , click Update You can switch to the Chinese interface.

For the Zabbix proxy client, see《 Centos 7 Zabbix Agent Client Source Code Compilation, Installation and Configuration 》。

Permission denied cannot be started after Zabbix Agent configuration is completed

The newly installed Zabbix Agent on the node machine cannot be started today.

1. Check the Zabbix Agent log file to find out the reason.

 # cat /var/log/zabbix/zabbix_agentd.log 63133:20170601:092700.920 ************************** 63133:20170601:092700.920 using configuration file: /etc/zabbix/zabbix_agentd.conf 63133:20170601:092700.920 cannot set resource limit: [13] Permission denied 63133:20170601:092700.920 cannot disable core dump, exiting... 63137:20170601:092711.171 Starting Zabbix Agent [cong171163].  Zabbix 3.2.6 (revision 67849). 63137:20170601:092711.171 **** Enabled features **** 63137:20170601:092711.171 IPv6 support: YES 63137:20170601:092711.171 TLS support: YES 63137:20170601:092711.171 ************************** ......

2. At this time, you only need to turn off Selinux. There are two schemes;

2.1. Temporary closing

 # setenforce 0

2.2. Permanent shutdown (reboot host)

 # vim /etc/selinux/config SELINUX=enforcing

change

 SELINUX=disabled

3. After the operation is completed, start the zabbix agent service again

# systemctl start zabbix-agent.service

4. View ports

 # ss -tnl State Recv-Q Send-Q Local Address:Port Peer Address:Port  LISTEN 0 128 *:22 *:* LISTEN 0 100 127.0.0.1:25 *:*  LISTEN 0 128 *:10050 *:* LISTEN 0 80 :::3306 :::* LISTEN 0 128 :::22 :::* LISTEN 0 100 ::1:25 :::* LISTEN 0 128 :::10050 :::*

Zabbix agent starts successfully, and port 10050 is running.

Zabbix Chinese monitoring server graph chart shows garbled code

Zabbix's support for Chinese is not very good, but sometimes we still choose Chinese for management. In the web interface monitored by Zabbix, the Chinese under the graphical icon will display small blocks, which is incorrect and requires downloading fonts. For example, "Microsoft Yahei"

"Microsoft Yahei. ttf" is named "msyh. ttf"

Upload the downloaded font to/zabbix/fonts/font

Modify two places in the/zabbix/include/defines.inc.php file

 define('ZBX_GRAPH_FONT_NAME', 'DejaVuSans'); define('ZBX_FONT_NAME', 'DejaVuSans');

change

 define('ZBX_GRAPH_FONT_NAME', 'msyh'); define('ZBX_FONT_NAME', 'msyh');

Finally, restart the web server.