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

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

zabbix監(jiān)控redis、tomcat、Nginx

本次博文需基于zabbix的基本環(huán)境,可參考搭建zabbix

創(chuàng)新互聯(lián)專注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于網(wǎng)站建設(shè)、成都網(wǎng)站制作、彭陽網(wǎng)絡(luò)推廣、重慶小程序開發(fā)公司、彭陽網(wǎng)絡(luò)營(yíng)銷、彭陽企業(yè)策劃、彭陽品牌公關(guān)、搜索引擎seo、人物專訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)為所有大學(xué)生創(chuàng)業(yè)者提供彭陽建站搭建服務(wù),24小時(shí)服務(wù)熱線:13518219792,官方網(wǎng)址:www.cdcxhl.com

一、配置zabbix監(jiān)控redis

(1)部署zabbix agent端

部署agent端詳細(xì)信息、下載軟件包可參考博文配置Zabbix監(jiān)控之郵件報(bào)警、微信報(bào)警這里就不進(jìn)行詳細(xì)解釋了!

[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.conf
[root@agent etc]#  sed -i 's/Server=127.0.0.1/Server=192.168.1.10/g' zabbix_agentd.conf
[root@agent etc]#  sed -i '/ListenPort=/s/^#//'  zabbix_agentd.conf
[root@agent etc]#  sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.1.10/g' zabbix_agentd.conf
[root@agent etc]#  sed -i 's/Hostname=Zabbix server/Hostname=192.168.1.8/g' zabbix_agentd.conf
[root@agent etc]#  echo -e "Timeout=15" >> zabbix_agentd.conf
[root@agent etc]#  echo -e "Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/" >> zabbix_agentd.conf
[root@agent etc]# /etc/init.d/zabbix_agentd start

web界面配置如下:
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

(2)安裝redis服務(wù)

需在agent進(jìn)行安裝:

[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)定義監(jiān)控redis文件

如圖:
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
需在zabbix agent端進(jìn)行配置,如下:

[root@zabbix ~]# cd /usr/local//zabbix/etc/zabbix_agentd.conf.d/
[root@zabbix zabbix_agentd.conf.d]# vim zbx_redis.conf
UserParameter=redis.status[*],/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 info|grep $1|grep -v _human|cut -d : -f2
UserParameter=redis.proc,pidof redis-server | wc -l
//對(duì)下載的配置文件進(jìn)行修改并存放在指定的地方
[root@agent zabbix_agentd.conf.d]# /etc/init.d/zabbix_agentd restart
//重啟啟動(dòng)zabbix agent服務(wù)

(4)zabbix server進(jìn)行測(cè)試

[root@zabbix ~]# zabbix_get -s 192.168.1.8 -p 10050 -k redis.status[used_memory:]
849472
//有數(shù)據(jù)返回表示沒有問題

(5)導(dǎo)入模板并監(jiān)控

如圖:
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

驗(yàn)證成功!

二、配置zabbix監(jiān)控tomcat

監(jiān)控Tomcat需要用到zabbix_java_gateway這個(gè)組件(在zabbix2.0引入的功能),顧名思義就是:Java網(wǎng)關(guān),類似于agentd,但是只用于Java方面。需要注意的是,它只能主動(dòng)去獲取數(shù)據(jù),而不能被動(dòng)獲取數(shù)據(jù)。它的數(shù)據(jù)最終會(huì)提交到server端或proxy。
如果需要開啟監(jiān)控Tomcat功能,在編譯zabbix server端時(shí),需要添加--enable_java 參數(shù);或者通過以下RPM的方式安裝。

(1)zabbix server 安裝zabbix_java_gateway程序

zabbix_java_gateway程序既可以安裝在zabbix server端,也可以安裝在被監(jiān)控端,也可單獨(dú)安裝,不過一般都是安裝在Zabbix server。那么本次案例就安裝在zabbix server端。

下載所需軟件

zabbix server(192.168.1.8)端的操作如下:

[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.conf
[root@zabbix ~]# sed -i '/LISTEN_PORT=/s/^#//' /etc/zabbix/zabbix_java_gateway.conf
[root@zabbix ~]# systemctl start zabbix-java-gateway.service
[root@zabbix ~]# ss -lnt | grep 10052
LISTEN     0      50          :::10052                   :::*           
[root@zabbix ~]# sed -i 's/# JavaGateway=/JavaGateway=192.168.1.10/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix ~]# sed -i '/JavaGatewayPort/s/^#//' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix ~]#  sed -i 's/# StartJavaPollers=0/StartJavaPollers=5/g' /usr/local/zabbix/etc/zabbix_server.conf
[root@zabbix ~]# /etc/init.d/zabbix_server restart
[root@zabbix ~]# jconsole          /確保這條命令可以使用,此命令是Java-gateway提供的。

(2)測(cè)試端安裝、配置tomcat

tomcat測(cè)試機(jī)(192.168.1.8)的操作如下:

[root@tomcat ~]# java -version        //確保java的環(huán)境
openjdk version "1.8.0_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 
//必須保證內(nèi)容插入到以下位置(兩個(gè)#號(hào)中)
# ----- 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: only output this if we have a TTY
//添加的內(nèi)容中:IP為Tomcat本機(jī)的IP,端口“8888”可以自定義,不要沖突即可!
[root@tomcat ~]# /usr/local/tomcat/bin/startup.sh 
[root@tomcat ~]# ss -lnt | grep 8080
LISTEN     0      100         :::8080                    :::*                  
[root@tomcat ~]# ss -lnt | grep 8888
LISTEN     0      50          :::8888                    :::*   

(3)登錄到zabbix server提供的web界面進(jìn)行配置

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
可以看到已經(jīng)監(jiān)控到數(shù)據(jù)了!

tomcat監(jiān)控完成!

三、配置zabbix監(jiān)控nginx

(1)測(cè)試機(jī)(192.168.1.7)部署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.conf
[root@nginx etc]# sed -i 's/Server=127.0.0.1/Server=192.168.1.10/g' zabbix_agentd.conf
[root@nginx etc]# sed -i '/ListenPort=/s/^#//'  zabbix_agentd.conf
[root@nginx etc]# sed -i 's/ServerActive=127.0.0.1/ServerActive=192.168.1.10/g' zabbix_agentd.conf
[root@nginx etc]# sed -i 's/Hostname=Zabbix server/Hostname=192.168.1.7/g' zabbix_agentd.conf
[root@nginx etc]# echo -e "Timeout=15" >> zabbix_agentd.conf
[root@nginx etc]# echo -e "Include=/usr/local/zabbix/etc/zabbix_agentd.conf.d/" >> zabbix_agentd.conf
[root@nginx etc]# egrep -v '^$|^#' zabbix_agentd.conf
 PidFile=/tmp/zabbix_agentd.pid
LogFile=/tmp/zabbix_agentd.log
Server=192.168.1.10
 ListenPort=10050
ServerActive=192.168.1.10
Hostname=192.168.1.7
Timeout=15
Include=/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)測(cè)試機(jī)(192.168.1.7)部署nginx服務(wù)

[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 /usr/local/zabbix/scripts/nginx.sh
#!/bin/bash
case $1 in
index)
    RS=`curl -s -I 192.168.1.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.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`
    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
[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.conf
[root@nginx etc]# echo -e 'UserParameter=nginx.info[*],/usr/local/zabbix/scripts/nginx.sh  $1' >> zabbix_agentd.conf
[root@nginx etc]# echo -e 'UserParameter=nginx.ping[*],netstat -anput | grep -w 80 | grep -w LISTEN | wc -l' >> zabbix_agentd.conf
[root@nginx etc]# /etc/init.d/zabbix_agentd restart

(3)zabbix server進(jìn)行測(cè)試

[root@zabbix ~]# zabbix_get -s 192.168.1.7 -p 10050 -k nginx.info[index]
200
//有返回值則表示連接成功

(4)配置web頁面

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

1)配置應(yīng)用集

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

2)配置監(jiān)控項(xiàng)

