Quellcode durchsuchen

+ Added Livestatus Listener object. #7222

Ricardo Cropalato de Melo vor 9 Jahren
Ursprung
Commit
382bb05b5f
3 geänderte Dateien mit 111 neuen und 1 gelöschten Zeilen
  1. 16 1
      README.md
  2. 62 0
      manifests/object/livestatuslistener.pp
  3. 33 0
      templates/object_livestatuslistener.conf.erb

+ 16 - 1
README.md

@@ -335,6 +335,7 @@ Object types:
 * [icinga2::object::hostgroup](#icinga2objecthostgroup)
 * [icinga2::object::idomysqlconnection](#icinga2objectidomysqlconnection)
 * [icinga2::object::idopgsqlconnection](#icinga2objectidopgsqlconnection)
+* [icinga2::object::livestatuslistener](#icinga2objectlivestatuslistener)
 * [icinga2::object::notification](#icinga2objectnotification)
 * [icinga2::object::notificationcommand](#icinga2objectnotificationcommand)
 * [icinga2::object::service](#icinga2objectservice)
@@ -554,6 +555,21 @@ This defined type supports all of the parameters that **IdoMySqlConnection** obj
 
 See [IdoPgSqlConnection](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-idopgsqlconnection) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters.
 
+####[`icinga2::object::livestatuslistener`](id:object_livestatuslistener)
+
+This defined type creates a **LivestatusListener** objects.
+
+Example usage:
+
+<pre>
+icinga2::object::livestatuslistener { 'livestatus-unix':
+  socket_type => 'unix',
+  socket_path => '/var/run/icinga2/cmd/livestatus'
+}
+</pre>
+
+See [LivestatusListener](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-livestatuslistener) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters.
+
 ####`icinga2::object::notification`
 
 The `notification` defined type can create `notification` objects.
@@ -618,7 +634,6 @@ icinga2::object::notificationcommand { 'mail-service-notification':
     'USEREMAIL' => '"$user.email$"'
   }
 }
-
 </pre>
 
 This object use the same parameter defined to `checkcommand`.

+ 62 - 0
manifests/object/livestatuslistener.pp

@@ -0,0 +1,62 @@
+# == Defined type: icinga2::object::livestatuslistener
+#
+# This is a defined type for Icinga 2 apply objects that create Livestatus Listener
+# See the following Icinga 2 doc page for more info:
+# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-livestatuslistener
+#
+# === Parameters
+#
+# See the inline comments.
+#
+
+define icinga2::object::livestatuslistener (
+  $ensure                         = 'file',
+  $object_livestatuslisternername = $name,
+  $socket_type                    = undef,
+  $bind_host                      = undef,
+  $bind_port                      = undef,
+  $socket_path                    = undef,
+  $compat_log_path                = undef,
+  $target_dir                     = '/etc/icinga2/objects/livestatuslistener',
+  $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_livestatuslisternername {
+    validate_string($object_livestatuslisternername)
+  }
+  if $socket_type {
+    validate_string($socket_type)
+  }
+  if $bind_host {
+    validate_string($bind_host)
+  }
+  if $bind_port {
+    validate_string($bind_port)
+  }
+  if $socket_path {
+    validate_string($socket_path)
+  }
+  if $compat_log_path {
+    validate_string($compat_log_path)
+  }
+  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_livestatuslistener.conf.erb'),
+    notify  => Service['icinga2'],
+  }
+
+}

+ 33 - 0
templates/object_livestatuslistener.conf.erb

@@ -0,0 +1,33 @@
+/**
+* WARNING: This LivestatusListener definition is automatically generated by Puppet.
+* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
+*/
+
+/**
+* A LivestatusListener 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 "livestatus"
+
+object LivestatusListener "<%= @object_livestatuslistenerdname %>" {
+  <%#- If any of the @ parameters are undefined, don't print anything for them: -%>
+
+  <%- if @socket_type -%>
+  socket_type =  "<%= @socket_type -%>"
+  <%- end -%>
+  <%- if @bind_host -%>
+  bind_host =  "<%= @bind_host -%>"
+  <%- end -%>
+  <%- if @bind_port -%>
+  bind_port =  "<%= @bind_port -%>"
+  <%- end -%>
+  <%- if @socket_path -%>
+  socket_path =  "<%= @socket_path -%>"
+  <%- end -%>
+  <%- if @compat_log_path -%>
+  compat_log_path =  "<%= @compat_log_path -%>"
+  <%- end -%>
+}