由于网上教程太多了,我就简单写写CentOS 6.5下Nagios 3.2安装过程吧,个人感觉nagios的安装真的很简单,难在熟练使用。
在RHEL5.3上配置基本的Nagios系统(使用Nagios-3.1.2)
CentOS 5.5+Nginx+Nagios监控端和被控端安装配置指南
Ubuntu 13.10 Server 安装 Nagios Core 网络监控运用
首先安装需要的环境基础,像apache、php、gd、gcc之类的
yum install httpd php gd gd-devel gcc* -y
安装需要的nagios和其插件,nagios监控都是通过插件来实现的
wget
wget
建立nagios用户和目录
useradd nagios
mkdir /usr/local/nagios
chown nagios.nagios /usr/local/nagios/
在下载的目录下进行进行一下命令(这个是从我本机的histroy里粘贴的)
tar zxvf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure --prefix=/usr/local/nagios/ --with-gd-lib=/usr/lib --with-gd-inc=/usr/include/
make all
make install
make install-init
make install-config
make install-commandmode
make install-config
tar zxvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --prefix=/usr/local/nagios/
make
make install
建立nagios验证用户test
/usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd test
在apache的配置文件内加上nagios的内容
vi /etc/httpd/conf/httpd.conf
使用Shift+g的组合键到最后一行,单击o键,在下一列加如(什么?你不懂?就是vi编译器的使用,快去看看吧~~地址:)
#setting for nagios 20070707
ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios /usr/local/nagios/share
<Directory "/usr/local/nagios/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
修改完了当然重启服务了
service httpd restart
chkconfig httpd on
这样就安装完成了,打开游览器输入你部署Nagios服务器的IP/nagios/
你可能出现的问题:
1.如果无法打开页面,请查看你系统的防火墙iptables。保证80端口的开放,或者直接关闭防火墙service iptables stop
2.重启apache服务时出现 Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
怎修改下/etc/httpd/conf/httpd.conf,将#ServerName前的#去掉
3.打开浏览器访问Nagios时,部分页面出现 internal server error,这个是eslinux的限制,关闭即可,修改/etc/selinux/config 下的SELINUX=enforcing改为SELINUX=disables,然后reboot重启。
4.页面出现woops!是因为你nagios没有启动,把nagios启动加入开机服务器内:
echo "/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg" >> /etc/rc.local
关于文章中的apache、iptables、selinux等,其实也很有意思的,网上资料也很多,以后有机会再写相关博文吧。