完整nagios安装最新pnp版绘图-sync模式

 最近搞了搞nagios并对最新版本的pnp加了图形,现就配置过程,写成文档如下,以备忘,也给广大同行一个借鉴参考。

    一、下载安装
    http://pnp4nagios.org 下载地址
    tar -xzvf pnp4nagios-0.6.16.tar.gz
    cd pnp4nagios-0.6.16
    ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata
    make all
    make install
    make install-webconf(可不做,只是安装pnp4nagios.conf文件到此路径: /etc/httpd/conf.d/pnp4nagios.conf下,可自行添加到httpd.conf中)
    make install-config
    make install-init
    二、配置
    1、配置nagios.cfg添加以下参数
    process_performance_data=1
    host_perfdata_command=process-host-perfdata
    service_perfdata_command=process-service-perfdata
    enable_environment_macros=1
    之后找到836行, 注释此语句
    #process_performance_data=0
    2、将下列配置文件重命名,使之能够被程序识别
    cd   /usr/local/pnp4nagios/etc 
    mv nagios.cfg-sample nagios.cfg (可不做)
    mv misccommands.cfg-sample  misccommands.cfg
    mv rra.cfg-sample rra.cfg
    cd /usr/local/pnp/etc/pages/
    mv web_traffic.cfg-sample web_traffic.cfg
    cd ../check_commands/
    mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
    mv check_nrpe.cfg-sample check_nrpe.cfg
    service npcd restart 
    3、修改nagios下配置文件 commands.cfg
    添加下面两行在文件的末行 ,并删除或注释掉原有对process-host-perfdata和process-service-perfdata进行定义的字段 
    define command {
           command_name    process-service-perfdata
           command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
    }
    define command {
           command_name    process-host-perfdata
           command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
    }
    4、修改配置文件templates.cfg
    define host {
            name       hosts-pnp
            register   0
            action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
            process_perf_data               1
    }
    define service {
            name       srv-pnp
            register   0
            action_url /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$ 
            process_perf_data               1
    }
    5、回到pnp解压目录下,复制鼠标悬停图标显示,预览绘图所需的文件 .
    cd    /root/soft/pnp4nagios-0.6.16/contrib/ssi
    cp * /usr/local/nagios/share/ssi/
    悬停在小太阳上就会出现预览图
    6、定义监控服务和主机配置文件
    修改主机配置文件
    define host{
            use                     standard-server,hosts-pnp
            host_name               localhost-93
            alias                   192.168.1.93
            address                 192.168.1.93
            }
     
    define host{
            use                     standard-server,hosts-pnp
            host_name              192.168.1.46
            alias                   192.168.1.46
            address                 192.168.1.46
            }
     
    修改服务配置文件
    define service {
            use                        service-all,srv-pnp
            host_name                  localhost-93
            service_description        check-http
            check_command              check_http
            }
     
    define service {
            use                        service-all,srv-pnp
            host_name                  localhost-93
            service_description        check-disk
            check_command              check_nrpe!check_disk
            }
     
    define service {
            use                        service-all,srv-pnp
            host_name                  localhost-93
            service_description        check-alive
            check_command              check-host-alive
            }
               
    define service {
            use                        service-all,srv-pnp
            host_name                  localhost-93
            service_description        check-load
            check_command              check_nrpe!check_load
            }    
         
    define service {
            use                        service-all,srv-pnp
            host_name                  localhost-93
            service_description        Prot-3306
            check_command              check_tcp!3306!-t 30 -w 10 -c 20
            }
    /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 
    重启nagios: service nagios restart
    7、修改apache配置文件添加下列
    Alias /pnp4nagios  "/usr/local/pnp4nagios/share" (也不能随便改路径否则无法点击小 太阳无法找到pnp4nagios访问,如果要改需要修改PHP文件)
     
    <Directory "/usr/local/pnp4nagios/share">
            AllowOverride None
            Order allow,deny
            Allow from all
            #
            # Use the same value as defined in nagios.conf
            #
            AuthName "Nagios Access"
            AuthType Basic
            AuthUserFile /usr/local/nagios/etc/htpasswd.users
            Require valid-user
            <IfModule mod_rewrite.c>
                    # Turn on URL rewriting
                    RewriteEngine On
                    Options FollowSymLinks
                    # Installation directory
                    RewriteBase /pnp4nagios/
                    # Protect application and system files from being viewed
                    RewriteRule ^(application|modules|system) - [F,L]
                    # Allow any files or directories that exist to be displayed directly
                    RewriteCond %{REQUEST_FILENAME} !-f
                    RewriteCond %{REQUEST_FILENAME} !-d
                    # Rewrite all other URLs to index.php/URL
                    RewriteRule .* index.php/$0 [PT,L]
            </IfModule>
    </Directory>
    重启apache: /usr/local/apache/bin/httpd -k restart
    三、测试
    wget http://verify.pnp4nagios.org/verify_pnp_config
    chmod +x verify_pnp_config
    perl verify_pnp_config --mode sync --config=/usr/local/nagios/etc/nagios.cfg --pnpcfg=/usr/local/pnp4nagios/etc
    [INFO] ========== Starting Environment Checks ============
    [INFO] My version is: verify_pnp_config-0.6.16-R.31
    [INFO] Reading /usr/local/nagios/etc/nagios.cfg
    [OK ] Running product is 'nagios'
    [OK ] object_cache_file is defined
    [OK ] object_cache_file=/usr/local/nagios/var/objects.cache
    [INFO] Reading /usr/local/nagios/var/objects.cache
    [OK ] resource_file is defined
    [OK ] resource_file=/usr/local/nagios/etc/resource.cfg
    [INFO] Reading /usr/local/nagios/etc/resource.cfg
    [INFO] Reading /usr/local/pnp4nagios/etc/process_perfdata.cfg
    [INFO] Reading /usr/local/pnp4nagios/etc/pnp4nagios_release
    [OK ] Found PNP4Nagios version "0.6.16"
    [OK ] Effective User is 'nagios'
    [OK ] User nagios exists with ID '503'
    [OK ] Effective group is 'nagios'
    [OK ] Group nagios exists with ID '504'
    [INFO] ========== Checking Sync Mode Config ============
    [OK ] process_performance_data is 1 compared with '/1/'
    [OK ] enable_environment_macros is 1 compared with '/1/'
    [OK ] service_perfdata_command is defined
    [OK ] service_perfdata_command=process-service-perfdata
    [OK ] host_perfdata_command is defined
    [OK ] host_perfdata_command=process-host-perfdata
    [INFO] Nagios config looks good so far
    [INFO] ========== Checking config values ============
    [OK ] Command process-service-perfdata is defined
    [OK ] '/usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl'
    [OK ] Command looks good
    [OK ] Script /usr/local/pnp4nagios/libexec/process_perfdata.pl is executable
    [OK ] Command process-host-perfdata is defined
    [OK ] '/usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA'
    [OK ] Command looks good
    [OK ] Script /usr/local/pnp4nagios/libexec/process_perfdata.pl is executable
    [INFO] ========== Starting global checks ============
    [OK ] status_file is defined
    [OK ] status_file=/usr/local/nagios/var/status.dat
    [INFO] Reading /usr/local/nagios/var/status.dat
    [INFO] ==== Starting rrdtool checks ====
    [OK ] RRDTOOL is defined
    [OK ] RRDTOOL=/usr/local/rrdtool/bin/rrdtool
    [OK ] /usr/local/rrdtool/bin/rrdtool is executable
    [OK ] RRDtool 1.4.5 Copyright 1997-2010 by Tobias Oetiker <[email protected]>
    [OK ] USE_RRDs is defined
    [OK ] USE_RRDs=1
    [OK ] Perl RRDs modules are loadable
    [INFO] ==== Starting directory checks ====
    [OK ] RRDPATH is defined
    [OK ] RRDPATH=/usr/local/nagios/share/perfdata
    [OK ] Perfdata directory '/usr/local/nagios/share/perfdata' exists
    [WARN] 11 hosts/services are not providing performance data
    [WARN] 'process_perf_data 1' is set for 12 hosts/services which are not providing performance data!
    [OK ] 'process_perf_data 1' is set for 131 of your hosts/services
    [INFO] ==== System sizing ====
    [OK ] 130 hosts/service objects defined
    [HINT] Use at least mode 'bulk' to reduce I/O
    [INFO] ==== Check statistics ====
    [WARN] Warning: 2, Critical: 0
    [WARN] Checks finished...
    1、pnp 编译错误
    configure: error: Perl Module Time::HiRes not available
    解决:
    yum instal perl*
    2、编译时候出现
    RRDs Perl Modules:             *** NOT FOUND ***
    解决:
    cp /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/auto/RRDs /RRDs.so     /usr/lib/perl5/5.8.5/i386-linux-thread-multi/
    cp /usr/local/rrdtool/lib/perl/5.8.5/i386-linux-thread-multi/* /usr/lib/perl5/5.8.5/i386-linux-thread-multi/
    3、php5.1.6无GD模块
    快速添加
    yum install php-gd
    重启apache
    http://www.boutell.com/gd/faq.html

四、生成的图像

你可能感兴趣的:(职场,绘图,nagios,nagios,pnp,休闲)