標籤:nagios
#佈建服務端監控用戶端
[[email protected] etc]# cd objects/
[[email protected] objects]# vi hosts.cfg
# Define a host for the local machine
define host{
use linux-server
host_name 1.3-samba
alias 1.3-samba
address 10.89.1.3
}
define host{
use linux-server
host_name 1.2-nagios
alias 1.2-nagios
address 10.89.1.2
}
define host{
use linux-server
host_name 1.34-web-lnmp
alias 1.34-web-lnmp
address 10.89.1.34
}
define host{
use linux-server
host_name 1.34-web
alias 1.34-web
address 10.89.1.34
}
# Define an optional hostgroup for Linux machines
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members 1.3-samba,1.2-nagios,1.34-web-lnmp,1.34-web
}
儲存退出
檢查文法,先編輯nagios檔案,使出錯資訊顯示出來
[[email protected] objects]# vim /etc/init.d/nagios +183
$NagiosBin -v $NagiosCfgFile > /dev/null 2>&1; 修改為:
$NagiosBin -v $NagiosCfgFile
儲存退出
檢查文法,如果報錯如下:
[[email protected] objects]# /etc/init.d/nagios checkconfig
Checking services...
Error: There are no services defined!
Checked 0 services.
解決方案:
[[email protected] objects]# vi services.cfg
define service {
use generic-service
host_name 1.3-samba
service_description Disk Partition
check_command check_nrpe!check_disk
}
再檢查文法
[[email protected] objects]# /etc/init.d/nagios checkconfig
Total Warnings: 1
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check
OK.
[[email protected] objects]#
如果報下面錯誤:
Error:Service check command ‘check_nrpe‘ specified in service ‘Disk Partition‘ for
host ‘10-client01‘ not defined anywhere!
則編輯commands.cfg 檔案:
[[email protected] objects]# vi commands.cfg
再末尾加上
# ‘check_nrpe‘ command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
注意:command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ 實際上就是使用這個命令探測:
[[email protected] objects]#/usr/local/nagios/libexec/check_nrpe -H 10.89.1.3 -c check_disk
儲存並退出
再檢查文法
[[email protected] objects]# /etc/init.d/nagios checkconfig
沒有錯誤的情況下:
[[email protected] objects]# /etc/init.d/nagios reload
Running configuration check...done.
Reloading nagios configuration...done
[[email protected] objects]#
http://10.89.1.2/nagios
650) this.width=650;" src="http://s2.51cto.com/wyfs02/M02/8B/E0/wKioL1hblIjRr84hAABeqkBD1sI501.jpg-wh_500x0-wm_3-wmp_4-s_3414212499.jpg" title="登入提示" alt="wKioL1hblIjRr84hAABeqkBD1sI501.jpg-wh_50" />
如果登入後提示錯誤:
It appears as though you do not have permission to view information for any of the hosts you requested...
If you believe this is an error, check the HTTP server authentication requirements for accessing this CGI
and check the authorization options in your CGI configuration file.
編輯 cgi.cfg
[[email protected] objects]# cd ../
[[email protected] etc]# vi cgi.cfg
# PHYSICAL HTML PATH
# This is the path where the HTML files for Nagios reside. This
# value is used to locate the logo images needed by the statusmap
# and statuswrl CGIs.
physical_html_path=/usr/local/nagios/share
:g/nagiosadmin/s//alvin/g #替換nagiosadmin 為 alvin,該使用者是我安裝的時候添加的
儲存並退出
[[email protected] objects]# /etc/init.d/nagios reload
本文出自 “知識改變命運” 部落格,請務必保留此出處http://ahtornado.blog.51cto.com/4826737/1885155
nagios 監控配置介紹(二)