Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Zabbix monitors redis, tomcat, Nginx

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

This blog post needs to be based on the basic environment of zabbix. You can refer to building zabbix.

1. Configure zabbix to monitor redis (1) deploy zabbix agent

Deployment of agent details, download software package can refer to the blog configuration Zabbix monitoring mail alarm, Wechat alarm here will not be explained in detail!

[root@agent] # tar zxf zabbix-3.2.1.tar.gz & & cd zabbix-3.2.1/ [root@agent zabbix-3.2.1] #. / configure-- prefix=/usr/local/zabbix-- enable-agent & & make & & make install [root@agent zabbix-3.2.1] # useradd zabbix [root@agent zabbix-3.2.1] # cp / root/zabbix-3.2.1/misc/init.d/fedora / core/zabbix_agentd / etc/init.d/ [root@agent zabbix-3.2.1] # sed-I "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" / etc/init.d/zabbix_agentd [root@agent zabbix-3.2.1] # chmod + x/etc/ init.d/zabbix_agentd [root@agent zabbix-3.2.1] # cd / usr/local/zabbix/etc/ [root@agent etc] # sed-I' / PidFile=/s/ ^ # / / 'zabbix_ agentd.confession [root @ agent etc] # root @ agent etc] # zabbix_ agentd.confession [root @ agent etc] # sed-I' / ListenPort=/s/ ^ # / / 'zabbix_ agentd.confession [root @ root] # root @ agent etc] # sed-I's Universe ActiveServer 127.0.0.1 and ActiveServer 192.168.1.10 zabbix_ agentd.confession @ agent etc] # sed-I 's/Hostname=Zabbix server/Hostname=192.168.1.8/g' zabbix_ agentd.confession [root @ agent etc] # echo-e "Timeout=15" > > zabbix_ agentd.confession [root @ agent etc] # echo-e "Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/" > > zabbix_ agentd.confession [root @ agent etc] # / etc/init.d/zabbix_agentd start

The web interface is configured as follows:

(2) install redis service

You need to install it at agent:

[root@agent ~] # tar zxf redis-4.0.14.tar.gz [root@agent ~] # cd redis-4.0.14/ [root@agent redis-4.0.14] # make & & make install [root@agent redis-4.0.14] # cd utils/ [root@agent utils] #. / install_server.sh (3) define the monitoring redis file

As shown in the figure:

It needs to be configured on the zabbix agent side, as follows:

[root@zabbix ~] # cd / usr/local//zabbix/etc/zabbix_agentd.conf.d/ [root @ zabbix zabbix_agentd.conf.d] # vim zbx_redis.confUserParameter=redis.status [*], / usr/local/bin/redis-cli-h 127.0.0.1-p 6379 info | grep $1 | grep-v _ human | cut-d:-f2UserParameter=redis.proc Pidof redis-server | wc-lamp / modify the downloaded configuration file and store it in the specified place [root@agent zabbix_agentd.conf.d] # / etc/init.d/zabbix_agentd restart// restart to start the zabbix agent service (4) zabbix server to test [root@zabbix ~] # zabbix_get-s 192.168.1.8-p 10050-k redis.status [used _ memory:] 849472amp / data returned indicates no problem (5) Import template and monitor

As shown in the figure:

Verified successfully!

2. Configure zabbix to monitor tomcat

Monitoring Tomcat requires the use of zabbix_java_gateway (a feature introduced in zabbix2.0), as the name implies: Java gateway, similar to agentd, but only for Java. It should be noted that it can only obtain data actively, not passively. Its data will eventually be submitted to the server or proxy.

If you need to enable the monitoring Tomcat function, you need to add the-- enable_java parameter when compiling the zabbix server side, or install it through the following RPM.

(1) zabbix server installs zabbix_java_gateway program

Zabbix_java_gateway programs can be installed either on the zabbix server side, on the monitored side, or separately, but they are usually installed on Zabbix server. Then this case is installed on the zabbix server side.

Download the required software

The operation on the zabbix server (192.168.1.8) side is as follows:

