将运行apache进程的用户加入到nagcmd组中
# usermod -a -G nagcmd apache
3、安装nagios
# tar zxf nagios-3.3.1.tar.gz
# cd nagios
# ./configure --with-command-group=nagcmd --enable-event-broker --sysconfdir=/etc/nagios
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
创建一个登录nagios web页面的用户,这个用户账号在以后通过web登录nagios时使用
# htpasswd -c /etc/nagios/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
启动httpd服务
# service httpd start
4、安装nagios-plugins插件
# tar zxf nagios-plugins-1.5.tar.gz
# cd nagios-plugins-1.5
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make && make install
5、启动nagios服务
# chkconfig --add nagios
# service nagios start
2、定义主机host及服务service
# vim /etc/nagios/objects/windows.cfg
define host{
use windows-server ; Inherit default values from a template
host_name winhost; The name we're giving to this host
alias My Windows Server ; A longer name associated with the host
address 10.1.1.254 ; IP address of the host
}
2)nrpe依赖于nagios-plugins,安装nagios-plugins
# tar zxf nagios-plugins-1.4.14.tar.gz
# cd nagios-plugins-1.4.14
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make all
# make install
3)安装nrpe
# tar zxf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
# make all
# make install-plugin
# make install-daemon
# make install-daemon-config
# chmod +x /etc/rc.d/init.d/nrpe
# chkconfig --add nrpe
# service nrpe start
# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 10.1.1.1:5666 0.0.0.0:* LISTEN 6826/nrpe
2、在监控端安装nrpe
1)安装nrpe
# tar zxf nrpe-2.15.tar.gz
# cd nrpe-2.15
# ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
# make all
# make install-plugin
2)定义主机host及服务service
# cp /etc/nagios/objects/windows.cfg /etc/nagios/objects/linux.cfg
# vim /etc/nagios/objects/linux.cfg
define host{
uselinux-server; Inherit default values from a template
host_namelinuxhost; The name we're giving to this host
aliasMy Linux Server; A longer name associated with the host
address10.1.1.1; IP address of the host
}