真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

zabbix監(jiān)控nginx和tomcat

請(qǐng)先還原到“zabbix監(jiān)控及郵件報(bào)警”的快照https://blog.51cto.com/14320361/2448847

創(chuàng)新互聯(lián)公司于2013年開(kāi)始,先為南山等服務(wù)建站,南山等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為南山企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問(wèn)題。

監(jiān)控tomcat
zabbix_java_gateway:在 zabbix2.0之后引入的一個(gè)功能。顧名思義: Java網(wǎng)關(guān),類(lèi)似 agentd,但是只用于Java方面。需要特別注意的是,它只能主動(dòng)去獲取數(shù)據(jù),而不能被動(dòng)獲取數(shù)據(jù)。它的數(shù)據(jù)最終會(huì)提交到 server或者 proxy。
如果需要開(kāi)啟監(jiān)控tomcat需要在zabbix編譯的的過(guò)程中添加--enable_java參數(shù)
一.Zabbix_server端配置
安裝zabbix_java_gateway程序
(1)查看端口

  284  netstat -anpt | grep 9000
  285  netstat -anpt | grep MySQL
  286  netstat -anpt | grep 80
  287  netstat -anpt | grep 10050

zabbix監(jiān)控nginx和tomcat

(2)安裝zabbix_java_gateway程序

  288  rz   (上傳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)修改zabbix配置文件
  293  vim /etc/zabbix/zabbix_java_gateway.conf 
LISTEN_IP="0.0.0.0"   #java-gateway監(jiān)聽(tīng)的地址
LISTEN_PORT=10052  #監(jiān)聽(tīng)的端口
PID_FILE="/var/run/zabbix/zabbix_java.pid"   #pid文件存放路徑

zabbix監(jiān)控nginx和tomcat
(4)開(kāi)啟zabbix并查看端口

  294  systemctl start zabbix-java-gateway.service 
  295  netstat  -anpt | grep 10052

  296  vim /etc/zabbix/zabbix_java_gateway.conf 

(5)修改zabbixserver的配置文件,默認(rèn)zabbix沒(méi)有啟動(dòng)java監(jiān)控程序

  297  vim /usr/local/zabbix/etc/zabbix_server.conf
JavaGateway=192.168.1.10   #215  本機(jī)IP
JavaGatewayPort=10052      #223 去注釋
StartJavaPollers=5        #231

(6)重啟zabbixserver端
298 /etc/init.d/zabbix_server restart

二. 配置tomcat
20 rpm -qa | grep jdk #檢查是否安裝rpm的java環(huán)境
21 rpm -e java-1.8.0-openjdk-headless java-1.7.0-openjdk-headless --nodeps
##卸載自帶的java環(huán)境
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat

   19  rz  (上傳jdk和tomcat安裝包)
   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   (末尾添加)
export JAVA_H0ME=/usr/local/jdk1.8.0_211
export JRE_HOME=/usr/local/jdk1.8.0_211
export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_H0ME/lib/dt.jar
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

   27  source  /etc/profile   (執(zhí)行一下)
   28  java -version      (查看一下jdk是否安裝成功)

zabbix監(jiān)控nginx和tomcat
Tomcat 開(kāi)啟jmx遠(yuǎn)程調(diào)試功能

   29  cd /usr/local/tomcat/
   31  vim bin/catalina.sh   (大約300行添加) 
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"
啟動(dòng)tomcat并查看端口
   32  /usr/local/tomcat/bin/startup.sh 
   33  netstat -anput | grep 8888

zabbix監(jiān)控nginx和tomcat

服務(wù)終端測(cè)試

zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbixserver端進(jìn)行配置(在瀏覽器上操作)
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat

三.監(jiān)控nginx服務(wù)器
1.安裝依賴包

   49  yum -y install pcre-devel openssl-devel
2.安裝nginx
48  rz              (上傳nginx和zabbix安裝包)
   50  tar zxf nginx-1.14.0.tar.gz 
   51  cd nginx-1.14.0/
   52  ./configure  && make && make install    (編譯安裝)
   53  ln -s /usr/local/nginx/sbin/nginx  /usr/local/sbin/   (鏈接命令目錄)
   54  nginx       (開(kāi)啟nginx)
   56  netstat -anpt | grep  nginx   (查看nginx端口)

zabbix監(jiān)控nginx和tomcat
3.安裝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/     (復(fù)制zabbix啟動(dòng)文件)
   27  vim /etc/init.d/zabbix_agentd     (修改zabbix啟動(dòng)文件)
        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              (修改zabbix配置文件)
PidFile=/usr/local/zabbix/logs/zabbix_agentd.pid   #11          (需要?jiǎng)?chuàng)建所需目錄)
LogFile=/usr/local/zabbix/logs/zabbix_agentd.log  #30   
Server=192.168.1.10  #91 服務(wù)端IP
ListenPort=10050  #99
ListenIP=0.0.0.0  #107
ServerActive=192.168.1.10  #132 服務(wù)端IP
Hostname=192.168.1.20  #143 客戶端IP
Timeout=3 #232
UnsafeUserParameters=1  #278
#287 修改添加
UserParameter=nginx.info[*],/usr/local/zabbix/scripts/nginx.sh  $1   (需要?jiǎng)?chuàng)建所需目錄)
UserParameter=nginx.ping[*],netstat  -anput | grep   -w  80   | grep  -w LISTEN | wc -l

   31  mkdir  /usr/local/zabbix/scripts      (創(chuàng)建所需目錄)
   32  cd /usr/local/zabbix/scripts/

