Nginx服務納入到zabbix監控

工作中有用到Nginx做負載均衡,所以想嘗試一下,把Nginx服務用zabbix監控起來

記錄下操作步驟,以防下次忘記

涉及的實驗環境:

     服務器操作系統:CentOS 7.2

     zabbix版本:zabbix-2.2.5

     Nginx版本:nginx-1.10.1

要做監控步驟前,先查看下當前Nginx中是否加載了--with-http_stub_status_module的模塊。

# /data0/nginx/sbin/nginx -V
nginx version: nginx/1.10.1
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC) 
built with OpenSSL 1.0.1e-fips 11 Feb 2013
TLS SNI support enabled
configure arguments: --prefix=/data0/nginx --pid-path=/data0/nginx/logs/nginx.pid --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi 
--with-pcre --add-module=/root/nginx_upstream_check_module-master/ --add-module=/data0/soft/ngx_cache_purge-master/

 

因爲這邊zabbix是根據nginx的Stub Status模塊,來抓取Status模塊所提供的數據。

假如從前尚未開啓此模塊,現在想啓用StubStatus模塊,你可以重新編譯nginx源碼安裝包,然後在編譯時記得加上參數 --with-http_stub_status_module,執行./configure && make就可以了,不用make install,如果make install記得先備份下,配置文件nginx.conf,以防止配置文件的內容都遺失了。

因爲Nginx配置時,我都有加載此模塊,所以就不多加介紹了。

重新加載nginx模塊可以參照我之前寫的博客

http://10803382.blog.51cto.com/10793382/1924871


在你的nginx.conf確認下,有沒有下列內容,如果沒有,那你可以在nginx.conf當中添加查看nginxstatus配置後,重啓nginx服務即可。

# vim /data0/nginx/conf/nginx.conf
##找到server模塊,server{}里加入下面的內容
 #20170627 Nginx監控設置
           location /nginxstatus{
            stub_status on;
            access_log /data0/nginx/logs/status.log;
            allow 10.60.0.71;  ##允許zabbix監控主機內網IP訪問
            allow 10.60.0.163; ##允許nginx本機內網IP訪問
            deny all;
            auth_basic "nginxstatus";
        }
        #20170627 END

因爲限定可訪問IP,有助於保護網址安全

# /data0/nginx/sbin/nginx -t
nginx: the configuration file /data0/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /data0/nginx/conf/nginx.conf test is successful

# /data0/nginx/sbin/nginx  -s reload

查看你設置好的nginxstatus連接狀況

http://網址/nginxstatus

 

# curl http://127.0.0.1/nginxstatus
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.10.1</center>
</body>
</html>


你會發現出現了錯誤提示,顯示了301 網站有設定了永久重定向,

如果你和我是一樣的情況,網址做了https,那麼請在nginx主機、zabbix監控主機上用網址來訪問即可

# curl https://www.sss.com/nginxstatus
Active connections: 9 
server accepts handled requests
 1453770 1453770 2718730 
Reading: 0 Writing: 4 Waiting: 5

注:

Activeconnections:對後端發起的活動連接數;

server accepts :nginx 總共處理了1453770個連接;

handled:成功創建了1453770次握手;

requests:總共處理了2718730個請求。

Reading:nginx讀取客戶端的header數;

Writing: nginx 返回給客戶端的header數;

Waiting: nginx 請求處理完成,正在等待下一請求指令的連接。

在上面的準備工作完了以後,接下來,我們就要開始在nginx的那臺機器上編輯一個可以讓zabbix服務器獲取到數據的腳本

注:因爲我的網站做了https,所以不是像別人一樣直接訪問IP和端口就可以了,我就直接訪問網址即可

