nagios配置全攻略

作者: 操作系统  发布:2019-09-06

经过整合pnp4nagios,ndoutils,nconf提供了关于nagios的一套完整的配备方案
操作系统Centos5.5,近年来最新版本的nagios3.3.1,装上之后分界面变化了太寒碜,所以这里本身还用3.2.3的版本来安装
先是把编写翻译景况准备好,大家这里把开垦库先都装上
yum groupinstall "Development Libraries" "Development Tools" "Legacy Software Development" "X Software Development" -y
#########################################################################
naigos安装配备:
安装要求的软件包
yum install  mysql perl mysql-server perl-DBI perl-DBD-MySQL httpd gcc glibc glibc-common gd gd-devel ruby ruby-devel2 ruby-devel mysql-devel
yum install php53-*           yum暗中认可安装的是5.1版本的php,可是pnp4nagios-0.6.6内需5.2上述版本的php,大家那边就装5.3的
wget
wget
useradd -m nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G apache nagios
tar zxf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure  --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
输入密码并切记,因为这一个同时也是网页访谈nagios时要输入的密码。
chkconfig --add nagios
chkconfig nagios on
chkconfig httpd on
chkconfig mysqld on
tar nagios-plugins-1.4.15.tar.gz
cd nagios-plugins-1.4.15
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

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更新源

wget

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/

从以下页面下载补丁文件

打补丁,不然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::SERVICEPERFDATAtTIMET::$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::HOSTPERFDATAtTIMET::$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绘图的Logo图片 1

图片 2

提拔古铜黑字体,表明成功,提醒重名文件

重命名以下文件

cd/usr/local/pnp4nagios/share

mv install.phpinstall.php.bak

双重刷新页面就好像常了。

图片 3

一经出现淡黄方框,那就证实未有安装字体

yum install -y dejavu-lgc-sans-fonts

双重刷新就能够了

图片 4

借使在网页推行操作时,提醒

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

6.5安装nagios 4.0.8 关闭selinux setenforce 0 长久的办法是 vi /etc/selinux/config 状态改为disabled SELINUX=disabled 须求重启服务器,这里前段时间不重启...

service nagios start
service httpd start
service mysqld start
使用
##########################################################################
pnp4nagios的装置和配备
接下去我们来配置pnp4nagios,可以把nagios捕获到的数量绘制作而成图片
rrdtool重视众多,这里自个儿选取下载rrdtool的rpm包 
rrdtool-perl-1.4.4-1.el5.wrl.i386.rpm rrdtool-devel-1.4.4-1.el5.wrl.i386.rpm rrdtool-1.4.4-1.el5.wrl.i386.rpm
rpm -ivh rrdtool-*
tar -xvf pnp4nagios-0.6.6.tar.gz
cd pnp4nagios-0.6.6
./configure --with-nagios-user=nagios --with-nagios-group=nagcmd
make all
make install
make install-webconf
make install-config
make isntall-init
make fullinstall
pnp4nagios官方提供了二种配备格局,笔者这里拔取一种
vi /usr/local/nagios/etc/nagios.cfg
process_performance_data=1

#
# service performance data
#
service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICEDESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECHECKCOMMAND::$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 performance data starting with Nagios 3.0
#
host_perfdata_file=/usr/local/pnp4nagios/var/host-perfdata
host_perfdata_file_template=DATATYPE::HOSTPERFDATAtTIMET::$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
vi /usr/local/nagios/etc/objects/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
}
cd /usr/local/pnp4nagios/share
mv install.php install.php.bak
访谈测量试验
  让nagios展现小太阳Logo
在pnp4nagios的源码包下边实践
 cp contrib/ssi/* /usr/local/nagios/share/ssi/
 然后在服务依然主机定义里面加多action_url
 define service{
        use                             local-service         ; Name of service template to use
        host_name                       localhost
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        action_url                      /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
        }
 define host{
        use                     linux-server           
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        action_url              /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
        }
效能如下:

图片 5

###########################################################################
设置nconf达成nagios的图形化配置
tar -xvf nconf-1.2.6-0.tgz -C /var/www/html/
chown -R apache:apache /var/www/html/nconf
为nconf创制数据库
mysql -u root -p
create database nconf;
grant all privileges on 数据库名称.* to '用户名'@'localhost' identified by '密码' with grant option;
然后经过浏览器访谈:

基于提示进行安装 然后删除 INSTALL/ INSTALL.php UPDATE/ UPDATE.php重新刷新页面就足以选拔了!
此处运用刚才建设构造的数据库

图片 6
那边运用暗许配置就好了

图片 7

上边是安装到位后的分界面

图片 8

##############################################################################
设置配备ndoutils把nagios的数量导入mysql数据库
mysql -u root -p
mysql>CREATE DATABASE nagios;
mysql>GRANT ALL ON nagios.* TO [email protected] IDENTIFIED BY ‘nagios’   授权nagios用户,密码为 Nagios
mysql>FLUSH PRIVILEGES;
wget
wget
tar -xvf ndoutils-1.4b9.tar.gz
cd ndoutils
patch -p1 -N < ../ndoutils1.4b9_light.patch
./configure --prefix=/usr/local/nagios/ --enable-mysql --disable-pgsql
   --with-ndo2db-user=nagios --with-ndo2db-group=nagios
make
cd db
./installdb ./installdb -u root -p 数据库密码 -d nagios
 
mysql -u root -p
mysql>USE nagios;
mysql>SHOW TABLES; 验证表已经转移
cd ndoutils-1.4b9
 cp ./src/ndomod-3x.o /usr/local/nagios/bin/ndomod.o
 cp ./src/ndo2db-3x /usr/local/nagios/bin/ndo2db
 cp ./config/ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg
 cp ./config/ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg
 chmod 774 /usr/local/nagios/bin/ndo*
 chown nagios:nagios /usr/local/nagios/bin/ndo*
 chown nagios:nagios /usr/local/nagios/etc/ndo*
vi ndo2db.cfg
db_name=nagios
db_user=nagios
db_pass=nagios
vi /usr/local/nagios/etc/nagios.cfg
加上以下两行
broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg
修改
event_broker_options=-1  //小编设置为1,测量检验也得以
 cp ./daemon-init /etc/init.d/ndo2db
 chmod +x /etc/init.d/ndo2db
 chkconfig --add ndo2db
 service nagios restart
 service ndo2db start
 tail -f /usr/log/nagios/var/nagios.log

图片 9

小编“成长全记录”

操作系统Centos5.5,如今新型版本的nagios3.3.1,装上之后分界面变化了太难看...

本文由今晚开什么码发布于操作系统,转载请注明出处:nagios配置全攻略

关键词: