温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

CentOS5.5下搭建nagios

发布时间:2020-06-01 20:23:06 来源:网络 阅读:351 作者:China_boy2019 栏目:移动开发

 CentOS5.5下搭建nagios

一、搭建环境:

    一台CentOS5.5x86的系统,ip我默认使用的是nat的,这根据你自己的喜好设置就行了,在这我们是在虚拟机上搭建的,为了方便起见关闭了防火墙和selinux,如果在真实环境中需要做一些设置,这里就不多讲了。

二、所需软件:

    对于初学者而言最痛苦的莫过于下载所需要的软件包,为了方便大家我将所需要的软件包的下载地址罗列出来方便大家下载:

      apache我们就用系统光盘自带的就可以了

php我们使用编译安装

下载地址:http://museum.php.net/php5/php-5.2.17.tar.bz2

rrdtool-1.4.7.tar.gz 绘图引摯

下载地址:http://oss.oetiker.ch/rrdtool/pub/rrdtool-1.4.7.tar.gz

      nagios-3.3.1.tar.gz       主程序英文版

下载地址:http://www.nagios.org/download/core/thanks

      nagios-cn-3.2.3.tar.bz2   主程序中文版

下载地址:http://sourceforge.net/projects/nagios-cn/files/sourcecode/zh_CN%203.2.3/nagios-cn-3.2.3.tar.bz2/download

      nagios-plugins-1.4.15.tar.gz 插件程序

下载地址:http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/

      pnp-0.4.14.tar.gz     结合rrdtool出图

下载地址:http://sourceforge.net/projects/pnp4nagios/files/PNP/pnp-0.4.14/pnp-0.4.14.tar.gz/download

      nrpe-2.12.tar.gz      监控linux主机   

下载地址:http://d.119g.com/f/2D3D54B3A8BFDEC6.html

      NSClient++-0.3.9-Win32.msi   监控32windows主机

下载地址:http://files.nsclient.org/x-0.3.x_STABLE/NSClient%2B%2B-0.3.9-Win32.msi

      NSClient++-0.3.9-x64.msi     监控64windows主机

下载地址:http://files.nsclient.org/x-0.3.x_STABLE/NSClient%2B%2B-0.3.9-x64.msi

==================================================================

三、开始nagios安装前的准备:

   1、安装Rrdtool绘图引摯

      # tar zxvf rrdtool-1.4.7.tar.gz

      # cd  rrdtool-1.4.7

      # ./configuer --prefix=/usr/local/rrdtool

      # make && make install

   2、安装apache

      # yum -y install httpd*

   3、编译安装php

      # ./configuer --prefix=/usr/local/php5.2  --enable-mbstring     

        --with-apxs2=/usr/sbin/apxs

        --with-config-file-path=/usr/local/php5.2

      # make

      # make test

      # make install

4、修改httpd.conf配置文件

   # vi /etc/httpd/conf/httpd.conf添加一下内容:

   AddType  application/x-httpd-php  .php //770

   index.php //392

5、保存退出

6、启动apache测试php

   # service httpd restart

   # echo " wellcome to the apache web site !">/var/www/html/index.html

   # vi /var/www/html/index.php添加一下内容:

     <?php

     phpinfo();

     ?>

    保存退出

7、启动浏览器输入:http://your server ip/index.html,如果出现

    wellcome to the apache web site !说明你的apache没问题了,然后输入:http://your server ip/index.php出现php测试页面证明你的php没问题了,如果没有出现那就仔细检查检查

8、创建nagios用户和组

   # groupadd nagcmd//添加nagcmd用户组,用以通过web页面提交外部控制命令

   # useradd  nagios//添加一个名为nagios的用户用以专门跑nagios 

   # passwd   nagios//设置密码

   # usermod  -a -G nagcmd nagios//nagios用户加入nagcmd

   # usermod -a -G nagcmd apache apache用户加入nagcmd

==================================================================

四、下面开始正式安装nagios主程序包了

1、解压并进行编译安装:

   # tar jxvf nagios-cn-3.2.3.tar.bz2//这里使用中文安装,有兴趣的同

                                       学也可以使用英文安装

   # cd nagios-cn-3.2.3

   # ./configure --with-command-group=nagcmd

     make all      //编译

     make install  //安装nagios主要程序,cgihtml文件等

     make install-init    //安装nagios启动脚本

     make install-config  //将配置文件的例子复制到nagios配置文件里

     make install-commandmode    //配置nagios目录权限
这时nagios基本已经安装完成,默认安装后的配置文件用于启动nagios是没有问题的。

 #   make install-webconf   安装nagiosweb接口,会在   /etc/httpd/conf.d/创建   nagios.conf文件

 #  htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
设置登陆web界面时HTTP验证的账号密码

 #  service httpd restart  启动apache

2、启动浏览器输入:http://your server ip/nagios将会弹出一个用户登录框,这时输入你的用户名和密码就可以进入到nagios的主界面,不过这是如果你选择左边的选项它会提示服务器内部错误等信息,这是因为缺少插件,下面我们进行插件的安装

3、安装plugin插件:

 # tar zxvf 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

 # ls -l /usr/local/nagios/libexec/ 可以看到插件都装载这个目录下了

 # chkconfig  --add nagios

 # chkconfig nagios on

4、此时刷新页面再试就会出现自带的效果图

附件:http://down.51cto.com/data/2361753
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI