标签:nagios监控
注:
本文档基于nagios+apache的模式,安装nagios时须预先编译安装apache,在此不进行apache编译安装的赘述。
一:配置apache
# vi /usr/local/apache/conf/extra/httpd-vhosts.conf NameVirtualHost *:80 <VirtualHost *:80> ServerName 192.168.189.132 DocumentRoot "/www" <Directory "/www"> Order deny,allow Deny from all </Directory> #以下是apache上,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" //配置nagios用户验证 Authuserfile /usr/local/nagios/etc/htpasswd Require valid-user </directory> </VirtualHost>
二:创建nagios用户与组
# useradd nagios # groupadd nagios # usermod –a –Gnagios nobody # usermod –a –Gnagios nagios
二:下载nagios相关软件包,并编译安装及环境配置
# cd /usr/local/src # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz # wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz # wget http://prdownloads.sourceforge.net/sourceforge/nagios/nrpe-2.13.tar.gz # tar -zxvf nagios-3.4.1.tar.gz # tar -zxvf nagios-plugins-1.4.16.tar.gz # tar -zxvf nagios/nrpe-2.13.tar.gz
编译安装nagios
# cd nagios-3.4.1/ # ./configure --prefix=/usr/local/nagios --with-command-group=nagios # make all # make install # make install-init # make install-commandmode # make install-config
编译安装nagios插件
# cd ../nagios-plugins-1.4.16
# ./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
# make && make install
编译安装nrpe
# cd ../nrpe-2.13 # ./configure --prefix=/usr/local/nagios # make all # make install-plugin
设置nagios目录权限
# chown –R nagios:nagios /usr/local/nagios/
配置用户密码访问
# /usr/local/apache/bin/htpasswd -cm /usr/local/nagios/etc/htpasswd nagiosadmin New password: Re-type new password: Adding password for usernagiosadmin
三:启用nagios,并访问测试
开启apache服务
# /usr/local/apache/bin/apachectl -k start
检测nagios配置文件语法是否正确
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
若语法正确,则可以正常启动nagios
# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg -d
(也可使用系统服务方式启动:service nagios start)
页面访问测试
出现以上页面,说明nagios安装部署成功。后续需在服务中添加主机与服务,方能开始进行监控。
本文出自 “扮演上帝的小丑” 博客,转载请与作者联系!
标签:nagios监控
原文地址:http://icenycmh.blog.51cto.com/4077647/1852000