Classified directory archiving: Zabbix

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

Zabbix: libssl.so.10: error adding symbols: DSO missing from command line

Configure predecessor task succeeded

 [ root@renwole.com  zabbix-5.0.1]# ./ configure --prefix=/apps/server/zabbix \ --sysconfdir=/apps/server/zabbix/etc --enable-server --enable-agent \ --with-mysql=/apps/server/mysql/bin/mysql_config --with-openssl \ --with-net-snmp --with-libcurl --with-libxml2 --enable-proxy --enable-ipv6 \ --enable-java --with-ssh2 --with-iconv --with-openipmi --with-ldap *********************************************************** *            Now run 'make install'                       * *                                                         * *            Thank you for using Zabbix!                  * *              < http://www.zabbix.com >                    * ***********************************************************

Failed to install Zabbix

 make install ... ssh2  -lOpenIPMI -lOpenIPMIposix -lz -lpthread -levent -lssl -lcrypto -lldap -llber   -lcurl -lm -ldl  -lresolv -lpcre -liconv /usr/bin/ld: warning: libssl.so.10, needed by /usr/lib64/libnetsnmp.so, may conflict with libssl.so.1.1 /usr/bin/ld: warning: libssl.so.10, needed by /usr/lib64/libnetsnmp.so, may conflict with libssl.so.1.1 /usr/bin/ld: ../../ src/libs/zbxcrypto/libzbxcrypto.a(libzbxcrypto_a-tls.o): undefined reference to symbol 'SSL_library_init@@libssl.so.10' //usr/lib64/libssl.so.10: error adding symbols: DSO missing from command line Collect2: Error: ld returns 1 Make [3]: * * * [zabbix_server] Error 1 Make [3]: leave directory "/opt/zabbix-5.0.1/src/zabbix_server" Make [2]: * * * [install recursive] Error 1 Make [2]: leave the directory "/opt/zabbix-5.0.1/src/zabbix_server" Make [1]: * * * [install recursive] Error 1 Make [1]: leave directory "/opt/zabbix-5.0.1/src" Make: * * * [install recursive] error 1

Analyze causes

 [ root@renwole.com  zabbix-5.0.1]# find / -name libssl.so.* /usr/lib64/libssl.so.1.0.2k /usr/lib64/libssl.so.10 /apps/server/mysql/lib/private/libssl.so.1.1

MySQL 8 depends on Openssl 1.1, while CentOS 7 installs Openssl 1.0 by default, so you need to upgrade Openssl 1.1.1, see《 How to upgrade OpenSSL 》, and then install Zabbix.

Zabbix Agent Remotely Install Shell(batch & Single)

Batch installation:

 #!/ bin/sh Server=10.16.8.8 ServerActive=10.16.8.8:10050 ip_array=("hostnamerenwole1" "hostnamerenwole2") for ip in ${ip_array[*]} do zabbix=$(ssh $ip 'find /etc -name zabbix_agentd.conf') if [ -f $zabbix ]; then ssh $ip 'rpm -ivh //repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm ;  yum -y install zabbix-agent' else echo "Already exist, no need to install" fi ssh $ip ' sed -i "s#Server=.*#Server='$Server'#" /etc/zabbix/zabbix_agentd.conf sed -i "s#ServerActive=.*#ServerActive='$ServerActive'#" /etc/zabbix/zabbix_agentd.conf sed -i "s#Hostname=.*#Hostname='$ip'#" /etc/zabbix/zabbix_agentd.conf sed -i "s/# UserParameter=/UserParameter=/g" /etc/zabbix/zabbix_agentd.conf sed -i "s#UserParameter=.*#UserParameter=pro.check,sh /renwole/Apps/check.sh|wc -c#" /etc/zabbix/zabbix_agentd.conf chmod -R 777 /etc/zabbix/zabbix_agentd.conf systemctl restart zabbix-agent ' done

