运维监控利器Nagios的部署及配置
安装Nagios
安装前的准备工作:
useradd -s /sbin/nologin nagios
开启邮件服务,sendmail或postfix
编译安装
./configure --prefix=/usr/local/nagios
make all
make install
make install-init #安装/etc/rc.d/init.d/下的nagios启动脚本
make install-commandmode #配置目录权限
make install-config #安装配置示例文件,在/usr/local/nagios/etc下
设置开机自动启动
chkconfig --add nagios
chkconfig nagios --level 35 on
安装Nagios插件(nagios-plugins)
默认情况下Nagios只有很少的监控功能,因此要使用更多的监控功能需要安装插件
./configure --prefix=/usr/local/nagios
make
make install
插件会安装到/usr/local/nagios/libexec下
安装Nagios汉化插件(nagios-cn)
./configure --prefix=/usr/local/nagios
make all
make install
安装apache或nginx并整合php
./configure --prefix=/usr/local/apache
make
make install
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
make
make install
配置apache
vim /usr/local/apache/conf/httpd.conf
User nagios
Group nagios
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
发布nagios页面,为了安全起见需要对nagios页面进行认证
#############Nagios settings
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory /usr/local/nagios/sbin>
Options ExecCGI
Allowoverride None
Order allow,deny
Allow from all
AuthType Basic
AuthName "Nagios access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory /usr/local/nagios/share>
Options ExecCGI
Allowoverride None
Order allow,deny
Allow from all
AuthType Basic
AuthName "Nagios access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd ivan #创建认证文件