在rhel6下安装nagios
我安装的时候选择的是这几个包。
nagios-3.4.3.tar.gz、nagios-plugins-1.4.14.tar.gz、nrpe-2.12.tar.gz
因为其他的包太难下载了。国外的网站,你懂的。
服务端:
需要安装nagios 和nagios-plugins nrpe。安装之前要把编译环境都安装好了。比如gcc之类的。
通过本地yum源,安装开发环境。
yum groupinstall “Development tools”
openssl不知道是不是开发工具里面的。
安装之前要创建相应的用户和组
#groupadd -g 6000 nagios
#groupadd -g 6001 nagcmd
#useradd -u 6000 -g nagios -G nagcmd -d /home/nagios nagios
安装nagios。首先解压。打开。然后./configure –help一下。
./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-command-user=nagios --with-command-group=nagcmd --enable-event-broker --enable-nanosleep --enable-embedded-perl --with-perlcache
然后开始make
make all
make install
make install-init
make install-commandmode
make install-webconf
make install-config
如果要nagios和apache一起使用。那么就要配置apache了。
需要配置php。
vim httpd.conf
AddType application/x-httpd-php .php
DirectoryIndex index.html index.html.var index.php
#然后要添加nagios的目录
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType basic
Authuserfile /usr/local/nagios/etc/.htpasswd.users
Require valid-user
</Directory>
ScriptAlias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AllowOverride None
Options None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType basic
Authuserfile /usr/local/nagios/etc/.htpasswd.users
Require valid-user
</Directory>
还要更改apache的附属组
usermod -a -G nagios:nagcmd apache
完成之后就可以重启服务。然后进入http://localhost/nagios
访问了
service httpd restart
service nagios restart
chkconfig httpd on
chkconfig --add nagios
chkconfig nagios on
打开之后可以看到在监控本机。
现在添加一个linux用于监控
被监控端:
要安装nagios-pligins 和nrpe即可
安装之前要建用户建组和上面的差不多。
先安装nagios-plugins
安装的时候指定用户 组 命令组 和安装路径
然后make ;make install-plugin; make install-daemon;make install-daemon;make install-daemon-config
重启
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
echo "/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d " >>/etc/rc.d/rc.local
然后在监控端 开启一个object 把里面localhost.cfg复制一份。然后进行修改。把ip地址什么的改了。然后测试一下有没有出错。
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
然后重新启动。然后在网页里面就可以看到了。
总结
nagios的基本安装不难。但是要开发监控插件还是有点复杂。
需要了解nagios的文件结构。
比如nagios.cfg这个主配置文件里面。可以看到其他要加载的配置文件的信息。
其他配置文件都可以很灵活的配置。比如把localhost拷贝一份,稍微修改一下。就可以作为被控端的。
其他等日后再详细补充。