最近因为工作需要搭建nagios,初次接触
,看了很多网上很多nagios的教程,历尽千辛万苦
最终搭建了一个简单的
nagios,结合网上的教程我把自己做的配置贴出来,有错误欢迎指正 
一:环境准备
由于要搭建的nagios主机是一个裸机,所以搭建nagios监控系统前需要搭建一个简单的LAMP平台,
这里我就直接用yum安装了
yum -y install http* mysql* php-*
对于英语不好的我,每做完一步我就喜欢用echo $? 验证一下 看看返回值是不是0 如果是0说明操作正确,否则错误,这种方法对我很实用,谁让英语差呢!
[root@localhost ~]# service httpd start
启动 httpd: [确定]
[root@localhost ~]# chkconfig httpd on
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
231 User apache
232 Group apache
391 DirectoryIndex index.php index.html index.html.var
992 #setting for nagios
993 ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
994 <Directory "/usr/local/nagios/sbin">
995 AuthType Basic
996 Options ExecCGI
997 AllowOverride None
998 Order allow,deny
999 Allow from all
1000 AuthName "nagios access"
1001 AuthUserFile /usr/local/nagios/etc/htpasswd
1002 Require valid-user
1003 </Directory>
1004 Alias /nagios "/usr/local/nagios/share"
1005 <Directory "/usr/local/nagios/share">
1006 AuthType Basic
1007 Options ExecCGI
1008 AllowOverride None
1009 Order allow,deny
1010 Allow from all
1011 AuthName "nagios access"
1012 AuthUserFile /usr/local/nagios/etc/htpasswd
1013 Require valid-user
1014 </Directory>
创建apache目录的验证文件touch /usr/local/nagios/etc/htpasswd
添加用户
[root@localhost ~]# htpasswd -c /usr/local/nagios/etc/htpasswd cainiao
二:nagios安装
(1)创建nagios程序用户、组
[root@localhost ~]# useradd -s /sbin/nologin nagios
[root@localhost ~]# mkdir /usr/local/nagios/
[root@localhost ~]# chown -R nagios:nagios /usr/local/nagios/
( 2) 安装和编译nagios
搭建nagios所需要的软件已经放在/nagios
[root@localhost nagios]# tar zxf nagios-3.2.0.tar.gz
[root@localhost nagios]# cd nagios-3.2.0
[root@localhost nagios-3.2.0]# ./configure --prefix=/usr/local/nagios/
[root@localhost nagios-3.2.0]# make all ; make install ; make install-init ; make install-commandmode ; make install-config
[root@localhost nagios-3.2.0]# chkconfig --add nagios
[root@localhost nagios-3.2.0]# chkconfig nagios on
(3)安装nagios插件
[root@localhost nagios]# tar zxf nagios-plugins-1.4.14.tar.gz
[root@localhost nagios]# cd nagios-plugins-1.4.14
[root@localhost nagios-plugins-1.4.14]# ./configure --prefix=/usr/local/nagios/ ; make ; make insta
(4)安装Nagios的汉化包
[root@localhost nagios]# tar jxf nagios-cn-3.2.0.tar.bz2
[root@localhost nagios]# cd nagios-cn-3.2.0
[root@localhost nagios-cn-3.2.0]# ./configure ; make all ; make install
接下来通过浏览器验证nagios是否安装成功
http:.//nagios的ip/nagios 这里就假如nagios的服务器的ip是:192.168.1.1

用户就是刚才新建的 cainiao 密码是刚才新建此用户的输入的
接下来就是难点了