[root@zabbix ~] # rpm-ivh zabbix-java-gateway-3.2.1-1.el7.x86_64.rpm [root@zabbix ~] # sed-I'/ LISTEN_IP=/s/ ^ # /'/ etc/zabbix/zabbix_java_ gateway.confession [root @ zabbix ~] # sed-I'/ LISTEN_PORT=/s/ ^ # /'/ etc/zabbix/zabbix_java_ gateway.confession [root @ zabbix ~] # systemctl start zabbix-java-gateway.service [ Root@zabbix ~] # ss-lnt | grep 10052LISTEN 0 50: 10052: * [root@zabbix ~] # sed-I's usr/local/zabbix/etc/zabbix_ # JavaGateway=/JavaGateway=192.168.1.10/g' / usr/local/zabbix/etc/zabbix_ server.confs [root @ zabbix ~] # sed-I'/ JavaGatewayPort/s/ ^ # /'/ usr/local/zabbix/etc/zabbix_ Server.conf [root@zabbix ~] # sed-I's Universe # StartJavaPollers=0/StartJavaPollers=5/g' / usr/local/zabbix/etc/zabbix_ server.confs [root @ zabbix ~] # / etc/init.d/zabbix_server restart [root@zabbix ~] # jconsole / Assurance this command can be used This command is provided by Java-gateway. (2) install and configure tomcat at the test end

The operation of the tomcat test machine (192.168.1.8) is as follows:

[root@tomcat ~] # java-version / / ensure the environment of java openjdk version "1.8.0mm 161" OpenJDK Runtime Environment (build 1.8.0_161-b14) OpenJDK 64-Bit Server VM (build 25.161-b14 Mixed mode) [root@tomcat ~] # tar zxf apache-tomcat-8.5.35.tar.gz [root@tomcat ~] # mv apache-tomcat-8.5.35 / usr/local/tomcat [root@tomcat ~] # sed-I '308a CATALINA_OPTS= "$CATALINA_OPTS-Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.port=8888-Dcom.sun.management.jmxremote.ssl=false-Djava.rmi.server.hostname=192.168.1.8-Dcom.sun.management. Jmxremote.authenticate=flase "'/ usr/local/tomcat/bin/catalina.sh / / must ensure that the content is inserted in the following location (two # signs) #-Execute The Requested Command-CATALINA_OPTS=" $CATALINA_OPTS-Dcom.sun.management.jmxremote-Dcom.sun.management.jmxremote.port=8888 -Dcom.sun.management.jmxremote.ssl=false-Djava.rmi.server.hostname=192.168.1.8-Dcom.sun.management.jmxremote.authenticate=flase "# Bugzilla 37848: added by only output this if we have a TTY//: IP is the native IP of Tomcat Port "8888" can be customized without conflict! [root@tomcat ~] # / usr/local/tomcat/bin/startup.sh [root@tomcat ~] # ss-lnt | grep 8080LISTEN 0 100:: 8080: * [root@tomcat ~] # ss-lnt | grep 8888LISTEN 0 50: 8888: * (3) Log in to the web interface provided by zabbix server to configure

You can see that the data has been monitored!

Tomcat monitoring complete!

