zoukankan      html  css  js  c++  java
  • nagios安装

    本次安装环境是RHEL5.5server

    一、创建nagios用户和用户组

    [root@localhost ~]#useradd -s /sbin/nologin nagios

    [root@localhost ~]#mkdir /usr/local/nagios

    [root@localhost ~]#chown -R nagios.nagios /usr/local/nagios

    二、开启系统sendmail服务

    [root@localhost ~]#service sendmail start

    三、编译安装nagios

    [root@localhost ~]# tar -zxvf nagios-3.2.0.tar.gz

    [root@localhost ~]# cd nagios-3.2.0

    [root@localhost nagios-3.2.0]#./configure --prefix=/usr/local/nagios 

    #指定nagios的安装目录,这里指定nagios安装到/usr/local/nagios目录

    [root@localhost nagios-3.2.0]#make all 

    [root@localhost nagios-3.2.0]#make install      

    # make install用来安装nagios的主程序,CGIHTML文件

    [root@localhost nagios-3.2.0]# make install-init  

    #通过make install-init命令可以在/etc/rc.d/init.d目录下创建nagios启动脚本

    [root@localhost nagios-3.2.0]# make install-commandmode 

    #通过make install-commandmode命令来配置目录权限

    [root@localhost nagios-3.2.0]# make install-config  

    #make install-cofig命令用来安装nagios示例配置文件,这里安装的路径是/usr/local/nagios/etc

     

    nagios安装完成后,目录对应的功能说明如下:

    bin:可执行程序所在目录

    etc:配置文件所在目录

    sbincgi文件所在目录,也就是执行外部命令所需文件所在目录

    share:网页文件所在目录

    libexec:外部插件所在目录

    var:日志文件,lock等文件所在目录

    var/archives:日志自动归档目录

    var/rw:用来存放外部命令文件的目录

    四、安装nagios的插件

    nagios-plugins-1.4.14为例,插件版本与nagios版本关系并不大。

    [root@localhost nagios]#tar -zxvf  nagios-plugins-1.4.14.tar.gz

    [root@localhost nagios]#cd  nagios-plugins-1.4.14

    [root@localhost nagios-plugins-1.4.14]#./configure --prefix=/usr/local/nagios

    [root@localhost nagios-plugins-1.4.14]# make

    [root@localhost nagios-plugins-1.4.14]# make install

    查看/usr/local/nagios/libexec,会看到新增很多的插件。

    五、安装Nagios中文化插件

    下载地址:http://sourceforge.net/projects/nagios-cn/files/

    此处切忌版本要与nagios的版本对应。

    [root@localhost ~]#tar jxvf nagios-cn-3.2.0.tar.bz2

    [root@localhost nagios-cn-3.2.0]#cd nagios-cn-3.2.0

    [root@localhost nagios-cn-3.2.0]#./configure

    [root@localhost nagios-cn-3.2.0]#make all

    [root@localhost nagios-cn-3.2.0]#make install

    六、安装httpdphp

    依次执行如下命令:

    [root@localhost nagios-cn-3.2.0]#rpm -ivh httpd-2.2.3-43.el5.i386.rpm

    [root@localhost nagios-cn-3.2.0]#rpm -ivh php-common-5.1.6-27.el5.i386.rpm

    [root@localhost nagios-cn-3.2.0]#rpm -ivh php-cli-5.1.6-27.el5.i386.rpm

    [root@localhost nagios-cn-3.2.0]#rpm -ivh php-5.1.6-27.el5.i386.rpm

    以上软件包从安装盘中的server目录中寻找。

    七、配置httpdphp

    修改httpd的配置文件/etc/httpd/conf/httpd.conf

    找到如下两行

    User apache

    Group apache

    #如果找不到,请通过搜索nobody寻找

    修改为

    User nagios

    Group nagios

    然后找到

    DirectoryIndex index.html index.html.var

    修改为

    DirectoryIndex index.html index.html.var index.php

    再在其下增加如下行

    AddType application/x-httpd-php .php

    在配置文件末尾增加如下信息:

    #setting for nagios

    ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

             <Directory "/usr/local/nagios/sbin">

                 AuthType Basic

                 Options ExecCGI

                 AllowOverride None

                 Order allow,deny

                 Allow from all

                 AuthName "Nagios Access"

    AuthUserFile /usr/local/nagios/etc/htpasswd

                 Require valid-user

             </Directory>

     

    Alias /nagios "/usr/local/nagios/share"

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

                 AuthType Basic

                 Options None

                 AllowOverride None

                 Order allow,deny

                 Allow from all

                 AuthName "nagios Access"

    AuthUserFile /usr/local/nagios/etc/htpasswd

                 Require valid-user

             </Directory>

    保存配置文件

    八、新增验证文件

    [root@localhost]# /usr/bin/htpasswd -c /usr/local/nagios/etc/htpasswd mark

    New password: (输入密码)    

    Re-type new password: (再输入一次密码)    

    Adding password for user mark

    /usr/local/nagios/etc下就会新增一个htpasswd验证文件。

    九、验证

    [root@localhost]#service httpd restart

    [root@localhost]#vipw

    修改最后一行为

    nagios:x:500:501::/home/nagios:/bin/bash

    [root@localhost]#service nagios start

    通过浏览器输入http://ip/nagios/

    输入用户名/密码,就可以看到nagios的管理界面啦。此时看到的界面中没有任何监控机的信息。

    十、配置本机监控

    根据如下配置,完成本机监控的配置,先简单看看nagios监控的庐山真面目。本人已经验证在RHEL5.5下的nagios-3.2.0版本按如下配置之后,能实现nagios对本机的监控支持。

    1、新建monitor文件夹,拷贝示例配置文件到该文件夹下

    /usr/local/nagios/etc$cp -rf objects/ monitor

    2、删除不需要得配置文件

    /usr/local/nagios/etc/monitor$rm windows.cfg switch.cfg printer.cfg

    3、修改contacts.cfg(联系人配置文件)

    define contact{

            contact_name  mark            ;修改为自己名字

            use           generic-contact   ;引用generic-contact的属性信息

            alias          markjohnson     ; 全名

            email         mark@126.com   ; 修改为自己电子邮箱地址

            }

    define contactgroup{

            contactgroup_name       admins

            alias                    Nagios Administrators

            members                mark  ;添加上边定义的联系人名,以逗号分隔

            }

    4、修改cgi.cfg

    default_user_name=mark      ;将用户名修改为nagios界面登录的用户名

    5、修改nagios.cfg

    将所有cfg_file=都注释掉添加如下一行

    cfg_dir=/usr/local/nagios/etc/monitor

    6、使用命令:/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg检查配置是否有误

    7、重启nagiosservice nagios restart

    此时登录到nagiosweb界面,就能查看到监控界面左侧的主机和服务中有我们配置好的本地监控的信息啦。

    问题:

    1、  如果监控界面报出HTTP WARNING: HTTP/1.1 403 Forbidden错误,说明nagios不断地检查apache的根目录,在寻找index主页文件,执行如下命令:

    /usr/local/nagios/etc$touch /var/www/html/index.html

  • 相关阅读:
    测试心得
    mysql学习整理
    测试思考
    Win7下安装Mysql方法
    xcall.sh
    hive 的几款可视化连接工具
    mongo 使用 mongoexport 按照条件导出 csv 文件
    WebFlux springboot 2.0
    Calendar java  日历(常用小结)
    java 自定义注解(3)
  • 原文地址:https://www.cnblogs.com/osyun/p/2139641.html
Copyright © 2011-2022 走看看