dev/provisioning/modules/puppi/manifests/check.pp
changeset 28 b0b56e0f8c7f
equal deleted inserted replaced
27:a2342f26c9de 28:b0b56e0f8c7f
       
     1 # Define puppi::check
       
     2 #
       
     3 # This define creates a file with a check command that can be used locally.
       
     4 # It uses Nagios plugins for all checks so that $command is just the
       
     5 # plugin name with its arguments
       
     6 #
       
     7 # == Usage
       
     8 # Basic Usage:
       
     9 # puppi::check { "checkname":
       
    10 #   command => "check_tcp -H localhost -p 80"
       
    11 # }
       
    12 #
       
    13 # :include:../README.check
       
    14 #
       
    15 define puppi::check (
       
    16   $command,
       
    17   $base_dir = '',
       
    18   $hostwide = 'no',
       
    19   $priority = '50',
       
    20   $project  = 'default',
       
    21   $enable   = true ) {
       
    22 
       
    23   require puppi
       
    24   require puppi::params
       
    25 
       
    26   $ensure = bool2ensure($enable)
       
    27   $bool_hostwide = any2bool($hostwide)
       
    28 
       
    29   $real_base_dir = $base_dir ? {
       
    30     ''      => $puppi::params::checkpluginsdir,
       
    31     default => $base_dir,
       
    32   }
       
    33 
       
    34   $path = $bool_hostwide ? {
       
    35     true  => "${puppi::params::checksdir}/${priority}-${name}" ,
       
    36     false => "${puppi::params::projectsdir}/${project}/check/${priority}-${name}",
       
    37   }
       
    38 
       
    39   file { "Puppi_check_${project}_${priority}_${name}":
       
    40     ensure  => $ensure,
       
    41     path    => $path,
       
    42     mode    => '0755',
       
    43     owner   => $puppi::params::configfile_owner,
       
    44     group   => $puppi::params::configfile_group,
       
    45     require => Class['puppi'],
       
    46     content => "${real_base_dir}/${command}\n",
       
    47     tag     => 'puppi_check',
       
    48   }
       
    49 
       
    50 }