所用: nagios-3.5.1.tar.gz
nagios-plugins-2.0.3.tar.gz
httpd-2.2.29.tar.gz
php-5.5.20.tar.gz
1.创建用户(nagios)
useradd -s /sbin/nologin nagios
2.创建安装目录
mkdir /usr/local/nagios
3.赋予权限
chown -R nagios.nagios /usr/local/nagios/
4.安装nagios
tar -xvf
nagios-3.5.1.tar.gz
make all
make install
make install-init #安装主程序html,cgi 模块
make install-commandmode #配置目录权限
make install-config #安装配置文件
5.设置开机自启动nagios
cd /usr/local/nagios/bin
chkconfig --add nagios
chkconfig --level 35 nagios on
chkconfig --list nagios
6.安装nagios插件
nagios-plugins
tar -xvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
./configure --prefix=/usr/local/nagios/
make
make install
7.安装apache2 与php
tar -xvf
httpd-2.2.29.tar.gz
cd httpd-2.2.29
./configure --prefix=/usr/local/apache2
make
make install
tar -xvf php-5.5.20.tar.gz
cd php-5.5.20
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
make
make install
修改apache的配置文件httpd.conf
将
User daemon
Group daemon
更改为
User nagios
Group nagios
将
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
更改为
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
在<IfModule mime_module>中添加
AddType application/x-httpd-php .php #支持php
在末尾处添加:
#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
Deny from nothing
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>
创建用户名,密码
/usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd ixdba
输入密码即可。用户名为ixdba
启动apache
访问:
http://ip/nagios/ 输入用户名 ixdba,密码登陆即可。
检测配置是否正确
../bin/nagios -v nagios.cfg
如果有错误信息,会直接提示出来
配置
hosts.cfg 文件 检测主机的配置文件 默认系统没有带,需要自己手写配置。我一般将此文件放置在nagios/etc/objects目录下
vi hosts.cfg
service.cfg 文件 主要提供检测服务器的命令文件。
默认系统没有带,需要自己手写配置。我一般将此文件放置在nagios/etc/objects目录下
vi service.cfg
nagios.cfg nagios 的主要配置文件位于 nagios/etc目录下
vi nagios.cfg
再次检测nagios 的配置文件
启动与关闭 nagios
开启apache 服务 登陆访问 查看服务器状态