centos 6.5 nagios 4.0.8安装

关闭selinux

setenforce 0

永久的方法是

vi /etc/selinux/config

状态改为disabled

SELINUX=disabled

需要重启服务器,这里暂时不重启

关闭防火墙

/etc/init.d/iptables stop

删除防火墙规则,重启防火墙

mv /etc/sysconfig/iptables /opt

/etc/init.d/iptables restart

 

安装epel更新源

wgethttp://dl.fedoraproject.org/pub/epel/6Server/x86_64/epel-release-6-8.noarch.rpm

rpm -ivhepel-release-6-8.noarch.rpm

vi/etc/yum.repos.d/epel.repo

用以下命名将所有https替换成http

:%s/https/http/g

 

yum -y installyum-fastestmirror

rpm --import/etc/pki/rpm-gpg/RPM*

安装组件,注意:LAMP环境是用yum安装的,包含在以下命令中

yum -y install httpdgettext mysql mysql-server mysql-devel php php-mysql php-pear php-mysql mysqlperl mysql-server perl-DBI perl-DBD-MySQL httpd gcc glibc glibc-common gdgd-devel php gcc automake autoconf libtool make cairo-devel libxml2-develpango-devel pango libpng-devel freetype freetype-devel libart_lgpl-devel php-gdmysql-connector-odbc libgd libgd-devel libpng libpng-devel libjpeglibjpeg-devel zlib zlib-devel libxml2 libxml2-devel cairo* pango-devel*cairo-devel* perl-CPAN gruff ntp wget bc perl-Time-HiRes dejavu-lgc-sans-fonts mailxpatch

清除缓存

yum clean all

 

创建nagios用户和组

useradd nagios

usermod -s /sbin/nologinnagios

groupadd nagcmd  

usermod -G nagcmd nagios

usermod -G nagcmd apache

 

安装nagios

tar zxvfnagios-4.0.8.tar.gz -C /usr/src/

cd /usr/src/nagios-4.0.8/

从以下页面下载补丁文件

http://tracker.nagios.org/file_download.php?file_id=205&type=bug

打补丁,否则message日志报错"wproc: Unknown job type: 10"

patch -p1 <bogus_warnings.patch

 

./configure--prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios--with-command-group=nagcmd -with-gd-lib=/usr/lib64 -with-gd-inc=/usr/include

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf

cd /root/

 

安装nagios插件包

tar zxvfnagios-plugins-2.0.3.tar.gz -C /usr/src/

cd/usr/src/nagios-plugins-2.0.3/

./configure--with-nagios-user=nagios --with-nagios-group=nagios

make && make install

cd /root/

定义访问的nagios的密码

htpasswd -c/usr/local/nagios/etc/htpasswd.users nagiosadmin

 

安装绘图插件

tar zxvfrrdtool-1.4.7.tar.gz -C /usr/src/

cd/usr/src/rrdtool-1.4.7/

./configure--prefix=/usr/local/rrdtool

make && makeinstall

cd /root

编辑系统环境变量配置文件

vi /etc/profile

在最后一行添加

PATH=$PATH:/usr/local/rrdtool/bin

 

重新加载配置文件

source /etc/profile

查看rrdtool的版本信息

rrdtool -v

 

安装绘图组件

tar zxvf pnp4nagios-0.6.25.tar.gz-C /usr/src/

cd/usr/src/pnp4nagios-0.6.25/

./configure--prefix=/usr/local/pnp4nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool--with-nagios-user=nagios --with-nagios-group=nagios--with-perl_lib_path=/usr/local/rrdtool/lib/perl/5.10.1/x86_64-linux-thread-multi/

 

make all

make install

make install-webconf

make install-config

make install-init

make fullinstall

 

复制配置文件

cd/usr/local/pnp4nagios/etc

cp -pmisccommands.cfg-sample misccommands.cfg

cp -p nagios.cfg-samplenagios.cfg

cp -p rra.cfg-samplerra.cfg

cd pages/

cp -pweb_traffic.cfg-sample web_traffic.cfg

cd ../check_commands/

cp -p check_all_local_disks.cfg-samplecheck_all_local_disks.cfg

cp -pcheck_nrpe.cfg-sample check_nrpe.cfg

cp -pcheck_nwstat.cfg-sample check_nwstat.cfg

 

编译Nagios配置文件

cd /usr/local/nagios/etc/

cp nagios.cfgnagios.cfg.bak