Interactive installation:

 #cat /renwole/bin/Zabbix_Agent_Single.sh #!/ bin/sh read -p "Please enter the HostName:" HostName Server=10.16.8.8 ServerActive=10.16.8.8:10050 zabbix=$(ssh $HostName 'find /etc -name zabbix_agentd.conf') if [ -f $zabbix ]; then ssh $HostName 'rpm -ivh //repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm ;  yum -y install zabbix-agent' else echo "Already exist, no need to install" fi ssh $HostName ' sed -i "s#Server=.*#Server='$Server'#" /etc/zabbix/zabbix_agentd.conf sed -i "s#ServerActive=.*#ServerActive='$ServerActive'#" /etc/zabbix/zabbix_agentd.conf sed -i "s#Hostname=.*#Hostname='$HostName'#" /etc/zabbix/zabbix_agentd.conf sed -i "s/# UserParameter=/UserParameter=/g" /etc/zabbix/zabbix_agentd.conf sed -i "s#UserParameter=.*#UserParameter=pro.check,sh /renwole/Apps/check.sh|wc -c#" /etc/zabbix/zabbix_agentd.conf systemctl restart zabbix-agent '

Zabbix monitors Redis database performance

Note: All the following operations are performed on the Zabbix Agent client.

Deployment environment:

 OS:CentOS Linux release 7.4.1708 (Core) x64 Zabbix Servers:3.4 Redis Servers:4.0

precondition:

Linux Centos7 Redis source code compilation, installation and configuration

1. Modify the host

Add the following at the end of the file:

 $ vim /etc/hosts 10.28.204.65 s102820465

2. Install Python dependency package

 $ yum -y install python-pip $ pip install argparse $ pip install redis

3. Download the official template Redis template provided by Zabbix

Transfer the local compressed package to the tmp directory and decompress it:

//github.com/adubkov/zbx_redis_template

 $ cd /tmp $ tar zxvf zbx_redis_template-master.zip $ cd zbx_redis_template-master

Copy the following 2 configuration files to the relevant directory:

 $ cp zbx_redis_stats.py /usr/local/zabbix/bin $ cp zbx_redis.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

Note: Except for the above two files, others can be ignored. Because the official Zabbix template provides two schemes for monitoring Redis, namely node.js and python. This tutorial uses the latter.

4. Configure zbx_resis_stats.py

Modify the parameters in the following file to the host IP and port of the Zabbix Server:

 $ cd /usr/local/zabbix/bin $ vim zbx_redis_stats.py ... zabbix_host = '10.28.204.62' # Zabbix Server IP zabbix_port = 10051 # Zabbix Server Port ...

Give the file executable permissions:

 $ chmod +x zbx_redis_stats.py

5. Configure zbx_reredis.conf

 $ cd /usr/local/zabbix/etc/zabbix_agentd.conf.d/

Modify the file as follows:

 $ vim zbx_redis.conf UserParameter=redis[*],/usr/local/zabbix/bin/zbx_redis_stats.py -p 6379 -a RenwoleQxl5qpKHrh $1 $2 $3

6. Test whether zbx_resis_status.py can connect to the Redis database

 $ cd /usr/local/zabbix/bin $ ./ zbx_redis_stats.py -h 127.0.0.1 -p 6379 -a RenwoleQxl5qpKHrh usage: zbx_redis_stats.py [-h] [-p REDIS_PORT] [-a REDIS_PASS] [redis_hostname] [metric] [db] Zabbix Redis status script positional arguments: redis_hostname metric db optional arguments: -h, --help show this help message and exit -p REDIS_PORT, --port REDIS_PORT Redis server port -a REDIS_PASS, --auth REDIS_PASS Redis server pass

The above information indicates that the connection is normal.

Parameter description:

-H Redis bind address
-P Redis port
-A Redis password

7. Test whether data is obtained

 $ ./ zbx_redis_stats.py -p 6379 -a RenwoleQxl5qpKHrh S102820465 used_cpu_user_children none zero point seven one

Return 0.71. This value is not fixed. If data is returned, the script is running normally.

Parameter description:

The $1 $2 $3 in the zbx_reredis.conf file comes in handy at this time.

$1 corresponds to S102820465 host
$2 corresponds to used_cpu_user_children
$3 corresponds to none

Finally zbx_redis_templates.xml Template import to Zabbix Servers UI And then link to the host to be monitored.

If the data cannot be obtained in the Zabbix UI, you can click Zabbix Agent Client run directly zbx_redis_stats.py If the script is not configured correctly, it will be fed back and processed according to the error report.

Conclusion:

In fact, there are too many templates to monitor the status of Redis. They are basically the same. Choose one that is suitable for you. For example, there are many monitoring projects, so you can learn more about Redis performance indicators.