# vim /data0/zabbix/scripts/nginx_status.sh
#!/bin/bash
# Script is userd to fetch nginx statuses for zabbix monitoring systems
# Set Variables
BKUP_DATE=`/bin/date +%Y%m%d`
LOG="/data0/zabbix/log/webstatus.log"
HOST=www.sss.com
export HOST
# Function used to check the process of nginx
function ping {
  ps -ef |grep  nginx | wc -l
}
# Functions to return nginx stats
function active {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| grep 'Active' | awk '{print $NF}'
}
function reading {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| grep 'Reading' | awk '{print $2}'
}
function writing {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| grep 'Writing' | awk '{print $4}'
}
function waiting {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| grep 'Waiting' | awk '{print $6}'
}
function accepts {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| awk NR==3 | awk '{print $1}'
}
function handled {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| awk NR==3 | awk '{print $2}'
}
function requests {
/usr/bin/curl "https://$HOST/nginxstatus" 2>/dev/null| awk NR==3 | awk '{print $3}'
}
# Run the requested function
$1


#上面是根據我的情況設定的,當然還有其他更簡潔的方式,但因爲可以實現想要的功能,所以就先不進行更改了。


賦予腳本可執行權限

# chmod +x nginx_status.sh


將腳本更改至zabbix用戶和羣組管理

# chown  zabbix:zabbix nginx_status.sh
# ll nginx_status.sh 
-rwxr-xr-x 1 zabbix zabbix 1168 Jun 27 13:58 nginx_status.sh


在本地查看下你的設定是否可以出結果,不然出錯,卻沒有發現,後面可能就沒有辦法收取到數據,也可以及時排錯。

# /usr/bin/curl "https://www.sss.com/nginxstatus" 2>/dev/null| grep 'Active' | awk '{print $NF}'
12

上面數據一個個試過,如果可以像上面一樣能出數據,說明沒有問題。那你就可以到zabbix客戶端去添加Nginx服務的模塊獲取設定

# grep -v "^[#;]" /data0/zabbix/etc/zabbix_agentd.conf | grep -v "^$"
LogFile=/tmp/zabbix_agentd.log
Server=10.60.0.71      ##zabbix server監控主機的IP地址
ServerActive=10.60.0.71   ##zabbix server監控主機的IP地址
Hostname=10.60.0.163    ##zabbix client 即本機nginx的IP地址
UnsafeUserParameters=1   ##默認情況下可能沒有開啓,那麼你就把前面的註釋去掉即可


那麼在zabbix_agentd.conf裏隨便找個位置添加下列設定即可,我是放在了UnsafeUserParameters下面。

# vim /data0/zabbix/etc/zabbix_agentd.conf
UserParameter=nginx.accepts,/data0/zabbix/scripts/nginx_status.sh accepts  
UserParameter=nginx.handled,/data0/zabbix/scripts/nginx_status.sh handled  
UserParameter=nginx.requests,/data0/zabbix/scripts/nginx_status.sh requests  
UserParameter=nginx.connections.active,/data0/zabbix/scripts/nginx_status.sh active  
UserParameter=nginx.connections.reading,/data0/zabbix/scripts/nginx_status.sh reading  
UserParameter=nginx.connections.writing,/data0/zabbix/scripts/nginx_status.sh writing  
UserParameter=nginx.connections.waiting,/data0/zabbix/scripts/nginx_status.sh waiting

重啓下zabbix agent服務,讓我們剛剛的配置設定生效

# pkill -9 zabbix_agentd
# /data0/zabbix/sbin/zabbix_agentd

現在關於zabbix client端的設定都已經完畢。轉站zabbix server監控主機

首先測試zabbix server是否可以通過zabbix_get來獲取到zabbix client端Nginx服務的數據

# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.accepts"
1422577
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.handled"
1422800
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.requests"
2654085
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.connections.active"
17
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.connections.reading"
0
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.connections.writing"
3
# /usr/local/zabbix/bin/zabbix_get -s 10.60.0.163 -p 10050 -k "nginx.connections.waiting"
9

從上面上看,Nginx服務被監控項都是沒有問題的。


在網上搜索到適合你用Nginx status的zabbix模板,然後把模板導入到zabbix web內,下面是我在自己的zabbix web上匯出的Nginx status的模板。如果覺得合適,也可以在文章最下方下載我的模板。

  <?xml version="1.0" encoding="UTF-8" ?> 
- <zabbix_export>
  <version>2.0</version> 
  <date>2017-06-27T13:30:39Z</date> 
- <groups>
- <group>
  <name>Freetrade</name> 
  </group>
  </groups>
