CentOS下主要监控软件的区别可参考http://os.51cto.com/art/201104/252820.htm

在这里总结下nagios的安装配置.

1.安装必要组件:

yum -y install httpd php php-gd freetype php-mysql php-snmp php-devel mysql mysql-server perl-DBD-MySQL php-pdo net-snmp net-snmp-libs net-snmp-utils net-snmp-devel ruby ruby-devel gcc glibc glibc-common gd gd-devel ntp openssl openssl-devel

2.关闭selinux和iptables.

3.安装nagios:

----创建nagios用户和组:

[root@web1 ~]# useradd nagios
[root@web1 ~]# groupadd nagcmd
[root@web1 ~]# usermod –a -G nagcmd  nagios

 

----下载nagios程序和nagios插件

[root@web1 ~]# wget http://jaist.dl.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz

[root@web1 ~]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz

----解压nagios程序和插件

[root@web1 ~]# tar zxvf nagios-3.5.0.tar.gz

[root@web1 ~]# tar zxvf nagios-plugins-1.4.16.tar.gz

----安装nagios程序

[root@web1 ~]#cd nagios

[root@web1 nagios]#./configure --with-command-group=nagcmd

[root@web1 nagios]#make all

[root@web1 nagios]#make install

[root@web1 nagios]#make install-init

[root@web1 nagios]#make install-config

[root@web1nagios]#make install-commandmode

[root@web1 nagios]#make install-webconf

注意:

make install 用于安装主要的程序、CGI及HTML文件
make install-init 用于生成init启动脚本
make install-config 用于安装示例配置文件
make install-commandmode 用于设置相应的目录权限
make install-webconf 用于安装Apache配置文件

复制eventhandlers:

[root@web1 nagios]# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

[root@web1 libexec]# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

校验nagios配置文件是否配置有误:

[root@web1 libexec]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

添加修改http访问页面用户nagiosadmin及密码123456

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

启动nagios:

/etc/init.d/nagios start

/etc/init.d/httpd start

----安装nagios插件

[root@web1 ~]# cd nagios-plugins-1.4.16

[root@web1 nagios-plugins-1.4.16]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

[root@web1 nagios-plugins-1.4.16]# make

[root@web1 nagios-plugins-1.4.16]# make install

----通过web访问nagios:

image