|
一、创建nagios用户和用户组。
[iyunv@localhost ~]#useradd -s /sbin/nologin nagios
[iyunv@localhost ~]#mkdir /usr/local/nagios
[iyunv@localhost ~]#chown -R nagios:nagios /usr/local/nagios
二、编译安装nagios
[iyunv@localhost ~]# tar -zxvf nagios-3.5.0.tar.gz
[iyunv@localhost ~]# cd nagios
[iyunv@localhost nagios]#./configure --prefix=/usr/local/nagios
[iyunv@localhost ~]# tar -zxvf nagios-3.5.0.tar.gz
[iyunv@localhost ~]# cd nagios
[iyunv@localhost nagios]#./configure --prefix=/usr/local/nagios
[iyunv@localhost nagios]#make all
[iyunv@localhost nagios]#make install
[iyunv@localhost nagios]# make install-init #在/etc/rc.d/init.d目录下创建nagios启动脚本
[iyunv@localhost nagios]# make install-config #安装示例配置文件
[iyunv@localhost nagios]# make install-commandmode #配置目录权限
三、nagios目录对应功能说明:
bin:可执行程序所在目录
etc:配置文件所在目录
sbin:cgi文件所在目录,也就是执行外部命令所需文件所在目录
share:网页文件所在目录
libexec:外部插件所在目录
var:日志文件,lock等文件所在目录
var/archives:日志自动归档目录
var/rw:用来存放外部命令文件的目录
四、安装nagios插件。
[iyunv@localhost ~]# tar -zxvf nagios-plugins-1.4.16.tar.gz
[iyunv@localhost ~]# yum -y install openssl*
[iyunv@localhost ~]# cd nagios-plugins-1.4.16
[iyunv@localhost nagios-plugins-1.4.16]# ./configure --prefix=/usr/local/nagios
[iyunv@localhost nagios-plugins-1.4.16]# make
[iyunv@localhost nagios-plugins-1.4.16]# make install
五、安装并配置httpd和php
[iyunv@localhost ~]# yum -y install php httpd
[iyunv@localhost ~]# vim /etc/httpd/conf/httpd.conf
User nagios
Group nagios
DirectoryIndex index.html index.html.var index.php
AddType application/x-httpd-php .php
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>
[iyunv@localhost ~]# htpasswd -cm /usr/local/nagios /etc/htpasswd USER
[iyunv@localhost ~]# service httpd restart
[iyunv@localhost ~]# service nagios restart
#访问http://ip/nagios 输入用户/密码就可以看到nagios管理界面
六、安装插件NRPE
[iyunv@localhost ~]# tar -zxvf nrpe-2.14.tar.gz
[iyunv@localhost ~]# cd nrpe-2.14
[iyunv@localhost nrpe-2.14]# ./configure
[iyunv@localhost nrpe-2.14]# make all
[iyunv@localhost nrpe-2.14]# make install-plugin
[iyunv@localhost ~]# cd /usr/local/nagios/etc
[iyunv@localhost etc]# mkdir monitor
[iyunv@localhost etc]# cp -R objects/* monitor/
[iyunv@localhost etc]# vim monitor/commands.cfg
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
七、定义被监控主机和服务。
|
|
|
|
|
|
|