#定义一个主机组
define hostgroup{
hostgroup_name bsmart-servers #主机组名称,可以随意指定。
alias bsmart servers #主机组别名
members Nagios-Linux #主机组成员,其中“Nagios-Linux”就是上面定义的主机。
}
注意:在/usr/local/nagios/etc/objects 下默认有localhost.cfg 和windows.cfg 这两个配置文件,localhost.cfg 文件是定义监控主机本身的,windows.cfg 文件是定义windows 主机的,其中包括了对host 和相关services 的定义。所以在本次实验中,将直接在localhost.cfg 中定义监控主机(Nagios-Server),在windows.cfg中定义windows 主机(Nagios-Windows)。根据自己的需要修改其中的相关配置,详细如下:
localhost.cfg
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name Nagios-Server
alias Nagios-Server
address 127.0.0.1
}
define hostgroup{
hostgroup_name linux-servers ; The name of the hostgroup
alias Linux Servers ; Long name of the group
members Nagios-Server ; Comma separated list of hosts that belong to this group
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description Root Partition
check_command check_local_disk!20%!10%!/
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description Current Users
check_command check_local_users!20!50
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description Total Processes
check_command check_local_procs!250!400!RSZDT
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description Current Load
check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description SSH
check_command check_ssh
notifications_enabled 0
}
define service{
use local-service ; Name of service template to use
host_name Nagios-Server
service_description HTTP
check_command check_http
notifications_enabled 0
}
windows.cfg