[chef] Nagios Service for Hostgroup without any Nodes


Chronological Thread 
  • From: Graham Christensen < >
  • To:
  • Subject: [chef] Nagios Service for Hostgroup without any Nodes
  • Date: Thu, 19 Sep 2013 17:13:07 -0500

Hello,

I'm a bit hung up on a problem with the Nagios cookbook when using host groups without any nodes. Here's the situation:

 I have a `loadbalancer-snowflake` role. This is so I can monitor the loadbalancers without rebuilding them (which I will, but not for a few months.)

In the `production` environment, I have a few of these nodes. However, in the `staging` environment, I don't have any of them.

The effect of this is it creates the host group block:

define hostgroup {
  hostgroup_name loadbalancer-snowflake
  alias loadbalancer-snowflake
}

And the command block (this is on the server, since it is performed remotely):

define command {
  command_name    check_loadbalancer-snowflake-http
  command_line    $USER1$/check_http -I $HOSTADDRESS$ -e "HTTP/1.1 200" -w 3 -c 5
}

However when it adds the service block:

define service {
  service_description loadbalancer-snowflake-http
  hostgroup_name loadbalancer-snowflake
  check_command check_loadbalancer-snowflake-http
  use default-service
}


it complains about "Could not expand hostgroups and/or hosts specified in service". This is because the Hostgroup is empty.

Has anyone experienced before? Is there a good solution to it? I considered altering it to not output the service if no hosts exist for it, but then found this monstrosity: https://github.com/opscode-cookbooks/nagios/blob/master/templates/default/services.cfg.erb#L17

I'd be willing to submit a PR to alter this behavior, but it looks like this might require a semi-substantial change. Any feedback to that point?

This cookbook could use refactoring :)

Graham



Archive powered by MHonArc 2.6.16.

§