- <templates>
- <template>
  <template>Nginx Status</template> 
  <name>Nginx Status</name> 
- <groups>
- <group>
  <name>Freetrade</name> 
  </group>
  </groups>
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
- <items>
- <item>
  <name>Nginx Accepts</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.accepts</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Connections Active</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.connections.active</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Connections Reading</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.connections.reading</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Connections Waiting</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.connections.waiting</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Connections Writing</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.connections.writing</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Handled</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.handled</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
- <item>
  <name>Nginx Requests</name> 
  <type>7</type> 
  <snmp_community /> 
  <multiplier>0</multiplier> 
  <snmp_oid /> 
  <key>nginx.requests</key> 
  <delay>30</delay> 
  <history>365</history> 
  <trends>365</trends> 
  <status>0</status> 
  <value_type>3</value_type> 
  <allowed_hosts>localhost</allowed_hosts> 
  <units /> 
  <delta>0</delta> 
  <snmpv3_contextname /> 
  <snmpv3_securityname /> 
  <snmpv3_securitylevel>0</snmpv3_securitylevel> 
  <snmpv3_authprotocol>0</snmpv3_authprotocol> 
  <snmpv3_authpassphrase /> 
  <snmpv3_privprotocol>0</snmpv3_privprotocol> 
  <snmpv3_privpassphrase /> 
  <formula>0</formula> 
  <delay_flex /> 
  <params /> 
  <ipmi_sensor /> 
  <data_type>0</data_type> 
  <authtype>0</authtype> 
  <username /> 
  <password /> 
  <publickey /> 
  <privatekey /> 
  <port /> 
  <description /> 
  <inventory_link>0</inventory_link> 
- <applications>
- <application>
  <name>Nginx</name> 
  </application>
  </applications>
  <valuemap /> 
  </item>
  </items>
  <discovery_rules /> 
  <macros /> 
  <templates /> 
  <screens /> 
  </template>
  </templates>
- <graphs>
- <graph>
  <name>Nginx Clients Status</name> 
  <width>900</width> 
  <height>200</height> 
  <yaxismin>0.0000</yaxismin> 
  <yaxismax>100.0000</yaxismax> 
  <show_work_period>1</show_work_period> 
  <show_triggers>1</show_triggers> 
  <type>0</type> 
  <show_legend>1</show_legend> 
  <show_3d>0</show_3d> 
  <percent_left>0.0000</percent_left> 
  <percent_right>0.0000</percent_right> 
  <ymin_type_1>0</ymin_type_1> 
  <ymax_type_1>0</ymax_type_1> 
  <ymin_item_1>0</ymin_item_1> 
  <ymax_item_1>0</ymax_item_1> 
- <graph_items>
- <graph_item>
  <sortorder>0</sortorder> 
  <drawtype>0</drawtype> 
  <color>0000EE</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.connections.active</key> 
  </item>
  </graph_item>
- <graph_item>
  <sortorder>1</sortorder> 
  <drawtype>0</drawtype> 
  <color>EE0000</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.connections.writing</key> 
  </item>
  </graph_item>
- <graph_item>
  <sortorder>2</sortorder> 
  <drawtype>0</drawtype> 
  <color>EEEE00</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.connections.waiting</key> 
  </item>
  </graph_item>
- <graph_item>
  <sortorder>3</sortorder> 
  <drawtype>0</drawtype> 
  <color>00EE00</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.connections.reading</key> 
  </item>
  </graph_item>
  </graph_items>
  </graph>
- <graph>
  <name>Nginx Socket Status</name> 
  <width>900</width> 
  <height>200</height> 
  <yaxismin>0.0000</yaxismin> 
  <yaxismax>100.0000</yaxismax> 
  <show_work_period>1</show_work_period> 
  <show_triggers>1</show_triggers> 
  <type>0</type> 
  <show_legend>1</show_legend> 
  <show_3d>0</show_3d> 
  <percent_left>0.0000</percent_left> 
  <percent_right>0.0000</percent_right> 
  <ymin_type_1>0</ymin_type_1> 
  <ymax_type_1>0</ymax_type_1> 
  <ymin_item_1>0</ymin_item_1> 
  <ymax_item_1>0</ymax_item_1> 
