詳細請參考:yahoon兄的博客 http://yahoon.blog.51cto.com/13184/41897
我這裏只作了些我的修改ios
1.下載NSClient 至關於 nrpe
http://sourceforge.net/projects/nscpluswindows
2.MSDOS下
E:\soft\NSClient_2B%2B-0.3.8-Win32>nsclient++ /install服務器
3.查看服務是否有NSClient 開始-運行-services.msc
MSI版本的話就直接安裝好了,能夠省略上面:ide
![](http://static.javashuo.com/static/loading.gif)
雙擊打開NSClient,點」登陸」標籤,在」容許服務與桌面交互」前打勾
![](http://static.javashuo.com/static/loading.gif)
4.修改NSC.ini文件
ui
將 [modules]部分的全部模塊前面的註釋都去掉,除了CheckWMI.dll and RemoteConfiguration.dll這兩個 FileLogger.dll CheckSystem.dll CheckDisk.dll NSClientListener.dll NRPEListener.dll SysTray.dll CheckEventLog.dll CheckHelpers.dll ;CheckWMI.dll
|
在[Settings]部分設置'password'選項來設置密碼,做用是在nagios鏈接過來時要求提供密碼.這一步是可選的,我這裏方便起見跳過它,不要密碼.看最後
|
將[Settings]部分'allowed_hosts'選項的註釋去掉,而且加上運行nagios的監控主機的IP.我改成以下這樣
allowed_hosts=127.0.0.1/32,192.168.68.55
以逗號相隔.這個地方是支持子網的,若是寫成
192.168.0.0/24則表示該子網內的全部機器均可以訪問.若是這個地方是空白則表示全部的主機均可以鏈接上來.注意是[Settings]部分的,由於[NSClient]部分也有這個選項.
|
必須保證[NSClient]的'port'選項並無被註釋,而且它的值是'12489',這是NSClient的默認監聽端口 ;# NSCLIENT PORT NUMBER ; This is the port the NSClientListener.dll will listen to. port=12489
|
5.
在CMD中執行
nsclient++ /start
啓動服務
順便再服務裏設置NSClient自動啓動服務
檢測:
netstat -an 12489
6.
增長監控項目
vi /usr/local/nagios/etc/objects/hosts.cfg
#添加
define host {
host_name 192.168.68.79
alias squid1
address 192.168.68.79
contact_groups doggroup
check_command check-host-alive
check_period 24x7
max_check_attempts 5
notification_interval 10
notification_period 24x7
notification_options d,u,r
}
vi /usr/local/nagios/etc/services.cfg
#分別監控 CPU C盤空間 內存
define service{
host_name 192.168.68.79
service_description check-CPU
check_command check_nt!CPULOAD!-l 5,80,90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
define service{
host_name 192.168.68.79
service_description check-Cdrive
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
define service{
host_name 192.168.68.79
service_description check-Mem
check_command check_nt!MEMUSE!-w 80 -c 90
max_check_attempts 5
normal_check_interval 3
retry_check_interval 2
check_period 24x7
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
contact_groups doggroup
}
一樣的能夠增長以下服務(爲了篇幅,我只給出最關鍵的check_command這一項)
1)監控windows服務器運行的時間
check_command check_nt!UPTIME
2)監控Windows服務器的CPU負載,若是5分鐘超過80%則是warning,若是5分鐘超過90%則是critical
check_command check_nt!CPULOAD!-l 5,80,90
3)監控Windows服務器的內存使用狀況,若是超過了80%則是warning,若是超過90%則是critical
.
check_command check_nt!MEMUSE!-w 80 -c 90
4)監控Windows服務器C:\盤的使用狀況,若是超過80%已經使用則是warning,超過90%則是critical
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
注:-l後面接的參數用來指定盤符
5)監控Windows服務器D:\盤的使用狀況,若是超過80%已經使用則是warning,超過90%則是critical
check_command check_nt!USEDDISKSPACE!-l d -w 80 -c 90
6)監控Windows服務器的W3SVC服務的狀態,若是服務中止了,則是critical
check_command check_nt!SERVICESTATE!-d SHOWALL -l W3SVC
7)監控Windows服務器的
Explorer.exe
進程的狀態,若是進程中止了,則是critical
check_command check_nt!PROCSTATE!-d SHOWALL -l Explorer.exe
關於增長密碼:
this
若是NSClient設置了鏈接須要密碼,則應寫成以下格式
$USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s PASSWORD -v $ARG1$ $ARG2$
具體含義參考check_nt命令的用法
修改nsc.ini
[Settings]
;# OBFUSCATED PASSWORD
; This is the same as the password option but here you can store the password in an obfuscated manner.
; *NOTICE* obfuscation is *NOT* the same as encryption, someone with access to this file can still figure out the
; password. Its just a bit harder to do it at first glance.
;obfuscated_password=Jw0KAUUdXlAAUwASDAAB
;
;# PASSWORD
; This is the password (-s) that is required to access NSClient remotely. If you leave this blank everyone will be able to access the daemon remotly.
password=My2Secure$Password
--------------------------------------------------------------------------------------------------------------------------
vi command.cfg 修改
define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s My2Secure$Password -v $ARG1$ $ARG2$
}加密