3、编译安装nagios:
# tar zxf nagios-3.3.1.tar.gz
# cd nagios-3.3.1
# ./configure --with-command-group=nagcmd --enable-event-broker
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# vi /usr/local/nagios/etc/objects/contacts.cfg
emailnagios@localhost #这个是默认设置
# make install-webconf
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
************建立模板文件******************
#cd /usr/local/nagios/etc/objects/
#vim linhost.cfg 或是 #cp localhost.cfg linhost.cfg
***定义远程Linux主机:
define host{
use linux-server
host_name linhost
alias my Linux Host
address 192.168.1.124
}
如主机组不需要则注释,添加服务可参照被监控端/usr/local/nagios/etc/nrpe.cfg中的command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20command[check_sda1]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda1command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Zcommand[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200 进行详细配置服务 ***定义远程Linux服务:也可以在后加参数进行设定监控
define service{
use generic-service host_name linhost service_description check_users check_command check_nrpe!check_users }# Create a service for monitoring the uptime of the server
# Change the host_name to match the name of the host you defined abovedefine service{ use generic-service host_name linhost service_description load check_command check_nrpe!check_load }# Create a service for monitoring CPU load
# Change the host_name to match the name of the host you defined abovedefine service{ use generic-service host_name linhost service_description sda1 check_command check_nrpe!check_sda1 }# Create a service for monitoring memory usage
# Change the host_name to match the name of the host you defined abovedefine service{ use generic-service host_name linhost service_description Zombie check_command check_nrpe!check_zombie_procs }define service{ use generic-service host_name linhost service_description Total procs check_command check_nrpe!check_total_procs }3)将设定好的linhost.cfg文件添加至/usr/local/nagios/etc/nagios.cfg中#vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/linhost.cfg
4)进行测试配置文件 # /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg5)重启服务#service nagios restart