diff --git a/nagios/manifests/target.pp b/nagios/manifests/target.pp index f01d77c..1988a8b 100644 --- a/nagios/manifests/target.pp +++ b/nagios/manifests/target.pp @@ -491,7 +491,9 @@ class nagios::target::nrpe inherits nagios::target { # === Parameters # # $name: -# Check command. +# Symbolic name for service check. +# $command: +# Check command (including arguments). Defaults to $name. # $description: # Service description. Defaults to command name without # check_ prefix. @@ -512,17 +514,25 @@ class nagios::target::nrpe inherits nagios::target { # } # } # -define nagios::target::nrpe::service($source=undef, +define nagios::target::nrpe::service($command=undef, + $source=undef, $description=undef, $package=undef) { include nagios::target::nrpe - $binary = regsubst($name, '^([^ ]+) .*', '\1') - $service = regsubst($binary, '^check_(.+)', '\1') + if $command { + $command_real = $command + $binary = regsubst($command_real, '^([^ ]+) .*', '\1') + $config = $name + } else { + $command_real = $name + $binary = regsubst($command_real, '^([^ ]+) .*', '\1') + $config = $binary + } if !$description { - $description = $service + $description = regsubst($binary, '^check_(.+)', '\1') } if $source and !defined(File["${nagios::common::libdir}/${binary}"]) { @@ -548,7 +558,7 @@ define nagios::target::nrpe::service($source=undef, } } - file { "${nagios::target::nrpe::nrpedir}/${binary}.cfg": + file { "${nagios::target::nrpe::nrpedir}/${config}.cfg": ensure => present, mode => "0644", owner => "root", @@ -556,12 +566,12 @@ define nagios::target::nrpe::service($source=undef, "openbsd" => "wheel", default => "root", }, - content => "command[${binary}]=${nagios::common::libdir}/${name}\n", + content => "command[${binary}]=${nagios::common::libdir}/${command_real}\n", require => File["/etc/nrpe.d"], notify => Service["nrpe"], } - @@nagios::service { "${::homename}_${service}": + @@nagios::service { "${::homename}_${config}": command => "check_nrpe!${binary}", description => $description, host => $::homename,