Problem with defining occurrences in puppet module

Hi,

I have a small problem with the puppet module that I haven't investigated fully (mainly because I get a bit lost in custom types, etc. in puppet).

I am defining a check like:

::sensu::check {'zombies':
   command => 'PATH=$PATH:/usr/local/nagios/libexec check_procs -s Z -c 5 -w 1',
   subscribers => 'sensu-host',
   interval => '1500',
   standalone => false,
   custom => {
     occurrences => 2,
   },
   handlers => 'mailer
}

Which produces a json in /etc/sensu/conf.d/checks like:
{
   "checks": {
     "zombies": {
       "interval": 1500,
       "handlers": [
         "mailer"
       ],
       "subscribers": [
         "sensu-host"
       ],
       "occurrences": 2,
       "command": "PATH=$PATH:/usr/local/nagios/libexec check_procs -s Z -c 5 -w 1",
       "standalone": false
     }
   }
}

So far so good.
But when I run puppet in the master, it always always, detects a change such like:
Notice: /Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]/custom: custom changed '' to 'occurrences => 2'
Info: /Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]: Scheduling refresh of Service[sensu-client]
Info: /Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]: Scheduling refresh of Service[sensu-server]

Notice the "custom changed '' to 'occurrences => 2'", looks as if it's not detecting the existing occurrences entries. This causes the service to be restarted unnecessarily!

Any idea what's going on? Am I doing something wrong?

Thanks.

Occurrences is a real parameter on the sensu check define:

Adding it in the custom section is confusing the provider, because
"custom" excludes the non-standard args:
https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_check/json.rb#L51-L55

So that is why it says 'custom changed ', because there is no custom.
But it writes occurrences down, which is fine. But that is the cause
of the non-convergence.
Just use the occurrences parameter directly and avoid sticking any
stock parameters
(https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_check/json.rb#L51\)
in the custom section and you will be fine.

···

On Thu, Sep 18, 2014 at 2:51 AM, Jesús Roncero <golan@notreally.org> wrote:

Hi,

I have a small problem with the puppet module that I haven't investigated
fully (mainly because I get a bit lost in custom types, etc. in puppet).

I am defining a check like:

::sensu::check {'zombies':
  command => 'PATH=$PATH:/usr/local/nagios/libexec check_procs -s Z -c 5
-w 1',
  subscribers => 'sensu-host',
  interval => '1500',
  standalone => false,
  custom => {
    occurrences => 2,
  },
  handlers => 'mailer
}

Which produces a json in /etc/sensu/conf.d/checks like:
{
  "checks": {
    "zombies": {
      "interval": 1500,
      "handlers": [
        "mailer"
      ],
      "subscribers": [
        "sensu-host"
      ],
      "occurrences": 2,
      "command": "PATH=$PATH:/usr/local/nagios/libexec check_procs -s Z -c 5
-w 1",
      "standalone": false
    }
  }
}

So far so good.
But when I run puppet in the master, it always always, detects a change such
like:
Notice:
/Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]/custom:
custom changed '' to 'occurrences => 2'
Info:
/Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]:
Scheduling refresh of Service[sensu-client]
Info:
/Stage[main]/We7::Sensu::Checks::Host/Sensu::Check[zombies]/Sensu_check[zombies]:
Scheduling refresh of Service[sensu-server]

Notice the "custom changed '' to 'occurrences => 2'", looks as if it's not
detecting the existing occurrences entries. This causes the service to be
restarted unnecessarily!

Any idea what's going on? Am I doing something wrong?

Thanks.

Awesome, thanks.

for some reason I thought it was in the custom section.

Now it's working, many thanks for the prompt response! :slight_smile:

J.

···

On 18/09/14 15:32, Kyle Anderson wrote:

So that is why it says 'custom changed ', because there is no custom.
But it writes occurrences down, which is fine. But that is the cause
of the non-convergence.
Just use the occurrences parameter directly and avoid sticking any
stock parameters
(https://github.com/sensu/sensu-puppet/blob/master/lib/puppet/provider/sensu_check/json.rb#L51\)
in the custom section and you will be fine.