command.pp 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Define icinga2::nrpe::command
  2. #
  3. # This defined type creates NRPE command definitions on machines running NRPE.
  4. #
  5. # Parameters:
  6. # * $command_name = What NRPE will know the command as; this defaults to the title of the resource
  7. # * $nrpe_plugin_libdir = The directory where the NRPE plugins themselves live
  8. # * $nrpe_plugin_name = The name of the plugin the command will run
  9. # * $nrpe_plugin_args = The arguments to pass to the plugin. This may be optional,
  10. # depending on the plugin and whether it expects any arguments or parameters
  11. define icinga2::nrpe::command (
  12. $command_name = $name,
  13. $nrpe_plugin_libdir = $icinga2::params::nrpe_plugin_libdir,
  14. $nrpe_plugin_name = undef,
  15. $nrpe_plugin_args = undef,
  16. ) {
  17. #Do some validation of the class' parameters:
  18. validate_string($command_name)
  19. validate_string($nrpe_plugin_libdir)
  20. validate_string($nrpe_plugin_name)
  21. validate_string($nrpe_plugin_args)
  22. file { "/etc/nagios/nrpe.d/${command_name}.cfg":
  23. owner => 'root',
  24. group => 'root',
  25. mode => '644',
  26. content => template('icinga2/nrpe_command.cfg.erb'),
  27. require => Package[$icinga2::params::icinga2_client_packages],
  28. notify => Service[$icinga2::params::nrpe_daemon_name]
  29. }
  30. }