- <graph_items>
- <graph_item>
  <sortorder>0</sortorder> 
  <drawtype>0</drawtype> 
  <color>00EE00</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.accepts</key> 
  </item>
  </graph_item>
- <graph_item>
  <sortorder>0</sortorder> 
  <drawtype>0</drawtype> 
  <color>EE0000</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.handled</key> 
  </item>
  </graph_item>
- <graph_item>
  <sortorder>1</sortorder> 
  <drawtype>0</drawtype> 
  <color>EEEE00</color> 
  <yaxisside>0</yaxisside> 
  <calc_fnc>2</calc_fnc> 
  <type>0</type> 
- <item>
  <host>Nginx Status</host> 
  <key>nginx.requests</key> 
  </item>
  </graph_item>
  </graph_items>
  </graph>
  </graphs>
  </zabbix_export>


首先你要先在zabbix web端創建一個空的templates即模板如下圖:

"組態--模板"-->到右上角"創建模板",填入你想要的模板名稱,以及所屬於該模板的主機,最後保存

wKioL1lVrbPh_O-bAAA_8qBOJ8I122.png

wKioL1lTeJzSsCnYAACtGiDFSlw852.png

wKiom1lVsDPAgryHAABTRVclx1M814.png

wKiom1lVsNGgWvhmAABJY3k3eKE225.png


把你下載好並修改成適合你的模板匯入到原創建好的空templates內,當然只要導入成功的話,你可以後期進templates去修改成適合你的。

選擇右上角的"匯入"--"選擇文件"--"匯入"

wKioL1lUrCyRLLjPAACUBEk-FNk614.png


要出現匯入成功的提示,才說明你的模板是合適的,但是合適不一定有用哦

wKioL1lUrH-xO_UMAACZzXCM5mo206.png


然後把你要的監控的Nginx主機納入到模板上去,再然後到被監控的Nginx主機裏去查看,該模塊是否被連結了

wKioL1lUrTej0tyWAAC2C1jamxY051.png

wKiom1lVt5-BRFt5AACh10fp-Bk594.png

你應該可以看到你的Nginx主機上多了一些圖形及項目,且在模板上已經鏈接到了你設定的新模板了


如果點進去看,nginx主機的監控項目中,Nginx服務相關的監控項目爲Zabbix端點代理程式(主動式)哦

wKioL1lUrwfS32vGAADOoEEMnE8748.png


當然如果你沒有導入模板成功,那你就老老實實一個個創建吧,不過也很簡單啦!一步一步來就好了,多做加深印象,還便於理解

先建立新模板

wKioL1lUr5GCvsu2AAA_8qBOJ8I511.png


在新建模板裏增加一個應用集

wKiom1lVuRCR6lCDAAA-YrewPVY935.png

wKioL1lVuVaQAaweAAAWjD6fzA8113.png


添加監控項進入新建模板,添加的內容一項一項地加,大致基本相同,唯一不同處是鍵值和名稱

wKiom1lUsJTD0vh9AABHHxGnOvM677.png

wKioL1lUsJXxO6ZvAAB2PfEL10I083.png


增加圖形監控,到這裏,只要你把監控項目創建好,在圖形監控只要選擇你要呈現圖形的監控項目即可

wKiom1lUsaeCMrfuAABFrpElruk422.png

wKioL1lUsajR8Q0KAACAx2cO00E779.png


到監控主機裏進模板連結,直接選擇現有的模板,然後添加保存

wKiom1lVudbi_pX_AACh10fp-Bk253.png

wKioL1lVuarjlkAEAADLt3aBcz0374.png

從上面看被監控主機已經載入新模板且項目集也存在了


最後查看通過"監測中"--"圖形"選擇被監控主機的圖形名稱,來看看圖是否有加載Nginx Client Status,Nginx Socket Status;如果有,恭喜你,監控設置就說明成功了!

wKiom1lVuq2iHp3fAAGQZ86w8Os101.png

wKioL1lVuq6AeBXkAAEHBC5M-N0275.png

如果想做些告警之類的,可以在規則中設定觸發器即可了,因爲大家需求各不相同,故在此就不再多說了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章