vi nagios.cfg

 

process_performance_data=1

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

 

最后一行添加

service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata

service_perfdata_file_template=DATATYPE::SERVICEPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tSERVICEDESC::$SERVICEDESC$\tSERVICEPERFDATA::$SERVICEPERFDATA$\tSERVICEC::HECKCOMMAND::$SERVICECHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$\tSERVICESTATE::$SERVICESTATE$\tSERVICESTATETYPE::$SERVICESTATETYPE$

service_perfdata_file_mode=a

service_perfdata_file_processing_interval=15

service_perfdata_file_processing_command=process-service-perfdata-file

 

#

# host performancedata starting with Nagios 3.0

#

host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata

host_perfdata_file_template=DATATYPE::HOSTPERFDATA\tTIMET::$TIMET$\tHOSTNAME::$HOSTNAME$\tHOSTPERFDATA::$HOSTPERFDATA$\tHOSTCHECKCOMMAND::$HOSTCHECKCOMMAND$\tHOSTSTATE::$HOSTSTATE$\tHOSTSTATETYPE::$HOSTSTATETYPE$

host_perfdata_file_mode=a

host_perfdata_file_processing_interval=15

host_perfdata_file_processing_command=process-host-perfdata-file

 

编辑配置文件

cd objects/

cp commands.cfgcommands.cfg.bak

最后一行添加

vi commands.cfg

 

define command{

       command_name    process-service-perfdata-file

       command_line   /usr/local/pnp4nagios/libexec/process_perfdata.pl--bulk=/usr/local/pnp4nagios/var/service-perfdata

         }

define command{

       command_name    process-host-perfdata-file

       command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl--bulk=/usr/local/pnp4nagios/var/host-perfdata

         }

 

编辑模板文件

cp templates.cfgtemplates.cfg.bak

vi templates.cfg

最后一行添加

 

define host {

        name host-pnp

        action_url/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_

        register 0

        }

define service {

        name srv-pnp

        action_url/pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$

        register 0

        }

 

或者在在generic-service服务模板中添加下面一句

action_url                     /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$

也在local-service模板中添加下面一句

action_url                    /pnp4nagios/index.php?host=$HOSTNAME$

 

检查配置

../../bin/nagios -v../nagios.cfg

启动nagios

/etc/init.d/nagios start

/etc/init.d/httpd start

 

编辑网页配置文件

vi /etc/httpd/conf.d/nagios.conf

最后一行添加

 

Alias /pnp4nagios"/usr/local/pnp4nagios/share"

<Directory"/usr/local/pnp4nagios/share">

        AllowOverride None

        Order allow,deny

        Allow from all

        AuthName "Nagios Access"

        AuthType Basic

        AuthUserFile/usr/local/nagios/etc/htpasswd

        Require valid-user

        <IfModule mod_rewrite.c>

                RewriteEngine On

                Options FollowSymLinks

                RewriteBase /pnp4nagios/

                RewriteRule ^(application|modules|system)- [F,L]

                RewriteCond %{REQUEST_FILENAME}!-f

                RewriteCond %{REQUEST_FILENAME}!-d

                RewriteRule .* index.php/$0[PT,L]

        </IfModule>

</Directory>

 

检查http配置

apachectl -t

重启服务

/etc/init.d/httpd restart

/etc/init.d/nagiosrestart

 

访问naigos页面,点击Current Load 后面的rrd绘图的图标技术分享

技术分享

提示绿色字体,说明成功,提示重名文件

重命名以下文件

cd/usr/local/pnp4nagios/share

mv install.phpinstall.php.bak

 

再次刷新页面就正常了。

 

技术分享

如果出现红色方框,那就说明没有安装字体

yum install -y  dejavu-lgc-sans-fonts

再次刷新就可以了

技术分享

 

如果在网页执行操作时,提示

Could not open command file/usr/local/nagios/var/rw/nagiosNaNd’ for update

解决方法如下:

usermod -a -G nagiosapache

chmod 666/usr/local/nagios/var/rw/nagiosNaNd

chown nagios.nagcmd/usr/local/nagios/var/rw

chmod u+rwx /usr/local/nagios/var/rw

chmod g+rwx/usr/local/nagios/var/rw 

chmod g+s/usr/local/nagios/var/rw

 


本文出自 “陨落星空” 博客,请务必保留此出处http://xiao987334176.blog.51cto.com/2202382/1643881

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。