檢測(cè)nginx是否存活
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

監(jiān)控Nginx總訪問量
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

獨(dú)立IP數(shù)
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

Nginx主頁的狀態(tài)
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

Nginx當(dāng)前并發(fā)數(shù)
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

根據(jù)MD5值來監(jiān)控nginx配置文件是否被更改
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

nginx當(dāng)前吞吐量bps
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

監(jiān)控nginx工作進(jìn)程的個(gè)數(shù)
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

監(jiān)控nginx虛擬主機(jī)的個(gè)數(shù)
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

3)創(chuàng)建觸發(fā)器

nginx服務(wù)意外停止工作觸發(fā)器
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

表達(dá)式編寫規(guī)范:

{Template App Nginx Service:nginx.ping.last(0)} = 0
Template App Nginx Service  模板名
nginx.ping    鍵名
last(0)       方法:表示當(dāng)前的。。  last(1)表示上一個(gè)。。

創(chuàng)建Nginx主頁不可訪問的觸發(fā)器
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

創(chuàng)建Nginx配置文件被修改觸發(fā)器
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

4)添加被監(jiān)控主機(jī)

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

5)查看zabbix監(jiān)控的數(shù)據(jù)

zabbix監(jiān)控redis、tomcat、Nginx

6)給監(jiān)控nginx狀態(tài)添加映射

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

7)關(guān)聯(lián)到監(jiān)控項(xiàng)

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

[root@zabbix ~]# yum -y install httpd-tools
[root@zabbix ~]# ab -n 100 -c 100 http://192.168.1.7/index.html
//模擬并發(fā)

zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx

也可自定義圖表,如下:
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
zabbix監(jiān)控redis、tomcat、Nginx
監(jiān)控nginx成功!

——————————————本文到此結(jié)束,感謝閱讀——————————————————


文章題目:zabbix監(jiān)控redis、tomcat、Nginx
URL分享:http://weahome.cn/article/jpphie.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部