Zabbix monitors Nginx status performance

In fact, there are many related templates and setting methods for service status monitoring of nginx by Zabbix, which can be modified according to their own needs. Later, I will write some tutorials that are more detailed for the production environment.

Deployment environment:

OS:CentOS 7.4
WEB: Nginx 1.3
Monitoring: Zabbix 3.4

precondition:

Centos 7 source code compilation and installation Nginx

be careful: Mainly the – with http_stub_status_module module.

1. Modify nginx. conf

Add the following content in the server section:

 $ vim /usr/local/nginx/conf/nginx.conf location /stub_status { stub_status on; access_log off; allow 127.0.0.1; deny all; }

2. Restart the Nginx service and test the access

 $ systemctl restart nginx.service $ curl //127.0.0.1/stub_status Active connections: 1 server accepts handled requests 304 304 304 Reading: 0 Writing: 1 Waiting: 0

The data returned from the access indicates that the Nginx configuration is normal

3. Create Nginx monitoring script

Copy and save the following code as nginx. sh

 $ cd /usr/local/zabbix/bin $ vim nginx.sh
 #!/ bin/bash HOST="127.0.0.1" PORT="80" stub_status=stub_status function check() { /sbin/pidof nginx | wc -l } function active() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Active' | awk '{print $NF}' } function accepts() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $1}' } function handled() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $2}' } function requests() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| awk NR==3 | awk '{print $3}' } function reading() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Reading' | awk '{print $2}' } function writing() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Writing' | awk '{print $4}' } function waiting() { /usr/bin/curl -s "//$HOST:$PORT/${stub_status}/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } case "$1" in check) check ;; active) active ;; accepts) accepts ;; handled) handled ;; requests) requests ;; reading) reading ;; writing) writing ;; waiting) waiting ;; *) echo $"Usage $0 {check|active|accepts|handled|requests|reading|writing|waiting}" exit esac

4. Give the script execution permission

 $ chmod 755 nginx.sh

5. Create the userparameter_nginx.conf configuration file

 $ cd /usr/local/zabbix/etc/zabbix_agentd.conf.d

Add the following:

 $ vim userparameter_nginx.conf
 UserParameter=nginx.status[*],/usr/local/zabbix/bin/nginx.sh $1

6. Restart zabbix

 $ systemctl restart zabbix-agent.service

7. Import the template zbx_nginx_templates.xml

Click here to download the template

To import a template, add a host and link it to the Template App Nginx template.

Zabbix 3.4 JMX monitors Tomcat performance

precondition:

Zabbix Servers 3.4 Source Code Compilation and Installation
Linux Apache Tomcat 8.5 Installation and Configuration

If you have completed the deployment of the above installation, continue to the next step.

Zabbix server side configuration:

1. Configure zabbix_server.conf

Main parameters:

 ... #The address of the Java Gateway server. The zabbix server and the zabbix_java_gateway are on the same server. JavaGateway=10.10.204.62 JavaGatewayPort=10052 #Set the number of processes that the java gateway fetches data. When set to 0, it means that the java gateway does not have the ability to fetch java information. StartJavaPollers=5 ...

During the installation of Zabbix Servers, I have configured the above parameters.

2. Configure the Zabbix Java gateway

The contents after modification are as follows:

 $ egrep -v '^#|^$' /usr/local/zabbix/sbin/zabbix_java/settings.sh #Zabbix Servers IP LISTEN_IP="0.0.0.0" #Port LISTEN_PORT=10052 #The PID_FILE path must be correct. PID_FILE="/usr/local/zabbix/sbin/zabbix_java/zabbix_java.pid" #The START_POLLERS item is the number of entries and exits configured to start. If you do not configure zabbix_java, it can still start but cannot retrieve data. START_POLLERS=5 #Network timeout. TIMEOUT=3

3. Start zabbix_java

 $ /usr/local/zabbix/sbin/zabbix_java/startup.sh

After startup, you can check whether port 10052 is running through ss - ntlp.

Zabbix Agent Tomcat client configuration:

1. Add the following content on the line or top of Execute The Requested Command in catalina.sh file:

 $ vim /usr/local/tomcat/bin/catalina.sh
 export CATALINA_OPTS="-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=10.10.204.65"

