Adding PerfdataWriter object. #7220

Signed-off-by: Nick Chappell <nick@intronic.org>

Merged from: https://github.com/Icinga/puppet-icinga2/pull/47

refs#7220: https://dev.icinga.org/issues/7220
This commit is contained in:
Ricardo Cropalato de Melo 2014-11-13 12:43:07 -05:00 committed by Nick Chappell
parent 21b374923f
commit 5b289000e2
3 changed files with 133 additions and 0 deletions

View file

@ -364,6 +364,7 @@ Object types:
* [icinga2::object::idopgsqlconnection](#icinga2objectidopgsqlconnection)
* [icinga2::object::notification](#icinga2objectnotification)
* [icinga2::object::notificationcommand](#icinga2objectnotificationcommand)
* [icinga2::object::perfdatawriter](#icinga2objectperfdatawriter)
* [icinga2::object::service](#icinga2objectservice)
* [icinga2::object::servicegroup](#icinga2objectservicegroup)
* [icinga2::object::syslogger](#icinga2objectsyslogger)
@ -668,6 +669,24 @@ icinga2::object::notificationcommand { 'mail-service-notification':
This object use the same parameter defined to `checkcommand`.
####[`icinga2::object::prefdatawriter`](id:object_prefdatawriter)
This dfined type creates a **PerfdataWriter** object
Example usage:
<pre>
icinga2::object::prefdatawriter { 'pnp':
host_perfdata_path => '/var/spool/icinga2/perfdata/host-perfdata',
service_perfdata_path => '/var/spool/icinga2/perfdata/service-perfdata',
host_format_template => 'DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$',
service_format_template => 'DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$',
rotation_interval => '15s'
}
</pre>
See [PrefdataWriter](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-prefdatawriter) on [docs.icinga.org](http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc) for a full list of parameters.
####[`icinga2::object::service`](id:object_service)
Coming soon...

View file

@ -0,0 +1,70 @@
# == Defined type: icinga2::object::perfdatawriter
#
# This is a defined type for Icinga 2 apply objects that create Perfdata Writer
# See the following Icinga 2 doc page for more info:
# http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/configuring-icinga2#objecttype-perfdatawriter
#
# === Parameters
#
# See the inline comments.
#
define icinga2::object::perfdatawriter (
$ensure = 'file',
$object_perfdatawritername = $name,
$host_perfdata_path = undef,
$service_perfdata_path = undef,
$host_temp_path = undef,
$service_temp_path = undef,
$host_format_template = undef,
$service_format_template = undef,
$rotation_interval = undef,
$target_dir = '/etc/icinga2/objects/perfdatawriters',
$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_perfdatawritername {
validate_string($object_perfdatawritername)
}
if $host_perfdata_path {
validate_string($host_perfdata_path)
}
if $service_perfdata_path {
validate_string($service_perfdata_path)
}
if $host_temp_path {
validate_string($host_temp_path)
}
if $service_temp_path {
validate_string($service_temp_path)
}
if $host_format_template {
validate_string($host_format_template)
}
if $service_format_template {
validate_string($service_format_template)
}
if $rotation_interval {
validate_string($rotation_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_perfdatawriter.conf.erb'),
notify => Service['icinga2'],
}
}

View file

@ -0,0 +1,44 @@
/**
* WARNING: This PerfdataWtiter definition is automatically generated by Puppet.
* ANY MANUAL CHANGES TO IT WILL GET OVERWRITTEN!
*/
/**
* A PerfdataWriter 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 "perfdata"
object PerfdataWriter "<%= @object_perfdatawritername %>" {
<%#- If any of the @ parameters are undefined, don't print anything for them: -%>
<%- if @host_perfdata_path -%>
host_perfdata_path = "<%= @host_perfdata_path %>"
<%- end -%>
<%- if @service_perfdata_path -%>
service_perfdata_path = "<%= @service_perfdata_path %>"
<%- end -%>
<%- if @host_temp_path -%>
host_temp_path = "<%= @host_temp_path %>"
<%- end -%>
<%- if @service_temp_path -%>
service_temp_path = "<%= @service_temp_path %>"
<%- end -%>
<%- if @host_format_template -%>
host_format_template = "<%= @host_format_template %>"
<%- end -%>
<%- if @service_format_template -%>
service_format_template = "<%= @service_format_template %>"
<%- end -%>
<%- if @rotation_interval -%>
rotation_interval = <%= @rotation_interval %>
<%- end -%>
}