In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Please restore to the snapshot https://blog.51cto.com/14320361/2448847 of "zabbix Monitoring and email alarm" first
Monitoring tomcat
Zabbix_java_gateway: a feature introduced after zabbix2.0. As the name implies: Java gateway, similar to agentd, but only for Java. Special attention should be paid to the fact that it can only obtain data actively, not passively. Its data will eventually be submitted to server or proxy.
If you need to enable monitoring tomcat, you need to add the-- enable_java parameter to the process of zabbix compilation.
I. Zabbix_server side configuration
Install the zabbix_java_gateway program
(1) View Port
Netstat-anpt | grep 9000 285 netstat-anpt | grep mysql 286 netstat-anpt | grep 80287 netstat-anpt | grep 10050
(2) install zabbix_java_gateway program
288 rz (upload zabbix-java-gateway-3.2.1-1.el7.x86_64.rpm) 292 rpm-ivh zabbix-java-gateway-3.2.1-1.el7.x86_64.rpm (3) modify zabbix configuration file 293 vim / etc/zabbix/zabbix_java_gateway.conf LISTEN_IP= "0.0.0.0" # java-gateway listener address LISTEN_PORT=10052 # listener port PID_FILE= "/ var/run / zabbix/zabbix_java.pid "# pid file storage path
(4) Open zabbix and check the port
294 systemctl start zabbix-java-gateway.service 295 netstat-anpt | grep 10052 296 vim / etc/zabbix/zabbix_java_gateway.conf
(5) modify the configuration file of zabbixserver. By default, zabbix does not start the java monitoring program.
297 vim / usr/local/zabbix/etc/zabbix_server.confJavaGateway=192.168.1.10 # 215 Native IPJavaGatewayPort=10052 # 223 to comment StartJavaPollers=5 # 231
(6) restart the ZabixServer end
298 / etc/init.d/zabbix_server restart
II. Configure tomcat
20 rpm-qa | grep jdk # check whether the java environment of rpm is installed
21 rpm-e java-1.8.0-openjdk-headless java-1.7.0-openjdk-headless-- nodeps
# # Uninstall the built-in java environment
19 rz (upload jdk and tomcat installation packages) 23 tar zxf jdk-8u211-linux-x64.tar.gz-C / usr/local/ 24 tar zxf apache-tomcat-8.5.35.tar.gz 25 mv apache-tomcat-8.5.35 / usr/local/tomcat 26 vim / etc/profile (add at the end) export JAVA_H0ME=/usr/local/jdk1.8.0_211export JRE_HOME=/usr/local/jdk1.8.0_211export CLASSPATH=$JAVA_ HOME/lib/tools.jar:$JAVA_H0ME/lib/dt.jarexport PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH 27 source / etc/profile (execute) 28 java-version (check to see if jdk is installed successfully)
Tomcat enables jmx remote debugging
29 cd / usr/local/tomcat/ 31 vim bin/catalina.sh (about 300 lines added) 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.20-Dcom.sun.management.jmxremote.authenticate=flase" launch tomcat and view port 32 / usr/local/tomcat/bin/startup.sh 33 netstat-anput | grep 8888
Service terminal test
Configure on the zabbixserver side (operate on the browser)
3. Monitor the nginx server
1. Install dependency packages
49 yum-y install pcre-devel openssl-devel2. Install nginx48 rz (upload nginx and zabbix installation packages) 50 tar zxf nginx-1.14.0.tar.gz 51 cd nginx-1.14.0/ 52. / configure & & make & & make install (compile and install) 53 ln-s / usr/local/nginx/sbin/nginx / usr/local/sbin/ (link command directory) 54 nginx (open nginx) 56 netstat-anpt | grep nginx (view nginx port)
3. Install zabbix
21 tar zxf zabbix-3.2.1.tar.gz 22 cd zabbix-3.2.1/ 23. / configure-- prefix=/usr/local/zabbix-- enable-agent 24 make & & make install 26 cp misc/init.d/fedora/core/zabbix_agentd / etc/init.d/ (copy zabbix startup file) 27 vim / etc/init.d/zabbix_agentd (modify zabbix startup file) BASEDIR=/usr/ Local/Zabbix # 22 PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid # 31 29 cd / usr/local/Zabbix 30 vim etc/zabbix_agentd.conf (modify zabbix configuration file) PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid # 11 (to create the required directory) LogFile=/usr/local/zabbix/logs/zabbix_agentd.log # 30 Server=192.168 .1.10 # 91 server IPListenPort=10050 # 99ListenIP=0.0.0.0 # 107ServerActive=192.168.1.10 # 132Server IPHostname=192.168.1.20 # 143client IPTimeout=3 # 232UnsafeUserParameters=1 # 278x287 modify and add UserParameter=nginx.info [*] / usr/local/zabbix/scripts/nginx.sh $1 (need to create the required directory) UserParameter=nginx.ping [*], netstat-anput | grep-w 80 | grep-w LISTEN | wc-l 31 mkdir / usr/local/zabbix/scripts (create the required directory) 32 cd / usr/local/zabbix/scripts/
4. Install nginx
33 rz 34 vim nginx.sh (modify ip) write monitoring nginx script #! / bin/bash#This is a scripts for checking nginx case $1 inindex) RS= `curl-s-I 192.168.83.7/index.html | head-N1 | awk'{print $2} '`echo $RS;; WorkerProcesses) RS= `ps aux | grep nginx | grep-w worker | wc-l`echo $RS Bps) RS= `ab-Q-n 1000-c 1000 http://192.168.83.7/index.html | grep Request | awk'{print $4} '`echo $RS;; Current) LINES= `cat / usr/local/nginx/logs/access.log | wc-l`cat 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 37 yum-y install httpd-tools (required for ab stress testing) 41 ab-Q-n 1000-c 1000 http://192.168.1.20/index.html 42 chmod + x nginx.sh (change to nginx.sh executable permission) 43 useradd Zabbix (create required user) 44 mkdir / usr/local/zabbix/logs (create required catalog) 45 chown-R zabbix:zabbix / usr/local/zabbix/ (owned by zabbix user for configuration directory) 49 / etc/init.d/zabbix_agentd start (enable zabbix) 50 netstat-anpt | grep Zabbix (View zabbix port)
Server-side testing
Zabbix_get-s 192.168.1.20-p 10050-k nginx.info [index]
Zabbix_get-s 192.168.1.20-p 10050-k nginx.ping
The client gives permission
Chmod + s / usr/bin/netstat
Test again on the server side
Zabbix_get-s 192.168.1.20-p 10050-k nginx.ping
4. Go back to the browser Zabbix server to create a nginx monitoring template
1. Monitor the running status of nginx
2. Monitor the total number of nginx visits
3. Independent IP number
4. The status of the nginx home page
Current concurrency of nginx
6. The configuration file MD5 value is used to monitor whether the nginx configuration file has been changed.
7. Current throughput bps and update time of 60 seconds
8. Number of nginx worker processes
9. Number of nignx virtual hosts
Five. create a trigger
Creating a nginx service stops working unexpectedly! Trigger, expression format {}
{Temlate App Nginx Service:nginx.ping.last (0)} = 0
Template 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 the Nginx home page is not accessible
{Temlate App Nginx Service:nginx.ping.last (0)} > 400
Create a trigger with "Nginx file modified"
{Temlate App Nginx Service: nginx.info [MD5] .last (0)} {Temlate App Nginx Service: nginx.info [MD5] .last (1)}
VI. Add the created nginx template in the client host
View the data monitored by zabbix
Add a mapping to the monitoring nginx status (more friendly)
Associate to a monitoring item
Create nginx graphical monitoring
View Monitoring
The experiment is over
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.