<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # 自定義nginx活動連接數監控 (1)添加用戶自定義參數 ``` [root@host-10-197-22-14 ~]# cat /etc/zabbix/zabbix_agentd.d/nginx.conf UserParameter=nginx.active,/usr/bin/curl -s "http://10.197.22.14:8080/nginx-status" | grep 'Active' | awk '{print $NF}' ``` (2)重啟zabbix-agent systemctl restart zabbix-agent (3)在server端使用zabbix_get 測試獲取 [root@host ~]# zabbix_get -s 10.197.22.14 -p 10050 -k "nginx.active" 1 (4)自定義監控內容 在web界面創建item ![7-37](http://pded8ke3e.bkt.clouddn.com/7-37.png) 自定義圖形 ![7-38](http://pded8ke3e.bkt.clouddn.com/7-38.png) (5)查看圖表信息 ![7-39](http://pded8ke3e.bkt.clouddn.com/7-39.png) # 監控nginx 添加監控大致流程 - 1.開啟Nginx監控 - 2.編寫腳本來進行數據采集。 - 3.設置用戶自定義參數 - 4.重啟zabbix-agent - 5.添加item - 6.創建圖形 - 7.創建觸發器 - 8.創建模板 (1)自定義監控腳本:zabbix_linux_plugin.sh ``` #!/bin/bash tcp_status_fun(){ TCP_STAT=$1 #netstat -n | awk '/^tcp/ {++state[$NF]} END {for(key in state) print key,state[key]}' > /tmp/netstat.tmp ss -ant | awk 'NR>1 {++s[$1]} END {for(k in s) print k,s[k]}' > /tmp/netstat.tmp TCP_STAT_VALUE=$(grep "$TCP_STAT" /tmp/netstat.tmp | cut -d ' ' -f2) if [ -z $TCP_STAT_VALUE ];then TCP_STAT_VALUE=0 fi echo $TCP_STAT_VALUE } nginx_status_fun(){ NGINX_PORT=$1 NGINX_COMMAND=$2 nginx_active(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| grep 'Active' | awk '{print $NF}' } nginx_reading(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| grep 'Reading' | awk '{print $2}' } nginx_writing(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| grep 'Writing' | awk '{print $4}' } nginx_waiting(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| grep 'Waiting' | awk '{print $6}' } nginx_accepts(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $1}' } nginx_handled(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $2}' } nginx_requests(){ /usr/bin/curl "http://127.0.0.1:"$NGINX_PORT"/nginx_status/" 2>/dev/null| awk NR==3 | awk '{print $3}' } case $NGINX_COMMAND in active) nginx_active; ;; reading) nginx_reading; ;; writing) nginx_writing; ;; waiting) nginx_waiting; ;; accepts) nginx_accepts; ;; handled) nginx_handled; ;; requests) nginx_requests; esac } memcached_status_fun(){ M_PORT=$1 M_COMMAND=$2 echo -e "stats\nquit" | nc 127.0.0.1 "$M_PORT" | grep "STAT $M_COMMAND " | awk '{print $3}' } redis_status_fun(){ R_PORT=$1 R_COMMAND=$2 (echo -en "INFO \r\n";sleep 1;) | nc 127.0.0.1 "$R_PORT" > /tmp/redis_"$R_PORT".tmp REDIS_STAT_VALUE=$(grep ""$R_COMMAND":" /tmp/redis_"$R_PORT".tmp | cut -d ':' -f2) echo $REDIS_STAT_VALUE } main(){ case $1 in tcp_status) tcp_status_fun $2; ;; nginx_status) nginx_status_fun $2 $3; ;; memcached_status) memcached_status_fun $2 $3; ;; redis_status) redis_status_fun $2 $3; ;; *) echo $"Usage: $0 {tcp_status key|memcached_status key|redis_status key|nginx_status key}" esac } main $1 $2 $3 ``` (2)上傳腳本到/etc/zabbix/zabbix_agentd.d (3)添加權限 ``` [root@host-10-197-22-14 zabbix_agentd.d]# chmod 777 zabbix_linux_plugin.sh ``` (4)修改nginx配置文件統一標準:`vim /usr/local/nginx/conf/nginx.conf` ``` location /nginx_status { stub_status on; access_log off; allow 127.0.0.1; deny all; } ``` (5)重載nginx ``` [root@host-10-197-22-14 zabbix_agentd.d]# /usr/local/nginx/sbin/nginx -t nginx: the configuration file /usr/local/nginx-1.15.2/conf/nginx.conf syntax is ok nginx: configuration file /usr/local/nginx-1.15.2/conf/nginx.conf test is successful [root@host-10-197-22-14 zabbix_agentd.d]# /usr/local/nginx/sbin/nginx -s reload ``` (6)驗證 在客戶端驗證 ``` [root@host-10-197-22-14 zabbix_agentd.d]# ./zabbix_linux_plugin.sh nginx_status 8080 active 1 [root@host-10-197-22-14 zabbix_agentd.d]# cat linux.conf UserParameter=linux_status[*],/etc/zabbix/zabbix_agentd.d/zabbix_linux_plugin.sh "$1" "$2" "$3" [root@lhost-10-197-22-14 zabbix_agentd.d]# systemctl restart zabbix-agent ``` 在服務端驗證 ``` [root@host-10-197-22-12 ~]# zabbix_get -s 10.197.22.14 -k linux_status[nginx_status,8080,active] 1 ``` (7)創建模板 ![7-47](http://pded8ke3e.bkt.clouddn.com/7-47.png) 填寫Template name ![7-48](http://pded8ke3e.bkt.clouddn.com/7-48.png) 給Template Nginx Statusu模板添加item ![7-49](http://pded8ke3e.bkt.clouddn.com/7-49.png) 創建item ![7-50](http://pded8ke3e.bkt.clouddn.com/7-50.png) 用克隆的方法添加6個item ![7-51](http://pded8ke3e.bkt.clouddn.com/7-51.png) ![7-52](http://pded8ke3e.bkt.clouddn.com/7-52.png) 添加完成如圖所示 ![7-53](http://pded8ke3e.bkt.clouddn.com/7-53.png) 創建圖表 ![7-54](http://pded8ke3e.bkt.clouddn.com/7-54.png) ![7-55](http://pded8ke3e.bkt.clouddn.com/7-55.png) 給host-10-197-22-14主機鏈接模板 ![7-56](http://pded8ke3e.bkt.clouddn.com/7-56.png) ![7-57](http://pded8ke3e.bkt.clouddn.com/7-57.png) 導出模板 ![7-58](http://pded8ke3e.bkt.clouddn.com/7-58.png) 查看圖表數據 ![7-59](http://pded8ke3e.bkt.clouddn.com/7-59.png) # nginx監控tcp和觸發器添加 tcp模板下載鏈路:[請點擊這里](https://pan.baidu.com/s/1fzoYyh8RzU9Qf93pIzRt1Q) 導入tcp模板 ![7-60](http://pded8ke3e.bkt.clouddn.com/7-60.png) 給host-10-197-22-12和host-10-197-22-14節點鏈接模板 ![7-61](http://pded8ke3e.bkt.clouddn.com/7-61.png) 查看圖表 ![7-62](http://pded8ke3e.bkt.clouddn.com/7-62.png) 添加一個觸發器 ![7-63](http://pded8ke3e.bkt.clouddn.com/7-63.png) ![7-64](http://pded8ke3e.bkt.clouddn.com/7-64.png) dashboard界面已經報警 ![7-65](http://pded8ke3e.bkt.clouddn.com/7-65.png)
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看