Skip to content
Ken Robertson edited this page Sep 30, 2011 · 1 revision

Configuration Options

Global Configuration

The global configuration optiosn can be used anywhere within your configuration scripts. They include:

  • checks_include_directories (defaults to ["checks"])
    This specifies the directories to scan for check definitions that should be loaded.

  • ignore_filename_patterns (defaults to [/_spec.rb$/])
    This is used to check whether a file should be skipped over for loading when scanning the directories specified in checks_include_directories. This would primarily be intended for test files within the load paths.

  • timeout (defaults to 30)
    The number of seconds to timeout when running an individual check.

Check Configuration

Within the configuration file, you can use configure blocks to specify configuration parameters for individual tests. For instance:

configure :check_mysql do
  username "foo"
  password "bar"
  port     3306
end

Within the configure block, any keyword given will be used as a parameter name and assigned to the given value. You can still use variables and other Ruby code bits in here. The keyword is basically used if it makes its way to method\_missing.

Within the checks, parameters can be defined as such:

define :check_mysql do
  attribute :username
  attribute :password
  attribute :host, :default => '127.0.0.1'
  attribute :port, :default => 3306
  ...
end

Here it defines 4 attributes, 2 of which have a specified default value. Attributes without defaults will be set to nil.

Attributes can also have types enforced on them. This can be done using:

define :check_mysql do
  attribute :username, :kind_of => String
  attribute :password, :kind_of => String
  attribute :host,     :kind_of => String, :default => '127.0.0.1'
  attribute :port,     :kind_of => Fixnum, :default => 3306
  ...
end

There are additional validations that can be enforced against attributes, including:

  • :regex
    Match the value of the paramater against a regular expression.

  • :respond\_to
    Ensure that the value has a given method. Takes one method name or an array of method names.

  • :equal\_to
    Match the value of the paramater with ==. An array means it can be equal to any of the values.

Clone this wiki locally