Icinga / chef-icinga2

Icinga 2 Chef Cookbook
https://supermarket.chef.io/cookbooks/icinga2
Apache License 2.0
41 stars 55 forks source link

Influxdbwriter prevents icinga2 from starting #334

Open dvzunderd opened 5 years ago

dvzunderd commented 5 years ago

Expected Behavior

Icinga2 should be able to start after configuration of influxdb with send_thresholds and/or send_metadata enabled

Current Behavior

Icinga2 cannot be started when send_thresholds and/or send_metadata are enabled with influxdb. When running:

icinga2 daemon -C

Will give the following result:

critical/config: Error: Error while evaluating expression: Can't convert 'true' to a floating point number.
Location: in /etc/icinga2/objects.d/influxdbwriter.conf: 31:3-31:33
/etc/icinga2/objects.d/influxdbwriter.conf(29):                         }
/etc/icinga2/objects.d/influxdbwriter.conf(30):                      }
/etc/icinga2/objects.d/influxdbwriter.conf(31):   enable_send_thresholds = "true"
                                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/objects.d/influxdbwriter.conf(32):   enable_send_metadata = "true"
/etc/icinga2/objects.d/influxdbwriter.conf(33):   flush_interval = 10s

Possible Solution

We solved this by modifying the object.influxdbwrite.conf.rb template the following lines:

<% if @enable_send_thresholds -%>
  enable_send_thresholds = <%= @enable_send_thresholds.inspect %>
  <% end -%>
  <% if @enable_send_metadata -%>
  enable_send_metadata = <%= @enable_send_metadata.inspect %>
  <% end -%>

into (removed .inspect):

<% if @enable_send_thresholds -%>
  enable_send_thresholds = <%= @enable_send_thresholds %>
  <% end -%>
  <% if @enable_send_metadata -%>
  enable_send_metadata = <%= @enable_send_metadata %>
  <% end -%>

output influxdb after change (emptied fields due to security):

/**
 * This file is managed by Chef.
 * Do NOT modify this file directly.
*/

/**
 * InfluxdbWriter Object.
*/

library "perfdata"

object InfluxdbWriter "influxdb" {
  host = ""
  port = 8086
  database = ""
  username = ""
  password = ""
  host_template = {
                      measurement = "$host.check_command$"
                      tags = {
                        hostname = "$host.name$"
                      }
                    }
  service_template = {
                        measurement = "$service.check_command$"
                        tags = {
                          hostname = "$host.name$"
                          service = "$service.name$"
                        }
                     }
  enable_send_thresholds = true
  enable_send_metadata = true
  flush_interval = 10s
  flush_threshold = 1024
}