nginx編譯時(shí)允許http_stub_status_module
然后在 nginx.conf 中 添加如下(粗體字部分)
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /data/web_server/index;
index index.html index.htm;
}
location /NginxStatus {
stub_status on;
access_log off;
}
}
#killall -s HUP nginx (令Nginx配置生效)
然后就通過(guò) http://localhost/NginxStatus 來(lái)訪(fǎng)問(wèn)到Nginx的運行狀態(tài)頁(yè)面
下載cacti for nginx 插件包: http://www.oschina.net/uploads/code/cacti-nginx.tar.gz
解壓后一共有5個(gè)文件,首先把 get_nginx_socket_status.pl 以及 get_nginx_clients_status.pl 上傳至服務(wù)器cacti 目錄下scripts 并設置可執行權限跟755讀寫(xiě)權限
檢測插件(舉例)
# /data/cacti/scripts/get_nginx_clients_status.pl http://192.168.1.100/NginxStatus
顯示的內容跟 NginxStatus 狀態(tài)頁(yè)內容相當即可。
然后在cacti管理面板導入
導入的方式是 Import Templates > Import Template from Local File (瀏覽導入插件包另外2個(gè)文件)
cacti_graph_template_nginx_clients_stat.xml
cacti_graph_template_nginx_sockets_stat.xml
但詳細操作起來(lái)可能會(huì )有個(gè)麻煩!
導入 cacti_graph_template_nginx_clients_stat.xml 跟 cacti_graph_template_nginx_sockets_stat.xml 的時(shí)候,cacti 出現紅字提醒:
Error: XML: Hash version does not exist.
解決:因為你的 cacti 版本太舊了,去Cacti 下個(gè)最新版吧:http://www.cacti.net/download_cacti.php
導入成功后會(huì )顯示:
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Cacti has imported the following items: GPRINT Preset [success] Normal [update]Data Input Method [success] nginx clients stat [update]Data Template [success] Nginx Clients Stat [update]Graph Template [success] Nginx Clients Stat [update] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
然后你就能在 Graph Templates 中看到你剛所導入 Xml 后所產(chǎn)生的模板

接著(zhù)進(jìn)入New Graphs 選擇任意一臺已經(jīng)創(chuàng )建好圖標的監控服務(wù)器。

呵...然后接下來(lái)的步驟不用說(shuō)了吧? 就跟創(chuàng )建網(wǎng)卡,CPU等之類(lèi)的圖表方式一樣。

聯(lián)系客服