Meaning description:

 CATALINA_OPTS="$CATALINA_OPTS -Dcom.sun.management.jmxremote #Enable JMX remote monitoring. -Dcom.sun.management.jmxremote.ssl=false #Whether to use SSL. -Dcom.sun.management.jmxremote.authenticate=false #Whether to enable authentication. -Djava.rmi.server.hostname=10.10.204.65" #The IP address of the server where Tomcat resides.

2. Modify the Tomcat server.xml configuration file

In<Server port="8005" shutdown="SHUTDOWN">line breaking, add the following:

 $ vim /usr/local/tomcat/conf/server.xml
 <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10053" rmiServerPortPlatform="10053"/>

3. Restart the Tomcat service

 $ systemctl restart tomcat

4. Set Firewalld

 $ firewall-cmd --zone=public --add-port=10053/tcp --permanent $ firewall-cmd --reload

5. Detect data in Zabbix server

Use cmdline-jmxclient-0.10.3.jar on the Zabbix server to check whether data can be captured

 $ java -jar /tmp/cmdline-jmxclient-0.10.3.jar - 10.10.204.65:10053 java.lang:type=Memory NonHeapMemoryUsage 09/15/2017 19:06:49 +0800 org.archive.jmx. Client NonHeapMemoryUsage: committed: 33406976 init: 2555904 max: -1 used: 32079720

Get data successfully.

Then add the host and link the template in the Zabbix web interface.

Template App Apache Tomcat JMX
Template App Generic Java JMX

The above two templates are system default and can be added. Some parameters are not common and need to be modified manually.

Zabbix 3.4 Monitoring the Performance of the MariaDB (MySQL) Database

precondition:

First, you need to install Zabbix Servers and Zabbix agentd:

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

1. Configure userparameter_mysql.conf

The Zabbix source code contains the userparameter_mysql.conf configuration file. You only need to copy it to the zabbix_agentd.conf. d directory:

 $ find / -name userparameter_mysql.conf $ cd /tmp/zabbix-3.4.2/conf/zabbix_agentd/ $ cp userparameter_mysql.conf /usr/local/zabbix/etc/zabbix_agentd.conf.d/

2. Modify zabbix_agentd.conf

Since we have placed the userparameter_mysql.conf file in the zabbix_agentd.conf.d directory, we need to cancel the following comment so that the Zabbix Agent can load this file

 $ vim /usr/local/zabbix/etc/zabbix_agentd.conf ... Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/*.conf ...

be careful: If the configuration file/path has been loaded in the systemctl Zabbix-Agent.service unit file, this step can be ignored.

3. Create monitoring MariaDB (MySQL) user information

 MariaDB [(none)]> GRANT SELECT ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY 'Renwolecom'; MariaDB [(none)]> FLUSH PRIVILEGES; MariaDB [(none)]> exit Bye

Note: MySQL user permissions can be set according to requirements, refer to《 Linux MariaDB (MySQL) database change user permissions 》。

4. Create the. my.cnf file and add the MariaDB (MySQL) user information

 $ vim /usr/local/zabbix/etc/.my.cnf # Zabbix Agent [mysql] host=localhost user=zabbix password="Renwolecom" socket=/tmp/mysql.sock [mysqladmin] host=localhost user=zabbix password="Renwolecom" socket=/tmp/mysql.sock

5. Modify userparameter_mysql.conf

The revised contents are as follows:

 $ cd /usr/local/zabbix/etc/zabbix_agentd.conf.d/ $ egrep -v "(^#|^$)" userparameter_mysql.conf UserParameter= mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/usr/local/zabbix/etc/ /usr/local/mysql/bin/mysql -N | awk '{print $$2}' UserParameter= mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");"  | HOME=/usr/local/zabbix/etc mysql -N' UserParameter= mysql.ping,HOME=/usr/local/zabbix/etc/ /usr/local/mysql/bin/mysqladmin ping | grep -c alive UserParameter= mysql.version,/usr/local/mysql/bin/mysql -V UserParameter= mysql.vars[*],echo "show variables where Variable_name='$1';" | HOME=/usr/local/zabbix/etc/ /usr/local/mysql/bin/mysql -N | awk '{print $$2}'

Note: Please pay attention to the absolute path above.

6. Restart the Zabbix Agent service

 $ systemctl restart zabbix-agent

Finally, add the MySQL monitoring template in the Zabbix UI interface.

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 》。

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.