Nagios check_http命令用法

Michael_DD發表於2014-08-11

Nagios check_http命令用法



//顯示版本
#./check_http -V
check_http v2053 (nagios-plugins 1.4.13)

//-H -u -p(不能直接-u寫URL,用-u時要用-H;-u帶的URL可以寫全或相對)
#./check_http -H www.****.com  
HTTP OK HTTP/1.1 200 OK
#./check_http -H www.****.com -u /url1/url2/index.html 
#./check_http -H www.****.com -u http://www.****.com/url1/url2/index.html  
#./check_http -H www.****.com -p 80 -u http://www.****.com/url1/url2/index.html  



//-I
#./check_http -I xxx.xxx.xxx -u /url1/url2/index.html  


//-e ; 預期伺服器返回的第一行字串匹配
# ./check_http -H "200 OK" 
HTTP OK HTTP/1.1 200 OK - 106540 bytes in 1.736 seconds |time=1.736245s;;;0.000000 size=106540B;;;0
# ./check_http -H "200 notOK" 
HTTP CRITICAL - Invalid HTTP response received from host: HTTP/1.1 200 OK


//-s 
; 預期頁面程式碼中的字串
//-M ;檢測頁面的 Last modified時間,如1m,1h,1d等(分鐘,小時,天);
# ./check_http -I 192.168.100.107 -u /cehq/zhishu.html -M 1m  
HTTP CRITICAL - Last modified 1:11:40 ago

//-m :; 最小頁面size(bytes):最大頁面size(bytes)
# ./check_http -I 192.168.100.107 -u /cehq/zhishu.html -m 100:200  
HTTP WARNING: page size 3466 too large|size=3466B;100;0;0

//-w和-c;定義warning和critical的告警閥值(單元:seconds)
# ./check_http -I 192.168.100.107 -u /cehq/zhishu.html -w 0.0001  
HTTP WARNING: - HTTP/1.1 200 OK - 0.002 second response time |time=0.001646s;0.000100;;0.000000 size=3466B;;;0
# ./check_http -I 192.168.100.107 -u /cehq/zhishu.html -c 0.0001  
HTTP CRITICAL: - HTTP/1.1 200 OK - 0.002 second response time |time=0.001778s;;0.000100;0.000000 size=3466B;;;0


// -N; 檢查一個頁面訪問,為了獲得較好的響應時間,不讀取頁面體,no-body:
# ./check_http -H   
HTTP OK: HTTP/1.1 200 OK - 4300 bytes in 0.015 second response time |time=0.014826s;;;0.000000 size=4300B;;;0

// -a; 以使用者名稱密碼訪問一個需認證的頁面:
# ./check_http -I 10.10.10.32 -u /nagios/  
HTTP WARNING: HTTP/1.1 401 Authorization Required - 717 bytes in 0.004 second response time |time=0.004006s;;;0.000000 size=717B;;;0
# ./usr/lib/nagios/plugins/check_http -I 192.168.10.2 -u /nagios/ -a nagios:nagios  
HTTP OK: HTTP/1.1 200 OK - 911 bytes in 0.005 second response time |time=0.004724s;;;0.000000 size=911B;;;0

//-t;連線超時的時間(default:10seconds)
#./check_http -H laabaa.com  
HTTP OK HTTP/1.1 200 OK - 106540 bytes in 1.840 seconds |time=1.839614s;;;0.000000 size=106540B;;;0
#./check_http -H laabaa.com -t 1 
CRITICAL - Socket timeout after 1 seconds
//-v;verbose,show details for command-line debugging

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1249062/,如需轉載,請註明出處,否則將追究法律責任。

相關文章