首页 > 代码库 > yum install nagios and pnp4nagios

yum install nagios and pnp4nagios

环境:centos6.2


1.下载并安装epel包

    links    http://fedoraproject.org/wiki/EPEL


2.安装nagios及插件

    yum install nagios nagios-nrpe nagios-plugins* -y


3.启动httpd

    service httpd start;chkconfig httpd on


4.创建管理用户

    htpasswd -cm /etc/nagios/passwd user1


5.更改默认的管理用户名

    vim /etc/nagios/cgi.cfg

    :%s/nagiosadmin/user1/g


6.配置nagios 和pnp4nagios

    6.1.    vim /etc/nagios/nagios.cfg

                    process_performance_data=http://www.mamicode.com/0 //0改成1

                    host_perfdata_command=process-host-perfdata                //去掉注释
                    service_perfdata_command=process-service-perfdata       //去掉注释

    6.2.    vim /etc/nagios/objects/commands.cfg

                    define command{
                             command_name    process-host-perfdata
                             command_line    /usr/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl -d                                           HOSTPERFDATA
                }

                    define command{
                            command_name    process-service-perfdata

                            command_line    /user/bin/perl /usr/libexec/pnp4nagios/process_perfdata.pl
                }
    6.3.    vim /etc/nagios/objects/templates.cfg

                         define host{
                                name                            host-pnp
                                action_url                      /pnp4nagios/graph?host=$HOSTNAME$&srv=_HOST_
                                register                        0
                                process_perf_data               1
                }

                        define service{
                                name                            service-pnp
                                action_url                      /pnp4nagios/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
                                register                        0
                                process_perf_data               1
                }
    6.4.    cd /etc/nagios/objects/                //默认localhost.cfg文件包含本机及本机服务的配置

                vim hosts.cfg                                //新建主机配置文件hosts.cfg

                    define host{
                        use                     linux-server,host-pnp
                        host_name               localhost
                        alias                   localhost
                        address                 127.0.0.1
                                        }
                    define hostgroup{
                            hostgroup_name  linux-servers
                            alias           Linux Servers
                            members         localhost
                                                    }

                    vim services.cfg                    //新建主机的服务配置文件

                            define service{
                                use                             local-service,service-pnp
                                host_name                       localhost
                                service_description             PING
                                check_command                   check_ping!100.0,20%!500.0,60%
                                                        }
        6.5.    vim /etc/nagios/nagios.cfg                //新增以下2条

                               cfg_file=/etc/nagios/objects/hosts.cfg                    
                                cfg_file=/etc/nagios/objects/services.cfg
        6.6.    vim /etc/nagios/cgi.cfg

                         #default_user_name=guest        //去掉注释,修改成nagios管理用户userr1

                           default_user_name=user1


7.启动nagios服务

    service npcd start;chkconfig npcd on

    service nagios start;chkconfig nagios on





本文出自 “卫国保家” 博客,请务必保留此出处http://zengbaobao.blog.51cto.com/2672985/1438075