nagios安装(一)
去年安装过一次nagios但是当时没有成功,用的别人的监控机器,一直比较不顺,一直想自己再重新安装下,这段时间正好有时间,就安装了下,这次比较顺利,安装成功,步骤以及报错也详细的记录下来!
[root@suibian nagios]# yum install gcc glibc glibc-common gd gd-devel xinetd openssl-devel
[root@suibian nagios]# useradd -s /sbin/nologin nagios
[root@suibian nagios]# mkdir /usr/local/nagios
[root@suibian nagios]# chown -R nagios.nagios /usr/local/nagios/
[root@suibian nagios]# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.3.tar.gz
[root@suibian nagios]# tar zxvf nagios-3.4.3.tar.gz
[root@suibian nagios]# cd nagios
[root@suibian nagios]# ./configure –prefix=/usr/local/nagios/
[root@suibian nagios]# make all
[root@suibian nagios]# make install
[root@suibian nagios]# make install-init
[root@suibian nagios]# make install-commandmode
[root@suibian nagios]# make install-config
[root@suibian nagios]# chkconfig –add nagios
[root@suibian nagios]# chkconfig nagios on
[root@suibian nagios]# chkconfig –list nagios
nagios 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
[root@suibian nagios]# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
[root@suibian nagios]# tar zxvf nagios-plugins-1.4.16.tar.gz
[root@suibian nagios]# cd nagios-plugins-1.4.16
[root@suibian nagios-plugins-1.4.16]# ./configure –prefix=/usr/local/nagios/
[root@suibian nagios-plugins-1.4.16]# make && make install
[root@suibian conf]# vi /usr/local/apache2/conf/httpd.conf
User daemon
Group daemon
修改为
User nagios
Group nagios
最后变添加上
#setting for nagios
ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”
<Directory “/usr/local/nagios/sbin”>
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Nagios Access”
AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件
Require valid-user
</Directory>
Alias /nagios “/usr/local/nagios/share”
<Directory “/usr/local/nagios/share”>
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “nagios Access”
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
[root@suibian conf]# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd nagios
New password:
Re-type new password:
Adding password for user nagios 我设置的是123456
登陆发现是英文 ,我的英文不好,只好装汉化包 。。。
[root@suibian nagios]# wget http://sourceforge.net/projects/nagios-cn/files/nagios-cn-3.2.3.tar.bz2
[root@suibian nagios]# tar jxvf nagios-cn-3.2.3.tar.bz2
[root@suibian nagios]# cd nagios-cn-3.2.3
[root@suibian nagios-cn-3.2.3]# ./configure –prefix=/usr/local/nagios/
[root@suibian nagios-cn-3.2.3]# make all
[root@suibian nagios-cn-3.2.3]# make install
启动nagios 如下报错
[root@suibian local]# service nagios restart
Running configuration check…done.
Stopping nagios: done.
Starting nagios:This account is currently not available.
done.
[root@suibian local]# vi /etc/passwd
修改为如下信息
nagios:x:502:502::/home/nagios:/bin/bash
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
没问题了,nagios可以启动了,但是登陆上,发现提示:
无权查看任何主机的信息。 请检查HTTP服务器关于该CGI的访问权限设置。
搜索了一下方法
确保 htpasswd.user的所有组为nagios
解决办法:
vi /usr/local/nagios/etc/cgi.cfg
将use_authentication的值改为0.
use_authentication=0
然后重启nagios服务
service nagios restart 可以正常监控了!