sensu / sensu-chef

Sensu Chef cookbook.
https://supermarket.chef.io/cookbooks/sensu
Apache License 2.0
221 stars 279 forks source link

[Sensu Check] Option type must be equal to one of: status, metric! You passed "standard". #364

Closed chrisduong closed 8 years ago

chrisduong commented 9 years ago

I created a data bag _sensuchecks with item _checkcpu with type is "standard" as from the Sensu official doc

{
  "id": "check_cpu",
  "type": "standard",
  "command": "/opt/sensu/embedded/bin/ruby check_cpu.rb",
  "standalone": true,
  "interval": 10
}

And I've got complaint

Option type must be equal to one of: status, metric! You passed "standard".

Chef::Exceptions::ValidationFailed
       ----------------------------------
       Option type must be equal to one of: status, metric!  You passed "standard".

       Cookbook Trace:
       ---------------
         /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/_worker.rb:45:in `block (2 levels) in from_file'
         /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/_worker.rb:44:in `block in from_file'
         /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/_worker.rb:43:in `each'
         /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/_worker.rb:43:in `from_file'
         /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/master.rb:23:in `from_file'

       Relevant File Content:
       ----------------------
       /tmp/kitchen/cache/cookbooks/sentifi-sensu/recipes/_worker.rb:

        38:    search(:sensu_checks, "*:*")
        39:  else
        40:    Array.new
        41:  end
        42:  
        43:  check_definitions.each do |check|
        44:    sensu_check check["id"] do
        45>>     type check["type"]
        46:      command check["command"]
        47:      subscribers check["subscribers"]
        48:      interval check["interval"]
        50:      additional check["additional"]
        51:    end
        52:  end

Look into Chef LWRP SensuCheck

attribute :type, :kind_of => String, :equal_to => %w[status metric]

Should it be [standard metric] ?

cwjohnston commented 8 years ago

This does seem like a bug. Based on brief review of the sensu source I suspect that type status and type standard have the same effect on check result processing (i.e. they do nothing). We should probably allow %w[status standard metric] in order to allow the officially documented standard type to be used without breaking existing use of type status.

agoddard commented 8 years ago

+1 to either allow standard, or just omit the type unless using metric - (standard is the default in Sensu)