puppet与nagios的结合

为了方便与puppet结合着用,所以接下去原本用源码编译的,统统改成用rpmbuild打包完,在放进自己建的源里面,本文也将说明本地源如何创建。

  文中软件包nrpe,和nagios-plugins均由上篇文章的spec生成。

  老规矩,先上架构图(ps:其实都差不多- -):

1.init.pp

import "*" 

2.web.pp

class nagios::web (    
  $nagiospluginsversion="1.4.16-10",    
  $nrpeversion="2.13-10"
){     
        file {"sa":    
          path    => "/root/sa",    
          ensure  => directory,    
        }    
        
        package {"xinetd":    
          ensure  => present,    
        }    
                
        package {"nagios-plugins":    
          ensure  => $nagiospluginsversion,    
        }    
        
        package {"nrpe":    
          ensure  => $nrpeversion,    
          require => Package["nagios-plugins"],    
        }    
        
        file {"nrpe.cfg":    
          mode      => 0644,    
          owner     => nagios,    
          group     => nagios,    
          path      => "/usr/local/nagios/etc/nrpe.cfg",    
          require   => Package["nrpe"],    
          content   => template('nagios/web-nrpe.erb'),    
          notify    => Service['xinetd'],      
        }    
        
        file {"nrpe":    
          mode      => 0644,    
          owner     => root,    
          group     => root,    
          path      => "/etc/xinetd.d/nrpe",    
          content   => template('nagios/nrpe.erb'),    
          require   => Package["nrpe"],    
          notify    => Service['xinetd'],    
        }    
              
        service {"xinetd":    
          ensure    => running,    
          enable    => true,    
          subscribe => File["nrpe","nrpe.cfg"],    
        }    
}

3,nrpe.erb

# default: on    
# description: NRPE (Nagios Remote Plugin Executor)    
service nrpe    
{    
        flags           = REUSE    
        socket_type     = stream        
          port              = 5666        
        wait            = no    
        user            = nagios    
          group             = nagios    
        server          = /usr/local/nagios/bin/nrpe    
        server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd    
        log_on_failure  += USERID    
        disable         = no    
          only_from       = 127.0.0.1 <%= nagios_server %>    
}

4,nrpe-web.erb

里面就是源码编译出来的nrpe.cfg的内容

5,site.pp

   ########################   for module nagios ########################    $nagios_server      = "192.168.10.211"

设置了nagios_server变量的值

6,node调用

(1),modules.pp

   import "nagios"

(2),site.pp

   node /^redis.w+.com$/ {        include nagios::web    }

当然也可以写进nodes.pp里面设置的节点里

7,创建本地源

我使用的是ftp来做

   (1)yum install vsftpd -y      (2)yum install createrep -y

然后把nrpe,nagios-plugins软件包复制到/var/ftp/pub下,生成依赖关系

   createrepo /var/ftp/pub

创建ftp.repo

   [ftp]    name=base    baseurl=ftp://192.168.10.211/pub    enabled=1    gpgcheck=0

最后在

   yum makecache

别忘了防火墙开启ftp端口

在此感谢itnihao大神的提供无私援助!!!

本文出自 “TNT、运维之路” 博客,请务必保留此出处http://tntdba.blog.51cto.com/1199791/1171046

你可能感兴趣的:(puppet与nagios的结合)