可以直接拷貝原有的進行修改,俺這個就是拷貝的原有的check_local_disk進行的。
修改host_name,service_description,check_command等
define service{
use generic-service ; Name of service template to use
host_name localhost
service_description qmail_pop3
is_volatile 0
check_period 24×7
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24×7
check_command check_pop!20%!10%!/
}
照貓畫虎的進行修改,然後去修改:
vi checkcommands.cfg
#’check_qmail’ command definition
define command{
command_name check_qmail
command_line $USER1$/check_smtp -H 127.0.0.1
}
define command{
command_name check_pop3
command_line $USER1$/check_pop -H 127.0.0.1
}
保存,然後檢查配置文件:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
如果沒有錯誤會顯示:
Total Warnings: 0
Total Errors: 0
如果有錯誤,請根據提示進行錯誤的修正。
重啟nagios
svc -d /service/nagios/ && svc -u /service/nagios/
通過web頁面檢查nagios的結果:
http://10.5.1.153/nagios/
點擊“Service Detail”
會出現:
2)添加主機並添加服務
俺們會監控這台主機的負載、磁盤等一些沒有通過端口方式啟動的服務器狀態,以及它的服務,比如:apache、mysql、qmail和ntp等等吧。那麼沒有端口的nagios直接能監控到嗎?答案是不行。所以俺們必須在兩台主機上安裝nrpe,nrpe可以啟動5666端口,把檢測的信息源源不斷的傳給監控中心的主機。
ok,俺們把apache、mysql、qmail和ntp先加上,這回俺們把監控的主機和服務新建一個文件:
cd /usr/local/nagios/etc/
touch 10_5_1_156.cfg
vi nagios.cfg
cfg_file=/usr/local/nagios/etc/10_5_1_156.cfg
vi 10_5_1_156.cfg
定義一個主機:
define host{
use generic-host ; Name of host template to use
host_name test_nrpe
alias client
address 10.5.1.156
check_command check-host-alive
max_check_attempts 1
check_period 24×7
notification_interval 120
notification_period 24×7
notification_options d,r
contact_groups admins
}
定義主機需要檢查的服務:
define service{
use generic-service ; Name of service template to use
host_name test_nrpe
service_description PING
is_volatile 0
check_period 24×7
max_check_attempts 1
normal_check_interval 1
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24×7
check_command check_ping!100.0,20%!500.0,60%
}
define service{
以下文章點擊率最高
Loading…