4.安裝nginx

33  rz 
   34  vim nginx.sh  (修改ip)
編寫(xiě)監(jiān)控nginx腳本
#!/bin/bash
#This is a scripts for checking nginx 
case $1 in
index)
    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`
    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`
    echo $RS
    ;;

VirtualHost)
    RS=`cat /usr/local/nginx/conf/nginx.conf |grep -v '#' | grep server_name | wc -l`
    echo $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  (ab壓力測(cè)試需要)
   41  ab -q -n 1000 -c 1000 http://192.168.1.20/index.html 
   42  chmod +x nginx.sh      (改nginx.sh可執(zhí)行權(quán)限)
   43  useradd  Zabbix         (創(chuàng)建所需用戶)
   44  mkdir /usr/local/zabbix/logs   (創(chuàng)建所需目錄)
   45  chown  -R zabbix:zabbix  /usr/local/zabbix/   (給配置目錄zabbix用戶擁有)
   49  /etc/init.d/zabbix_agentd start          (開(kāi)啟zabbix)
   50  netstat  -anpt | grep Zabbix            (查看zabbix端口)

zabbix監(jiān)控nginx和tomcat

服務(wù)端測(cè)試
zabbix_get -s 192.168.1.20 -p 10050 -k nginx.info[index]
zabbix監(jiān)控nginx和tomcat
zabbix_get -s 192.168.1.20 -p 10050 -k nginx.ping
zabbix監(jiān)控nginx和tomcat
客戶端給予權(quán)限
chmod +s /usr/bin/netstat
再次在服務(wù)端測(cè)試
zabbix_get -s 192.168.1.20 -p 10050 -k nginx.ping

zabbix監(jiān)控nginx和tomcat

四.回到瀏覽器zabbixserver端創(chuàng)建nginx監(jiān)控模板
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
1、 監(jiān)控nginx運(yùn)行狀態(tài)
zabbix監(jiān)控nginx和tomcat
2、 監(jiān)控nginx總訪問(wèn)量
zabbix監(jiān)控nginx和tomcat
3、 獨(dú)立IP數(shù)
zabbix監(jiān)控nginx和tomcat

4、 nginx主頁(yè)的狀態(tài)
zabbix監(jiān)控nginx和tomcat

  1. nginx當(dāng)前并發(fā)數(shù)
    zabbix監(jiān)控nginx和tomcat

6、配置文件MD5值用來(lái)監(jiān)控nginx配置文件是否被更改

zabbix監(jiān)控nginx和tomcat

7、當(dāng)前吞吐量bps,并且讓其更新時(shí)間為60秒
zabbix監(jiān)控nginx和tomcat

8、nginx工作進(jìn)程的個(gè)數(shù)
zabbix監(jiān)控nginx和tomcat
9、nignx虛擬主機(jī)的個(gè)數(shù)

zabbix監(jiān)控nginx和tomcat
五.創(chuàng)建觸發(fā)器
創(chuàng)建nginx服務(wù)意外停止工作!觸發(fā)器,表達(dá)式格式{}
{Temlate App Nginx Service:nginx.ping.last(0)} = 0
Template App Nginx Service 模板名
nginx.ping 鍵名
last(0) 方法:表示當(dāng)前的。。 last(1)表示上一個(gè)。。
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
創(chuàng)建“Nginx主頁(yè)不可訪問(wèn)”的觸發(fā)器
{Temlate App Nginx Service:nginx.ping.last(0)} > 400
zabbix監(jiān)控nginx和tomcat

創(chuàng)建“Nginx文件被修改”的觸發(fā)器
{Temlate App Nginx Service:nginx.info[MD5].last(0)} <> {Temlate App Nginx Service:nginx.info[MD5].last(1)}
zabbix監(jiān)控nginx和tomcat

zabbix監(jiān)控nginx和tomcat

六.在客戶端主機(jī)中添加創(chuàng)建的nginx模板
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
查看zabbix監(jiān)控的數(shù)據(jù)
zabbix監(jiān)控nginx和tomcat
給監(jiān)控nginx狀態(tài)添加映射(更加友好)
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
關(guān)聯(lián)到監(jiān)控項(xiàng)
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat

創(chuàng)建nginx圖形監(jiān)控
zabbix監(jiān)控nginx和tomcat
zabbix監(jiān)控nginx和tomcat
查看監(jiān)控
zabbix監(jiān)控nginx和tomcat
實(shí)驗(yàn)完畢


網(wǎng)頁(yè)標(biāo)題:zabbix監(jiān)控nginx和tomcat
網(wǎng)站URL:http://weahome.cn/article/pgpphc.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部