dev/provisioning/modules/puppi/manifests/check.pp
author ymh <ymh.work@gmail.com>
Tue, 20 Mar 2018 15:02:40 +0100
changeset 573 25f3d28f51b2
parent 28 b0b56e0f8c7f
permissions -rwxr-xr-x
Added tag 0.0.25 for changeset 190ae1dee68d

# Define puppi::check
#
# This define creates a file with a check command that can be used locally.
# It uses Nagios plugins for all checks so that $command is just the
# plugin name with its arguments
#
# == Usage
# Basic Usage:
# puppi::check { "checkname":
#   command => "check_tcp -H localhost -p 80"
# }
#
# :include:../README.check
#
define puppi::check (
  $command,
  $base_dir = '',
  $hostwide = 'no',
  $priority = '50',
  $project  = 'default',
  $enable   = true ) {

  require puppi
  require puppi::params

  $ensure = bool2ensure($enable)
  $bool_hostwide = any2bool($hostwide)

  $real_base_dir = $base_dir ? {
    ''      => $puppi::params::checkpluginsdir,
    default => $base_dir,
  }

  $path = $bool_hostwide ? {
    true  => "${puppi::params::checksdir}/${priority}-${name}" ,
    false => "${puppi::params::projectsdir}/${project}/check/${priority}-${name}",
  }

  file { "Puppi_check_${project}_${priority}_${name}":
    ensure  => $ensure,
    path    => $path,
    mode    => '0755',
    owner   => $puppi::params::configfile_owner,
    group   => $puppi::params::configfile_group,
    require => Class['puppi'],
    content => "${real_base_dir}/${command}\n",
    tag     => 'puppi_check',
  }

}