define host{
use linux-server ; Name of host template to use
host_name linuxserver
alias my linux server
address 192.168.0.102
}
###############################################################################
###############################################################################
#
# HOST GROUP DEFINITION
#
###############################################################################
###############################################################################
# Define an optional hostgroup for Linux machines
# hostgroup_name linux-servers ; The name of the hostgroup
# alias Linux Servers ; Long name of the group
# }
###############################################################################
###############################################################################
#
###############################################################################
###############################################################################
# Define a service to "ping" the local machine
define service{
host_name linuxserver
service_description users
check_command check_nrpe!check_users
# Define a service to check the disk space of the root partition
# on the local machine. Warning if < 20% free, critical if
# < 10% free space on partition.
define service{
host_name linuxserver
service_description load
check_command check_nrpe!check_load
# Define a service to check the number of currently logged in
# users on the local machine. Warning if > 20 users, critical
# if > 50 users.
define service{
host_name linuxserver
}
# Define a service to check the number of currently running procs
# on the local machine. Warning if > 250 processes, critical if
# > 400 users.
define service{
host_name linuxserver
}
# Define a service to check the load on the local machine.
define service{
host_name linuxserver
service_description zombie
check_command check_nrpe!check_zombie_procs
}
# Define a service to check the swap usage the local machine.
define service{
host_name linuxserver
service_description total
check_command check_nrpe!check_total_procs
}
# Define a service to check SSH on the local machine.
# Disable notifications for this service by default, as not all users may have SSH enab
led.
# Define a service to check HTTP on the local machine.
# Disable notifications for this service by default, as not all users may have HTTP ena
bled.
define service{
use local-service ; Name of service templat
e to use
host_name linuxserver
service_description swap
check_command check_nrpe!check_swap
}
vim ../nagios.cfg
添加一行
cfg_file=/usr/local/nagios/etc/objects/linux-server.cfg
4.检查语法错误
nagios -v /usr/local/nagios/etc/nagios.cfg
service nagios restart