进入nagios目录
cd /var/application/nagios/nagios
编译
./configure --with-command-group=nagios --enable-even-broker
make all
make install
make install-init
make install-commandmode
make install-config
安装nagios web配置文件
make install-webconf
创建web登陆用户nagiosadmin
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
cat /usr/local/nagios/etc/htpasswd.users
添加监控报警接收email地址
vi /usr/local/nagios/etc/objects/contacts.cfg +35
需要启动postfix
[root@resin nagios]# service postfix start
Starting postfix: [ OK ]
启动httpd
service httpd start
添加服务自启动
chkconfig --add nagios
chkconfig --level 3 nagios
3、编译安装nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
make
make install
检查插件个数
ls /usr/local/nagios/libexec/ |wc -l
4、编译安装nrpe
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
注意nrpe启动依赖于xinetd服务,若没有需先安装
[root@resin nrpe-1.8]# service xinted start
xinted: unrecognized service
解决: [root@resin nrpe-1.8]# yum -y install xinetd
[root@resin nrpe-1.8]# service xinetd restart
Stopping xinetd: [FAILED]
Starting xinetd: [ OK ]
三、nagios-client端配置
1、编译安装nagios-plugins(同服务端安装)
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
make
make install
ls /usr/local/nagios/libexec/ |wc -l
2、编译安装nrpe
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
四、Server端实现监控Client端
1、nagios-server编辑nrpe配置文件
vi /etc/xinetd.d/nrpe
编辑nagios配置文件,添加监控实例
[root@mail ~]# vi /usr/local/nagios/etc/nagios.cfg
# Definitions for monitoring the Linux host
cfg_file=/usr/local/nagios/etc/objects/mylinux.cfg
复制localhost.cfg 成实例文件mylinux.cfg
cp -r /usr/local/nagios/etc/objects/localhost.cfg /usr/local/nagios/etc/objects/mylinux.cfg
修改实例文件mylinux.cfg
vi /usr/local/nagios/etc/objects/mylinux.cfg