码迷,mamicode.com
首页 > 移动开发 > 详细

Nagios监控系统的安装

时间:2016-03-28 16:58:43      阅读:268      评论:0      收藏:0      [点我收藏+]

标签:

环境:centOS 6.5 X86 64位 nagios-4.08

步骤:

1、  最小化安装系统

2、  修改安全特性

关闭SELINUX     SELINUX=disabled

清除iptables防火墙规则,开机不启动该服务

3、  安装所必须的软件

yum install gcc mysql httpd php gd openssl openssl-devel mysql-server vim wget

yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp

4、  创建/data目录,上传tar包到该目录

nagios-4.0.8.tar.gz

nagios-plugins-2.1.1.tar.gz

nrpe-2.12.tar.gz

pnp-0.4.14.tar.gz

rrdtool-1.4.5.tar.gz

5、  创建nagios组和用户并给创建用户目录/usr/local/nagios

mkdir /usr/local/nagios

groupadd nagios

useradd nagios -d /usr/local/nagios -s /sbin/nologin -g nagios

   chown -R nagios:nagios /usr/local/nagios/

6、  启动lnmp环境

/etc/init.d/httpd start

/etc/init.d/mysqld start

chkconfig --add httpd

chkconfig --add mysqld

chkconfig --level 35 httpd on

chkconfig --level 35 mysqld on

cd /var/www/html/

touch index.php

<?php

phpinfo();

?>

~ chown -R apache:apache index.php

使用浏览器打开http://10.0.0.10查看是否正正常解析php,如果能够正常解析,继续下一步。

7、  安装nagios

cd /data/

tar zxvf nagios-4.0.8.tar.gz

cd nagios-4.0.8

./configure --prefix=/usr/local/nagios --with-user=nagios --with-nagios-group=nagios

make all

make install

make install-init

make install-commandmode

make install-config

make install-webconf

cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/

chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers/

启动nagios服务

/etc/init.d/nagios start

chkconfig --add nagios
chkconfig --level 35 nagios on

创建nagios的web用户

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

8、  安装nagios-plugin

tar zxvf nagios-plugins-2.1.1.tar.gz

cd nagios-plugins-2.1.1

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

Make

make install

 9 、测试nagios安装

   /etc/init.d/httpd restart 重启apache服务

  在浏览器中输入http://10.0.0.10/nagios输入前面创建的nagios用户和密码进入

10.安装nrpe

 cd nrpe-2.12

./configure

make all

make && make install

make install-plugin

11.安装rrrdtool

安装依赖包

yum install -y pango pango-devel freetype freetype-devel libpng libpng-devel gettext gettext-devel libjpeg libjpeg-devel gd gd-devel libxml2 libxml2-devel libiconv libiconv-devel  qpixman qpixman-devel glib glib-devel cairo cairo-devel libart*

tar zxvf rrdtool-1.4.5.tar.gz

mkdir /usr/local/rrdtool

yum -y install libxml2-devel

yum -y install pang*

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

make && make install

报错:

make[3]: *** [perl-piped/Makefile] Error 2

make[3]: Leaving directory `/data/rrdtool-1.4.5/bindings‘

make[2]: *** [all-recursive] Error 1

make[2]: Leaving directory `/data/rrdtool-1.4.5/bindings‘

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/data/rrdtool-1.4.5‘

make: *** [all] Error 2

解决方法:

yum -y install libxml2 libxml2-devel

然后执行make

Make install

10.安装pnp4

tar zxvf pnp-0.4.14.tar.gz

mkdir /usr/local/pnp4nagios

cd pnp-0.4.14

./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool

报错:

configure: error: Perl Module Time::HiRes not available

解决方法:

yum install perl-Time-HiRes

make all

make install

make fullinstall

修改nagios.cfg

vi nagios.cfg

增加

process_performance_data=1

enable_environment_macros=1

host_perfdata_command=process-host-perfdata

service_perfdata_command=process-service-perfdata

vi commands.cfg

增加

define command{

command_name process-service-perfdata-pnp4nagios

command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl

}

define command{

command_name process-host-perfdata-pnp4nagios

command_line /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA

}

在模板配置文件中增加

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
}

Nagios监控系统的安装

标签:

原文地址:http://www.cnblogs.com/networking/p/5329435.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!