瀏覽代碼

Adding IcingaStatusWriter object. #7230

ricardo@cropalato.com.br 9 年之前
父節點
當前提交
38d1ac911a
共有 3 個文件被更改,包括 79 次插入0 次删除
  1. 15 0
      README.md
  2. 44 0
      manifests/object/icingastatuswriter.pp
  3. 20 0
      templates/object_icingastatuswriter.conf.erb

+ 15 - 0
README.md

@@ -403,6 +403,7 @@ Object types:
 * [icinga2::object::externalcommandlistener](#icinga2objectexternalcommandlistener)
 * [icinga2::object::host](#icinga2objecthost)
 * [icinga2::object::hostgroup](#icinga2objecthostgroup)
+* [icinga2::object::icingastatuswriter](#icinga2objecticingastatuswriter)
 * [icinga2::object::idomysqlconnection](#icinga2objectidomysqlconnection)
 * [icinga2::object::idopgsqlconnection](#icinga2objectidopgsqlconnection)
 * [icinga2::object::livestatuslistener](#icinga2objectlivestatuslistener)
@@ -649,6 +650,20 @@ If you would like to use an IPv6 address, make sure to set the `ipv6_address` pa
 
 Coming soon...
 
+####[`icinga2::object::icingastatuswriter`](id:object_icingastatuswriter)
+
+This defined type creates an **IcingaStatusWriter** objects.
+
+Example usage:
+<pre>
+icinga2::object::icingastatuswriter { 'status':
+   status_path       => '/cache/icinga2/status.json',
+   update_interval   => '15s',
+}
+</pre>
+
+See [IcingaStatusWriter](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-icingastatuswriter) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for more details about the object.
+
 ####[`icinga2::object::idomysqlconnection`](id:object_idomysqlconnection)
 
 This defined type creates an **IdoMySqlConnection** objects.

+ 44 - 0
manifests/object/icingastatuswriter.pp

@@ -0,0 +1,44 @@
+# == Defined type: icinga2::object::icingastatuswriter
+#
+# This is a defined type for Icinga 2 apply objects that create IcingaStatusWriter
+# See the following Icinga 2 doc page for more info:
+# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-checkercomponent
+#
+# === Parameters
+#
+# See the inline comments.
+#
+
+define icinga2::object::icingastatuswriter (
+  $ensure                    = 'file',
+  $object_name               = $name,
+  $status_path               = undef,
+  $update_internal           = undef,
+  $target_dir                = '/etc/icinga2/objects/icingastatuswriters',
+  $target_file_name          = "${name}.conf",
+  $target_file_owner         = 'root',
+  $target_file_group         = 'root',
+  $target_file_mode          = '0644'
+) {
+
+  if $status_path {
+    validate_string($status_path)
+  }
+  if $update_internal {
+    validate_string($update_internal)
+  }
+  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_icingastatuswriter.conf.erb'),
+    notify  => Service['icinga2'],
+  }
+}

+ 20 - 0
templates/object_icingastatuswriter.conf.erb

@@ -0,0 +1,20 @@
+/**
+* WARNING: This IcingaStatusWriter is automatically generated by Puppet.
+* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
+*/
+
+/**
+* A IcingaStatusWriter 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.
+*
+*/
+
+object IcingaStatusWriter "<%= @object_name %>" {
+<%- if @status_path -%>
+  status_path = LocalStateDir + "<%= @status_path -%>"
+<%- end -%>
+<%- if @update_interval -%>
+  update_interval = <%= @update_interval -%>
+<%- end -%>
+}