环境: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
}

最新文章

  1. Chrome 开发工具之Sources
  2. 华硕笔记本U盘启动系统/WinPE报错。Windows failed to start. A Recent hardware or software change might be the cause.
  3. jenkins环境搭建
  4. ItextDemo&lt;二&gt;
  5. [问题2015S06] 复旦高等代数 II(14级)每周一题(第七教学周)
  6. C++11中async中future用法(一)
  7. 类,抽象基类,接口类三者间的区别与联系(C++)
  8. Time, Clocks, and the Ordering of Events in a Distributed System
  9. 【转】分享10VPN
  10. JAVA的节点流和处理流以及流的关闭顺序
  11. Sherlock and Squares
  12. EasyUI项目驱动学习
  13. A - Alice&#39;s Print Service ZOJ - 3726 (二分)
  14. Bigger-Mai 养成计划,Python基础巩固三
  15. AngelToken钱包——值得投资与存币的钱包
  16. 面向对象【day07】:面向对象使用场景(十)
  17. 833. Find And Replace in String
  18. asp.net mvc 安全测试漏洞 &quot; HTTP 动词篡改的认证旁路&quot; 问题解决
  19. 【20K必备知识点】北上广Java开发月薪20K往上,该如何做,需要会写什么
  20. Javascript实现重力弹跳拖拽运动效果

热门文章

  1. dump json 显示中文问题
  2. hdoj 1286 找新朋友 【数论之欧拉函数】
  3. hdu1391(Number Steps )
  4. php使用 _before_index() 来实现访问页面前,判断登录
  5. 基于visual Studio2013解决面试题之0602全排列
  6. hdu1087Super Jumping! Jumping! Jumping!(最大递增序列和)
  7. java中怎么判断一个字符串中包含某个字符或字符串
  8. android 5.0新特性
  9. android 请求网络 和 httpclient的使用上传下载
  10. 在界面线程不能使用Sleep和WaitForSingleObject之类的函数, 使用 MsgWaitForMultipleObjects