perfdatawriter.pp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # == Defined type: icinga2::object::perfdatawriter
  2. #
  3. # This is a defined type for Icinga 2 apply objects that create Perfdata Writer
  4. # See the following Icinga 2 doc page for more info:
  5. # http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-perfdatawriter
  6. #
  7. # === Parameters
  8. #
  9. # See the inline comments.
  10. #
  11. define icinga2::object::perfdatawriter (
  12. $ensure = 'file',
  13. $object_perfdatawritername = $name,
  14. $host_perfdata_path = undef,
  15. $service_perfdata_path = undef,
  16. $host_temp_path = undef,
  17. $service_temp_path = undef,
  18. $host_format_template = undef,
  19. $service_format_template = undef,
  20. $rotation_interval = undef,
  21. $target_dir = '/etc/icinga2/objects/perfdatawriters',
  22. $target_file_name = "${name}.conf",
  23. $target_file_owner = 'root',
  24. $target_file_group = 'root',
  25. $target_file_mode = '0644'
  26. ) {
  27. #Do some validation of the class' parameters:
  28. if $object_perfdatawritername {
  29. validate_string($object_perfdatawritername)
  30. }
  31. if $host_perfdata_path {
  32. validate_string($host_perfdata_path)
  33. }
  34. if $service_perfdata_path {
  35. validate_string($service_perfdata_path)
  36. }
  37. if $host_temp_path {
  38. validate_string($host_temp_path)
  39. }
  40. if $service_temp_path {
  41. validate_string($service_temp_path)
  42. }
  43. if $host_format_template {
  44. validate_string($host_format_template)
  45. }
  46. if $service_format_template {
  47. validate_string($service_format_template)
  48. }
  49. if $rotation_interval {
  50. validate_string($rotation_interval)
  51. }
  52. validate_string($target_dir)
  53. validate_string($target_file_name)
  54. validate_string($target_file_owner)
  55. validate_string($target_file_group)
  56. validate_re($target_file_mode, '^\d{4}$')
  57. file {"${target_dir}/${target_file_name}":
  58. ensure => $ensure,
  59. owner => $target_file_owner,
  60. group => $target_file_group,
  61. mode => $target_file_mode,
  62. content => template('icinga2/object_perfdatawriter.conf.erb'),
  63. notify => Service['icinga2'],
  64. }
  65. }