From 425551736ffc361214661bda928f30259375adc2 Mon Sep 17 00:00:00 2001 From: Ricardo Cropalato de Melo Date: Thu, 13 Nov 2014 14:52:56 -0500 Subject: [PATCH] Adding StatusDataWriter object. #7223 --- README.md | 17 +++++++ manifests/object/statusdatawriter.pp | 54 ++++++++++++++++++++++ templates/object_statusdatawriter.conf.erb | 27 +++++++++++ 3 files changed, 98 insertions(+) create mode 100644 manifests/object/statusdatawriter.pp create mode 100644 templates/object_statusdatawriter.conf.erb diff --git a/README.md b/README.md index 3e3d358..a79e9a6 100644 --- a/README.md +++ b/README.md @@ -339,6 +339,7 @@ Object types: * [icinga2::object::notificationcommand](#icinga2objectnotificationcommand) * [icinga2::object::service](#icinga2objectservice) * [icinga2::object::servicegroup](#icinga2objectservicegroup) +* [icinga2::object::statusdatawriter](#icinga2objectstatusdatawriter) * [icinga2::object::syslogger](#icinga2objectsyslogger) * [icinga2::object::timeperiod](#icinga2objecttimeperiod) * [icinga2::object::user](#icinga2objectuser) @@ -642,6 +643,22 @@ icinga2::object::servicegroup { 'web_services': See [ServiceGroup](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-servicegroup) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters. +####[`icinga2::object::statusdatawriter`](id:object_statusdatawriter) + +This defined type creates **StatusDataWriter** objects. + +Example usage: + +
+icinga2::object::statusdatawriter { 'status':
+    status_path     => '/var/cache/icinga2/status.dat',
+    objects_path    => '/var/cache/icinga2/objects.path',
+    update_interval => 30s
+}
+
+ +See [StatusDataWriter](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-statusdatawriter) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-sysloglogger) for more info. + ####[`icinga2::object::sysloglogger`](id:object_syslogger) This defined type creates **SyslogLogger** objects. diff --git a/manifests/object/statusdatawriter.pp b/manifests/object/statusdatawriter.pp new file mode 100644 index 0000000..c0441d8 --- /dev/null +++ b/manifests/object/statusdatawriter.pp @@ -0,0 +1,54 @@ +# == Defined type: icinga2::object::statusdatawriter +# +# This is a defined type for Icinga 2 apply objects that create StatusDataWriter +# See the following Icinga 2 doc page for more info: +# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-statusdatawriter +# +# === Parameters +# +# See the inline comments. +# + +define icinga2::object::statusdatawriter ( + $ensure = 'file', + $object_statusdatawritername = $name, + $status_path = undef, + $object_path = undef, + $update_interval = undef, + $target_dir = '/etc/icinga2/objects/statusdatawriters', + $target_file_name = "${name}.conf", + $target_file_owner = 'root', + $target_file_group = 'root', + $target_file_mode = '0644' +) { + + #Do some validation of the class' parameters: + if $object_statusdatawritername { + validate_string($object_statusdatawritername) + } + if $status_path { + validate_string($status_path) + } + if $object_path { + validate_string($object_path) + } + if $update_interval { + validate_string($update_interval) + } + validate_string($target_dir) + validate_string($target_file_name) + validate_string($target_file_owner) + validate_string($target_file_group) + validate_re($target_file_mode, '^\d{4}$') + + + file {"${target_dir}/${target_file_name}": + ensure => $ensure, + owner => $target_file_owner, + group => $target_file_group, + mode => $target_file_mode, + content => template('icinga2/object_statusdatawriter.conf.erb'), + notify => Service['icinga2'], + } + +} diff --git a/templates/object_statusdatawriter.conf.erb b/templates/object_statusdatawriter.conf.erb new file mode 100644 index 0000000..6cca1b0 --- /dev/null +++ b/templates/object_statusdatawriter.conf.erb @@ -0,0 +1,27 @@ +/** +* WARNING: This StatusDataWriter definition is automatically generated by Puppet. +* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN! +*/ + +/** +* A StatusDataWriter definition. You can create your own configuration files +* in the conf.d directory (e.g. one per commnand). By default all *.conf +* files in this directory are included. +* +*/ + +library "compat" + +object StatusDataWriter "<%= @object_statusdatawritername %>" { + <%#- If any of the @ parameters are undefined, don't print anything for them: -%> + + <%- if @status_path -%> + status_path = "<%= @status_path -%>" + <%- end -%> + <%- if @objects_path -%> + objects_path = "<%= @objects_path -%>" + <%- end -%> + <%- if @update_interval -%> + update_interval = <%= @update_interval -%> + <%- end -%> +}