3. Configure zabbix to monitor nginx (1) test machine (192.168.1.7) deploy zabbix agent [root@nginx ~] # tar zxf zabbix-3.2.1.tar.gz & & cd zabbix-3.2.1/ [root@nginx zabbix-3.2.1] #. / configure-- prefix=/usr/local/zabbix-- enable-agent & & make & & make install [root@nginx zabbix-3.2.1] # cp misc/init.d/fedora/core/zabbix _ agentd / etc/init.d/ [root@nginx zabbix-3.2.1] # useradd zabbix [root@nginx zabbix-3.2.1] # sed-I "s#BASEDIR=/usr/local#BASEDIR=/usr/local/zabbix#g" / etc/init.d/zabbix_agentd [root@nginx zabbix-3.2.1] # chmod + x/etc/ init.d/zabbix_agentd [root@nginx zabbix-3.2.1] # cd / usr/local/zabbix/etc/ [root @ nginx etc] # sed-I'/ PidFile=/s/ ^ # / / 'zabbix_ agentd.confession [root @ nginx etc] # sed-I's Accord Server servers 127.0.0.1and sed @ nginx etc] # sed-I' / ListenPort=/s/ ^ # / 'zabbix_agentd.conf [root@nginx etc] # sed-I's Universe 127.0.0.1 and Server Activehands 192.168.1.10 Zabbix_ agentd.confession [root @ nginx etc] # sed-I 's/Hostname=Zabbix server/Hostname=192.168.1.7/g' zabbix_ agentd.confession [root @ nginx etc] # echo-e "Timeout=15" > > zabbix_ agentd.confession [root @ nginx etc] # echo-e "Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/" > > zabbix_ agentd.confession [root @ nginx etc] # root-v' ^ $| ^ # 'zabbix_agentd.conf PidFile=/tmp/zabbix_agentd.pidLogFile=/ Tmp/zabbix_agentd.logServer=192.168.1.10 ListenPort=10050ServerActive=192.168.1.10Hostname=192.168.1.7Timeout=15Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/ [root @ nginx etc] # / etc/init.d/zabbix_agentd start [root@nginx etc] # ss-lnt | grep 10050 (2) test machine (192.168.1.7) deploy nginx service [root@nginx ~] # yum-y install pcre-devel zlib-devel openssl-devel [root@nginx ~] # wget http://nginx.org/download/nginx-1.14.0.tar.gz[root@nginx ~] # tar zxf nginx-1.14.0.tar.gz [root@nginx ~] # cd nginx-1.14.0/ [root@nginx nginx-1.14.0] #. / configure-- with-http_stub_status_module & & make & & make install [root@nginx nginx-1.14.0] # / usr/local/nginx/sbin/nginx [root@nginx ~] # mkdir / usr/local/zabbix/scripts/ [root@nginx ~] # vim / awk _ print _ scripts _ ; WorkerProcesses) RS= `ps aux | grep nginx | grep-w worker | wc-l`echo $RS;; bps) RS= `ab-Q-n 1000-c 1000 http://192.168.1.7/index.html | grep Request | awk'{print $4} '`echo $RS;; Current) LINES= `cat / usr/local/nginx/logs/access.log | wc-l`sleep 1 NOW_LINES= `cat / usr/local/nginx/logs/access.log | wc-l`echo $NOW_LINES $LINES | awk' {print $1-$2}' IP) RS= `cat / usr/local/nginx/logs/access.log | awk'{print $1}'| sort-u | wc-l`cat $RS;; VirtualHost) RS= `cat / usr/local/nginx/conf/nginx.conf | grep-v'#'| grep server_name | wc-l`cat $RS;; MD5) RS= `md5sum / usr/local/nginx/conf/nginx.conf | awk'{print $1} '`echo $RS PV) RS= `wc-l / usr/local/nginx/logs/access.log | awk'{print $1} '`echo $RS Esac [root@nginx ~] # chmod + s / usr/bin/netstat [root@nginx ~] # chmod + x / usr/local/zabbix/scripts/nginx.sh [root@nginx ~] # cd / usr/local/zabbix/etc/ [root@nginx etc] # echo-e 'UnsafeUserParameters=1' > > zabbix_ agentd.confession [root @ nginx etc] # echo-e' UserParameter=nginx.info [*], / usr/local/zabbix/scripts/nginx.sh $1'> > zabbix_ agentd.confession [root @ nginx etc] # echo-e 'UserParameter=nginx.ping [*] Netstat-anput | grep-w 80 | grep-w LISTEN | wc-l'> > zabbix_ agentd.confs [root @ nginx etc] # / etc/init.d/zabbix_agentd restart (3) zabbix server to test [root@zabbix ~] # zabbix_get-s 192.168.1.7-p 10050-k nginx.info [index] 200pm / return value indicates that the connection is successful (4) configure web page

1) configure the application set

2) configure monitoring items

Check whether nginx is alive

Monitor total Nginx visits

Independent IP number

Status of the Nginx home page

Current concurrency of Nginx

Monitor whether the nginx profile has been changed according to the MD5 value

Nginx current Throughput bps

Monitor the number of nginx worker processes

Monitor the number of nginx virtual hosts

3) create a trigger

Nginx service unexpected stop working trigger

Expression writing specification:

{Template App Nginx Service:nginx.ping.last (0)} = 0Template App Nginx Service template name nginx.ping key name last (0) method: represents the current. Last (1) represents the previous one.

Create a trigger that is not accessible to the Nginx home page

Create Nginx profile modified trigger

4) add monitored hosts

5) View the data monitored by zabbix

6) add a mapping to the monitoring nginx status

7) Associate to the monitoring item

[root@zabbix ~] # yum-y install httpd-tools [root@zabbix ~] # ab-n 100-c 100 http://192.168.1.7/index.html// simulation concurrency

You can also customize the chart as follows:

Monitoring nginx succeeded!

-this is the end of this article. Thank you for reading-

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report