Skip to content

Commit

Permalink
Merge pull request #350 from Icinga/bug/missing-params-graphite
Browse files Browse the repository at this point in the history
Add missing parameters to graphite module class
  • Loading branch information
lbetz committed Mar 5, 2023
2 parents 4704ac1 + fd3afad commit 6d23b05
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
38 changes: 37 additions & 1 deletion manifests/module/graphite.pp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
# @param url
# URL to your Graphite Web/API.
#
# @param insecure
# Do not verify the TLS certificate.
#
# @param user
# A user with access to your Graphite Web via HTTP basic authentication.
#
Expand All @@ -36,6 +39,18 @@
# @param graphite_writer_service_name_template
# The value of your icinga 2 GraphiteWriter's attribute `service_name_template` (if specified).
#
# @param customvar_obscured_check_command
# The Icinga custom variable with the `actual` check command obscured by e.g. check_by_ssh.
#
# @param default_time_range_unit
# Set unit for the time range.
#
# @param default_time_range
# Set the displayed time range.
#
# @param disable_no_graphs
# Do not display empty graphs.
#
# @note Here the official [Graphite module documentation](https://www.icinga.com/docs/graphite/latest/) can be found.
#
# @example
Expand All @@ -52,10 +67,18 @@
Enum['git', 'none', 'package'] $install_method = 'git',
String $package_name = 'icingaweb2-module-graphite',
Optional[String] $url = undef,
Optional[Boolean] $insecure = undef,
Optional[String] $user = undef,
Optional[Icingaweb2::Secret] $password = undef,
Optional[String] $graphite_writer_host_name_template = undef,
Optional[String] $graphite_writer_service_name_template = undef
Optional[String] $graphite_writer_service_name_template = undef,
Optional[String] $customvar_obscured_check_command = undef,
Optional[Enum[
'minutes', 'hours', 'days',
'weeks', 'months', 'years'
]] $default_time_range_unit = undef,
Optional[Integer[1]] $default_time_range = undef,
Optional[Boolean] $disable_no_graphs = undef,
) {
icingaweb2::assert_module()

Expand All @@ -66,11 +89,19 @@
'url' => $url,
'user' => $user,
'password' => icingaweb2::unwrap($password),
'insecure' => $insecure,
}

$icinga_settings = {
'graphite_writer_host_name_template' => $graphite_writer_host_name_template,
'graphite_writer_service_name_template' => $graphite_writer_service_name_template,
'customvar_obscured_check_command' => $customvar_obscured_check_command,
}

$ui_settings = {
'default_time_range' => $default_time_range,
'default_time_range_unit' => $default_time_range_unit,
'disable_no_graphs_found' => $disable_no_graphs,
}

$settings = {
Expand All @@ -84,6 +115,11 @@
'target' => "${module_conf_dir}/config.ini",
'settings' => delete_undef_values($icinga_settings),
},
'module-graphite-ui' => {
'section_name' => 'ui',
'target' => "${module_conf_dir}/config.ini",
'settings' => delete_undef_values($ui_settings),
},
}

icingaweb2::module { 'graphite':
Expand Down
17 changes: 15 additions & 2 deletions spec/classes/graphite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,15 @@
{
git_revision: 'v0.9.0',
url: 'http://localhost',
insecure: false,
user: 'foo',
password: 'bar',
graphite_writer_host_name_template: 'foobar',
graphite_writer_service_name_template: 'barfoo',
customvar_obscured_check_command: 'baz',
default_time_range: 10,
default_time_range_unit: 'hours',
disable_no_graphs: true,
}
end

Expand All @@ -52,15 +57,23 @@
is_expected.to contain_icingaweb2__inisection('module-graphite-graphite')
.with_section_name('graphite')
.with_target('/etc/icingaweb2/modules/graphite/config.ini')
.with_settings('url' => 'http://localhost', 'user' => 'foo', 'password' => 'bar')
.with_settings('url' => 'http://localhost', 'insecure' => false, 'user' => 'foo', 'password' => 'bar')
}

it {
is_expected.to contain_icingaweb2__inisection('module-graphite-ui')
.with_section_name('ui')
.with_target('/etc/icingaweb2/modules/graphite/config.ini')
.with_settings('default_time_range' => 10, 'default_time_range_unit' => 'hours', 'disable_no_graphs_found' => true)
}

it {
is_expected.to contain_icingaweb2__inisection('module-graphite-icinga')
.with_section_name('icinga')
.with_target('/etc/icingaweb2/modules/graphite/config.ini')
.with_settings('graphite_writer_host_name_template' => 'foobar',
'graphite_writer_service_name_template' => 'barfoo')
'graphite_writer_service_name_template' => 'barfoo',
'customvar_obscured_check_command' => 'baz')
}
end
end
Expand Down

0 comments on commit 6d23b05

Please sign in to comment.