sensu
: Base Sensu classsensu::api
: = Class: sensu::api Manages the Sensu api == Parameters [hasrestart] Boolean. Value of hasrestart attribute for this service. Defaulsensu::client
: Manages the Sensu client servicesensu::enterprise
: Installs the Sensu packagessensu::enterprise::dashboard
: Installs the Sensu Enterprise Dashboardsensu::package
: Installs Sensu packagessensu::rabbitmq::config
: Sets the Sensu rabbitmq configsensu::redis::config
: Sets the Sensu redis configsensu::repo::apt
: Adds the Sensu repo to Aptsensu::repo::yum
: Adds the Sensu YUM repo supportsensu::server::service
: Manages the Sensu server servicesensu::transport
: Configures Sensu transport
sensu::check
: Creates Sensu checkssensu::config
: Defines Sensu check configurationssensu::contact
: Manages contact routingsensu::enterprise::dashboard::api
: Manages the Sensu Enterprise API configurationsensu::extension
: Defines Sensu extensionssensu::filter
: Manages Sensu filterssensu::handler
: sensu::handlersensu::mutator
: Manages sensu mutatorssensu::plugin
: Installs Sensu pluginssensu::plugins_dir
: Verifies if install_dir exists without duplicate declarationssensu::subscription
: Manages Sensu subscriptionssensu::write_json
: Writes arbitrary hash data to a config file.
sensu_api_config
: Manages Sensu API configsensu_check
: Manages Sensu checkssensu_check_config
: ""sensu_client_config
: Manages Sensu client configsensu_client_subscription
: Manages Sensu client subscriptionssensu_contact
: Manages Sensu contactssensu_enterprise_dashboard_api_config
: Manages Sensu Enterprise Dashboard API configsensu_enterprise_dashboard_config
: Manages Sensu Enterprise Dashboard configsensu_extension
: Manages Sensu extensionssensu_filter
: Manages Sensu filterssensu_handler
: Manages Sensu handlerssensu_mutator
: Manages Sensu mutatorssensu_rabbitmq_config
: Manages Sensu RabbitMQ configsensu_redis_config
: Manages Sensu Redis config
sensu_sorted_json
: This function takes unsorted hash and outputs JSON object making sure the keys are sorted. Optionally you can pass a boolean as the second pa
This is the main Sensu class
The following parameters are available in the sensu
class.
Data type: Pattern[/^absent$/, /^installed$/, /^latest$/, /^present$/, /^[\d\.\-el]+$/]
Version of sensu to install. Defaults to installed
to support
Windows MSI packaging and to avoid surprising upgrades.
Default value: 'installed'
Data type: Stdlib::Absolutepath
Absolute path to the sensu etc directory. Default: '/etc/sensu' on Linux, 'C:/opt/sensu' on windows
Default value: $::osfamily
Data type: String
Name of the sensu-plugin package. Refers to the sensu-plugin rubygem, not the community sensu-plugins community scripts.
Default value: 'sensu-plugin'
Data type: Optional[String]
String. Provider used to install the sensu-plugin package. Refers to the
sensu-plugin rubygem, not the sensu-plugins community scripts. On windows,
defaults to gem
, all other platforms defaults to undef
Default value: $::osfamily
Data type: Pattern[/^absent$/, /^installed$/, /^latest$/, /^present$/, /^\d[\d\.\-\w]+$/]
Version of the sensu-plugin gem to install. Refers to the sensu-plugin rubygem, not the sensu-plugins community scripts
Default value: 'installed'
Data type: Boolean
Whether or not to install the sensu repo
Default value: true
Data type: Boolean
Whether or not to install and configure Sensu Enterprise
Default value: false
Data type: Boolean
Whether or not to install sensu-enterprise-dashboard
Default value: false
Data type: Boolean
Whether or not to manage apt/yum repositories
Default value: true
Data type: Enum['main','unstable']
Which sensu repo to install
Default value: 'main'
Data type: Optional[String]
Location of the yum/apt repo. Overrides the default location
Default value: undef
Data type: String
The apt GPG key id
Default value: 'EE15CFF6AB6E4E290FDAB681A20F259AEB9C94BB'
Data type: String
URL of the apt GPG key
Default value: 'https://sensu.global.ssl.fastly.net/apt/pubkey.gpg'
Data type: Optional[String]
Release for the apt source. Only set this if you want to run packages from another release, which is not supported by Sensu. Only works with systems that use apt.
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Tune concurrency of the sensu-server pipe handler and the
sensu-client check execution. This setting should not need to be tuned
except in specific situations, e.g. when there are a large number of JIT
clients. See #727 for
more information. The default is undefined, which does not manage
/etc/sensu/conf.d/spawn.json
Default value: undef
Data type: Boolean
Include the sensu client
Default value: true
Data type: Boolean
Include the sensu server
Default value: false
Data type: Boolean
Include the sensu api service
Default value: false
Data type: Boolean
Manage the sensu services with puppet
Default value: true
Data type: Boolean
Set enable value for sensu client service (applies when manage_services is set to true)
Default value: true
Data type: String
Set ensure value for sensu client service (applies when manage_services is set to true)
Default value: running
Data type: Boolean
Set enable value for sensu server service (applies when manage_services is set to true)
Default value: true
Data type: String
Set ensure value for sensu server service (applies when manage_services is set to true)
Default value: running
Data type: Boolean
Manage the sensu user with puppet
Default value: true
Data type: Boolean
Manage the sensu plugins directory. Must be false if you use sensu::plugin with type 'directory'.
Default value: true
Data type: Boolean
Manage the sensu handlers directory
Default value: true
Data type: Boolean
Manage the sensu mutators directory
Default value: true
Data type: Optional[String]
Name of the user Sensu is running as. Default is calculated according to the underlying OS
Default value: undef
Data type: Optional[String]
Name of the group Sensu is running as. Default is calculated according to the underlying OS
Default value: undef
Data type: Optional[Stdlib::Filemode]
Directory mode for Sensu conf directory. Default is calculated according to the underlying OS
Default value: $::osfamily
Data type: Optional[Stdlib::Filemode]
File mode for config files under Sensu conf directory . Default is calculated according to the underlying OS
Default value: $::osfamily
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Rabbitmq port to be used by sensu
Default value: undef
Data type: Optional[String]
Host running rabbitmq for sensu
Default value: undef
Data type: Optional[String]
Username to connect to rabbitmq with for sensu
Default value: undef
Data type: Optional[String]
Password to connect to rabbitmq with for sensu
Default value: undef
Data type: Optional[String]
Rabbitmq vhost to be used by sensu
Default value: undef
Data type: Optional[Boolean]
Use SSL transport to connect to RabbitMQ. If rabbitmq_ssl_private_key and/or rabbitmq_ssl_cert_chain are set, then this is enabled automatically. Set rabbitmq_ssl => true without specifying a private key or cert chain to use SSL transport, but not cert auth.
Default value: undef
Data type: Optional[String]
Private key to be used by sensu to connect to rabbitmq. If the value starts with 'puppet://' the file will be copied and used. Also the key itself can be given as the parameter value, or a variable, or using hiera. Absolute paths will just be used as a file reference, as you'd normally configure sensu.
Default value: undef
Data type: Optional[String]
Private SSL cert chain to be used by sensu to connect to rabbitmq If the value starts with 'puppet://' the file will be copied and used. Also the key itself can be given as the parameter value, or a variable, or using hiera. Absolute paths will just be used as a file reference, as you'd normally configure sensu.
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
The integer value for the RabbitMQ prefetch attribute
Default value: undef
Data type: Variant[Undef,Hash,Array]
Array of hashes. Rabbitmq Cluster configuration and connection information for one or more Cluster
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
The integer value for the RabbitMQ heartbeat attribute
Default value: undef
Data type: Optional[String]
Hostname of redis to be used by sensu
Default value: '127.0.0.1'
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Redis port to be used by sensu
Default value: 6379
Data type: Optional[String]
Password to be used to connect to Redis
Default value: undef
Data type: Boolean
Reconnect to Redis in the event of a Redis error, e.g. READONLY (not to be confused with a connection failure).
Default value: true
Data type: Integer
The Redis instance DB to use/select
Default value: 0
Data type: Optional[Array]
Redis Sentinel configuration and connection information for one or more Sentinels
Default value: undef
Data type: Optional[String]
Redis master name in the sentinel configuration In the end whatever sensu defaults to, which is "mymaster" currently.
Default value: undef
Data type: Boolean
Reconnect to Redis in the event of a connection failure
Default value: true
Data type: Enum['rabbitmq','redis']
Transport type to be used by Sensu
Default value: 'rabbitmq'
Data type: Boolean
If the transport connection is closed, attempt to reconnect automatically when possible.
Default value: true
Data type: String
IP to bind api service
Default value: '0.0.0.0'
Data type: String
Hostname of the sensu api service
Default value: '127.0.0.1'
Data type: Integer
Port of the sensu api service
Default value: 4567
Data type: Optional[String]
Password of the sensu api service
Default value: undef
Data type: Optional[String]
Password of the sensu api service
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Port of the HTTPS (SSL) sensu api service. Enterprise only feature.
Default value: undef
Data type: Optional[String]
The file path for the SSL certificate keystore. Enterprise only feature.
Default value: undef
Data type: Optional[String]
The SSL certificate keystore password. Enterprise only feature.
Default value: undef
Data type: Variant[String,Array]
Default subscriptions used by the client
Default value: []
Data type: Boolean
Boolean that determines if client socket will be enabled
Default value: true
Data type: String
Address of the client to report with checks
Default value: $::ipaddress
Data type: String
Name of the client to report with checks
Default value: $::fqdn
Data type: Hash
Custom client variables.
Default value: {}
Data type: Variant[Undef,Boolean]
Enable the deregistration event if true.
Default value: undef
Data type: Variant[Undef,Hash]
(https://sensuapp.org/docs/latest/reference/clients#deregistration-attributes) used to generate check result data for the de-registration event. Client deregistration attributes are merged with some default check definition attributes by the Sensu server during client deregistration, so any valid check definition attributes – including custom check definition attributes – may be used as deregistration attributes, with the following exceptions (which are used to ensure the check result is valid): check name, output, status, and issued timestamp. The following attributes are provided as recommendations for controlling client deregistration behavior.
Default value: undef
Data type: Variant[Undef,Hash]
(https://sensuapp.org/docs/latest/reference/clients#registration-attributes) used to generate check result data for the registration event. Client registration attributes are merged with some default check definition attributes by the Sensu server during client registration.
Default value: undef
Data type: Hash
Client keepalive configuration
Default value: {}
Data type: Hash
Client http_socket configuration. Must be an Hash of parameters as described in: https://sensuapp.org/docs/latest/reference/clients.html#http-socket-attributes
Default value: {}
Data type: Hash
Client servicenow configuration. Supported only on Sensu Enterprise. It expects an Hash with a single key named 'configuration_item' containing an Hash of parameters, as described in: https://sensuapp.org/docs/latest/reference/clients.html#servicenow-attributes
Default value: {}
Data type: Hash
Client ec2 configuration. Supported only on Sensu Enterprise. It expects an Hash with valid paramters as described in: https://sensuapp.org/docs/latest/reference/clients.html#ec2-attributes
Default value: {}
Data type: Hash
Client chef configuration. Supported only on Sensu Enterprise. It expects an Hash with valid paramters as described in: https://sensuapp.org/docs/latest/reference/clients.html#chef-attributes
Default value: {}
Data type: Hash
Client puppet configuration. Supported only on Sensu Enterprise. It expects an Hash with valid paramters as described in: https://sensuapp.org/docs/latest/reference/clients.html#puppet-attributes
Default value: {}
Data type: Boolean
Force safe mode for checks
Default value: false
Data type: Variant[String,Array,Hash]
Plugins to install on the node Strings and Arrays of strings will set 'install_path' => '/etc/sensu/plugins' as default. Example string: 'puppet:///data/sensu/plugins/plugin1.rb' Example array: [ 'puppet:///data/sensu/plugins/plugin1.rb', 'puppet:///data/sensu/plugins/plugin2.rb' ] Example hash: { 'puppet:///data/sensu/plugins/plugin1.rb' => { 'pkg_version' => '2.4.2' }, 'puppet:///data/sensu/plugins/plugin1.rb' => { 'pkg_provider' => 'sensu-gem' }
Default value: []
Data type: Hash
Defaults for Plugins to install on the node. Will be added when plugins is set to a hash. Example value: { 'install_path' => '/other/path' }
Default value: {}
Data type: Optional[String]
Puppet url to plugins directory
Default value: undef
Data type: Variant[Boolean,Hash]
If unused plugins, configs, handlers, extensions and mutators should be removed from the system. If set to true, all unused plugins, configs, handlers, extensions and mutators will be removed from the system. If set to a Hash, only unused files of the specified type(s) will be removed from the system. Valid values: true, false, Hash containing any of the keys 'plugins', 'config', 'handlers', 'extensions', 'mutators' Example value: { config => true, plugins => true }
Default value: false
Data type: Boolean
If the embedded ruby should be used, e.g. to install the sensu-plugin gem. This value is overridden by a defined sensu_plugin_provider. Note, the embedded ruby should always be used to provide full compatibility. Using other ruby runtimes, e.g. the system ruby, is not recommended.
Default value: true
Data type: Optional[String]
Ruby opts to be passed to the sensu services
Default value: undef
Data type: Optional[String]
Paths to add to GEM_PATH if we need to look for different dirs.
Default value: undef
Data type: Enum['debug','info','warn','error','fatal']
Sensu log level to be used
Default value: 'info'
Data type: Stdlib::Absolutepath
Sensu log directory to be used
Default value: '/var/log/sensu'
Data type: Variant[Integer,Pattern[/^(\d+)$/]]
Number of seconds to wait for the init stop script to run
Default value: 10
Data type: Optional[Any]
Optional configuration to use for the installation of the sensu plugin gem with sensu_gem provider. See: https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options Example value: [{ '-p' => 'http://user:[email protected]:8080' }]
Default value: undef
Data type: Boolean
Value of hasrestart attribute for sensu services. If you use your own startup scripts for upstart and want puppet to properly stop and start sensu services when those scripts change, set it to false. See also http://upstart.ubuntu.com/faq.html#reload
Default value: true
Data type: Optional[Any]
Optional auth configuration for Enterprise Dashboard
Default value: undef
Data type: Optional[Any]
Optional OIDC configuration for Enterprise Dashboard
Default value: undef
Data type: Variant[Stdlib::Absolutepath,Pattern[/^\$PATH$/]]
Used to set PATH in /etc/default/sensu
Default value: '$PATH'
Data type: Optional[Array]
Use to redact passwords from checks on the client side
Default value: undef
Data type: Boolean
Whether the sensu client should deregister from the API on service stop
Default value: false
Data type: Optional[String]
The handler to use when deregistering a client on stop.
Default value: undef
Data type: Hash
Hash of handlers for use with create_resources(sensu::handler). Example value: { 'email' => { 'type' => 'pipe', 'command' => 'mail' } }
Default value: {}
Data type: Hash
Handler defaults when not provided explicitly in $handlers. Example value: { 'filters' => ['production'] }
Default value: {}
Data type: Hash
Hash of checks for use with create_resources(sensu::check). Example value: { 'check-cpu' => { 'command' => 'check-cpu.rb' } }
Default value: {}
Data type: Hash
Check defaults when not provided explicitly in $checks. Example value: { 'occurrences' => 3 }
Default value: {}
Data type: Hash
Hash of filters for use with create_resources(sensu::filter). Example value: { 'occurrence' => { 'attributes' => { 'occurrences' => '1' } } }
Default value: {}
Data type: Hash
Filter defaults when not provided explicitly in $filters. Example value: { 'negate' => true }
Default value: {}
Data type: Optional[String]
Used to set package_checksum for windows installs
Default value: undef
Data type: Boolean
Whether or not to use logrotate on Windows OS family.
Default value: false
Data type: Variant[Integer,Pattern[/^(\d+)$/]]
The integer value for the size of log files on Windows OS family. sizeThreshold in sensu-client.xml.
Default value: 10240
Data type: Variant[Integer,Pattern[/^(\d+)$/]]
The integer value for the number of log files to keep on Windows OS family. keepFiles in sensu-client.xml.
Default value: 10
Data type: Optional[String]
If specified, override the behavior of computing the
package source URL from windows_repo_prefix and os major release fact.
This parameter is intended to allow the end user to override the source URL
used to install the Windows package. For example:
"https://repositories.sensuapp.org/msi/2012r2/sensu-0.29.0-11-x64.msi"
Default value: undef
Data type: Optional[String]
When something other than undef
, use the
specified package provider to install Windows packages. The default
behavior of undef
defers to the default package provider in Puppet which
is expected to be the msi provider.
Valid values are undef
or 'chocolatey'
.
Default value: undef
Data type: Optional[String]
The URL of the Chocolatey repository, used with the chocolatey windows package provider.
Default value: undef
Data type: String
The package name used to identify the package
filename. Defaults to 'sensu'
which matches the MSI filename published at
https://repositories.sensuapp.org/msi
. Note, this is distinct from the
windows_package_title, which is used to identify the package name as
displayed in Add/Remove programs in Windows.
Default value: 'Sensu'
Data type: String
The package name used to identify the package as listed in Add/Remove programs. Note this is distinct from the package filename identifier specified with windows_package_name.
Default value: 'sensu'
Data type: Optional[Variant[Stdlib::Absolutepath,Array[Stdlib::Absolutepath]]]
Additional directories to load configuration snippets from.
Default value: undef
Data type: Variant[Integer,Pattern[/^(\d+)/],Undef]
Value of the HEAP_SIZE environment variable. Note: This has effect only on Sensu Enterprise.
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Value of the MAX_OPEN_FILES environment variable.
Default value: undef
Data type: Variant[Stdlib::Absolutepath,Undef]
Value of the CONFIG_FILE environment variable.
Default value: undef
Data type: Variant[Undef,String]
Value of the HEAP_DUMP_PATH environment variable.
Default value: undef
Data type: Variant[Undef,String]
Value of the JAVA_OPTS environment variable.
Default value: undef
Data type: Pattern[/^absent$/,/^installed$/,/^latest$/,/^present$/,/^[\d\.\-]+$/]
Default value: 'latest'
Data type: Optional[String]
Default value: undef
Data type: Optional[String]
Default value: undef
Data type: String
Default value: 'latest'
Data type: String
Default value: '910442FF8781AFD0995D14B311AB27E8C3FE3269'
Data type: String
Default value: '127.0.0.1'
Data type: Integer
Default value: 3030
Data type: Boolean
Default value: false
Data type: Boolean
Default value: false
Data type: Boolean
Default value: false
Data type: Optional[String]
Default value: undef
Data type: Optional[String]
Default value: undef
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[String]
Default value: undef
Data type: Optional[String]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[Any]
Default value: undef
Data type: Optional[String]
Default value: 'https://repositories.sensuapp.org/msi'
Data type: Hash
Default value: {}
Data type: Hash
Default value: {}
= Class: sensu::api
Manages the Sensu api
== Parameters
[hasrestart] Boolean. Value of hasrestart attribute for this service. Default: true
The following parameters are available in the sensu::api
class.
Data type: Boolean
Default value: $::sensu::hasrestart
Manages the Sensu client service
The following parameters are available in the sensu::client
class.
Data type: Boolean
Value of hasrestart attribute for this service.
Default value: $::sensu::hasrestart
Data type: Any
Sensu log level to be used Valid values: debug, info, warn, error, fatal
Default value: $::sensu::log_level
Data type: Any
Whether or not to use logrotate on Windows OS family.
Default value: $::sensu::windows_logrotate
Data type: Any
The integer value for the size of log files on Windows OS family. sizeThreshold in sensu-client.xml.
Default value: $::sensu::windows_log_size
Data type: Any
The integer value for the number of log files to keep on Windows OS family. keepFiles in sensu-client.xml.
Default value: $::sensu::windows_log_number
Data type: Any
Default value: $::sensu::client_service_enable
Data type: Any
Default value: $::sensu::client_service_ensure
Installs Sensu enterprise
The following parameters are available in the sensu::enterprise
class.
Data type: Optional[String]
The handler to use when deregistering a client on stop.
Default value: $::sensu::deregister_handler
Data type: Optional[Boolean]
Whether the sensu client should deregister from the API on service stop
Default value: $::sensu::deregister_on_stop
Data type: Optional[String]
Paths to add to GEM_PATH if we need to look for different dirs.
Default value: $::sensu::gem_path
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Number of seconds to wait for the init stop script to run
Default value: $::sensu::init_stop_max_wait
Data type: Optional[String]
Sensu log directory to be used Valid values: Any valid log directory path, accessible by the sensu user
Default value: $::sensu::log_dir
Data type: Optional[String]
Sensu log level to be used Valid values: debug, info, warn, error, fatal
Default value: $::sensu::log_level
Data type: Optional[String]
Used to set PATH in /etc/default/sensu
Default value: $::sensu::path
Data type: Optional[String]
Ruby opts to be passed to the sensu services
Default value: $::sensu::rubyopt
Data type: Optional[Boolean]
If the embedded ruby should be used, e.g. to install the sensu-plugin gem. This value is overridden by a defined sensu_plugin_provider. Note, the embedded ruby should always be used to provide full compatibility. Using other ruby runtimes, e.g. the system ruby, is not recommended.
Default value: $::sensu::use_embedded_ruby
Data type: Variant[Undef,Integer,Pattern[/^(\d+)/]]
Value of the HEAP_SIZE environment variable.
Default value: $::sensu::heap_size
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Value of the MAX_OPEN_FILES environment variable.
Default value: $::sensu::max_open_files
Data type: Variant[Undef,String]
Value of the HEAP_DUMP_PATH environment variable.
Default value: $::sensu::heap_dump_path
Data type: Variant[Undef,String]
Value of the JAVA_OPTS environment variable.
Default value: $::sensu::java_opts
Data type: Boolean
Default value: $::sensu::hasrestart
Installs the Sensu Enterprise Dashboard
The following parameters are available in the sensu::enterprise::dashboard
class.
Data type: Boolean
Default value: $::sensu::hasrestart
Installs the Sensu packages
The following parameters are available in the sensu::package
class.
Data type: Optional[String]
The default configuration directory.
Default value: $::sensu::conf_dir
Data type: Variant[String,Array,Undef]
Additional directories to load configuration snippets from.
Default value: $::sensu::confd_dir
Data type: Variant[Undef,Integer,Pattern[/^(\d+)/]]
Value of the HEAP_SIZE environment variable. Note: This has no effect on sensu-core.
Default value: $::sensu::heap_size
Data type: Variant[Stdlib::Absolutepath,Undef]
Value of the CONFIG_FILE environment variable.
Default value: $::sensu::config_file
Data type: Optional[String]
The handler to use when deregistering a client on stop.
Default value: $::sensu::deregister_handler
Data type: Optional[Boolean]
Whether the sensu client should deregister from the API on service stop
Default value: $::sensu::deregister_on_stop
Data type: Optional[String]
Paths to add to GEM_PATH if we need to look for different dirs.
Default value: $::sensu::gem_path
Data type: Variant[Undef,Integer,Pattern[/^(\d+)$/]]
Number of seconds to wait for the init stop script to run
Default value: $::sensu::init_stop_max_wait
Data type: Optional[String]
Sensu log directory to be used Valid values: Any valid log directory path, accessible by the sensu user
Default value: $::sensu::log_dir
Data type: Optional[String]
Sensu log level to be used Valid values: debug, info, warn, error, fatal
Default value: $::sensu::log_level
Data type: Optional[String]
Used to set PATH in /etc/default/sensu
Default value: $::sensu::path
Data type: Optional[String]
Ruby opts to be passed to the sensu services
Default value: $::sensu::rubyopt
Data type: Optional[Boolean]
If the embedded ruby should be used, e.g. to install the sensu-plugin gem. This value is overridden by a defined sensu_plugin_provider. Note, the embedded ruby should always be used to provide full compatibility. Using other ruby runtimes, e.g. the system ruby, is not recommended.
Default value: $::sensu::use_embedded_ruby
Sets the Sensu rabbitmq config
Sets the Sensu redis config
Adds the Sensu repo to Apt
Adds the Sensu YUM repo support
Manages the Sensu server service
The following parameters are available in the sensu::server::service
class.
Data type: Boolean
Value of hasrestart attribute for this service.
Default value: $::sensu::hasrestart
Data type: Any
Default value: $::sensu::server_service_enable
Data type: Any
Default value: $::sensu::server_service_ensure
Configure Sensu Transport
This define manages Sensu checks
Hooks Since Sensu 1.1.0. Manages hooks for a check. See the documentation for the format of the Hash value.
The following parameters are available in the sensu::check
defined type.
Data type: Optional[String]
The check command to run
Default value: undef
Data type: Enum['present','absent']
Whether the check should be present or not. Valid values: present, absent
Default value: 'present'
Data type: Optional[String]
Type of check. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,String,Array]
Array of Strings. Handlers to use for this check. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,String,Array]
Array of Strings. Contacts to use for the contact-routing Sensu Enterprise feature. This value corresponds with a sensu::contact resource having the same name.
Default value: undef
Data type: Variant[Boolean,Enum['absent']]
When true, scheduled by the client. When false, listen for published check request. Set this to 'absent' to remove it completely.
Default value: true
Data type: String
When the check should be executed, using the Cron
syntax. Supersedes the
interval
parameter. Example: "0 0 * * *"
.
Default value: 'absent'
Data type: Variant[Integer,Enum['absent']]
How frequently (in seconds) the check will be executed. Set this to 'absent' to remove it completely.
Default value: 60
Data type: Variant[Undef,Pattern[/^(\d+)$/],Integer,Enum['absent']]
The number of event occurrences before the handler should take action. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Integer]
The number of seconds sensu-plugin-aware handlers should wait before taking second action. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,String,Integer]
The check source, used to create a JIT Sensu client for an external resource (e.g. a network switch). Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,String,Array]
Array of Strings. Which subscriptions must execute this check. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Integer]
Flap detection - see Nagios Flap Detection. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Integer]
Flap detection - see Nagios Flap Detection. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Numeric]
Check timeout in seconds, after it fails. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Optional[String]
Aggregates, preventing event floods. Set 'aggregate:' and 'handle:false', this prevents the server from sending to a handler, and makes the aggregated results available under /aggregates in the REST API. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,String,Array]
Array of Strings. An array of aggregates to add to the check. This supercedes the above aggregate parameter. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Boolean]
When false, check will not be sent to handlers. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Boolean]
Unpublished checks. Prevents the check from being triggered on clients. This allows for the definition of commands that are not actually 'checks' per say, but actually arbitrary commands for remediation. Set this to 'absent' to remove it completely. Default: undef
Default value: undef
Data type: Variant[Undef,String,Array]
List of checks this check depends on. Note: The validity of the other checks is not enforced by puppet Set this to 'absent' to remove it completely.
Default value: undef
Data type: Hash
Mapping of arbitrary attributes from the top-level of the target configuration JSON map. This parameter is intended to configure plugins and extensions which look up values outside of the check configuration scope. Example: { "mailer" => { "mail_from" => "[email protected]", "mail_to" => "[email protected]" } }
Default value: {}
Data type: Optional[Hash]
List of custom attributes to include in the check. You can use it to pass any attribute that is not listed here explicitly. Example: { 'remediation' => { 'low_remediation' => { 'occurrences' => [1,2], 'severities' => [1], 'command' => "/bin/command", 'publish' => false, } } }
Default value: undef
Data type: Variant[Undef,Enum['absent'],Integer]
The time to live (TTL) in seconds until check results are considered stale. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Boolean]
When a check in a WARNING or CRITICAL state returns to an OK state, the event generated by the WARNING or CRITICAL state will be automatically resolved. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Hash]
Check subdue configuration. Set this to 'absent' to remove it completely.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Hash]
Manages Proxy Check Requests Since Sensu 0.28.0. Publishes a check request to every Sensu client which matches the defined client attributes. See the documentation for the format of the Hash value.
Default value: undef
Data type: Variant[Undef,Enum['absent'],Hash]
Manages
Default value: undef
This define manages Sensu check configurations.
The following parameters are available in the sensu::config
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not Valid values: present, absent
Default value: 'present'
Data type: Optional[Hash]
Check configuration for the client to use
Default value: undef
Data type: Optional[Hash]
Configuration to send with the event to handlers
Default value: undef
Manage Contact Routing configuration with Sensu Enterprise.
Note: If the sensu::purge_config
class parameter is true
, unmanaged
sensu::contact resources located in /etc/sensu/conf.d/contacts will be purged.
The following parameters are available in the sensu::contact
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: Optional[String]
Where to place the contact JSON configuration file. Defaults to
undef
which defers to the behavior of the underlying sensu_contact type.
Default value: undef
Data type: Hash
The configuration data for the contact. This is an arbitrary hash to
accommodate the various communication channels. For example, { "email": { "to": "[email protected]" } }
.
Default value: {}
Manages the Sensu Enterprise API configuration
The following parameters are available in the sensu::enterprise::dashboard::api
defined type.
The hostname or IP address of the Sensu API. This is used as the namevar for the underlying resource, so must be unique within the catalog.
Data type: Enum['present','absent']
Whether the dashboard API should be configured or not
Default value: present
Data type: Optional[String]
The base path to the client config file.
Default value: undef
Data type: Optional[String]
The datacenter name.
Default value: undef
Data type: Optional[Integer]
The port of the Sensu API.
Default value: undef
Data type: Optional[Boolean]
Whether or not to use the HTTPS protocol.
Default value: undef
Data type: Optional[Boolean]
Whether or not to accept an insecure SSL certificate.
Default value: undef
Data type: Optional[String]
The path of the Sensu API. Leave empty unless your Sensu API is not mounted to /.
Default value: undef
Data type: Optional[Integer]
The timeout for the Sensu API, in seconds.
Default value: undef
Data type: Optional[String]
The username of the Sensu API. Leave empty for no authentication.
Default value: undef
Data type: Optional[String]
The password of the Sensu API. Leave empty for no authentication.
Default value: undef
This define manages Sensu extensions
The following parameters are available in the sensu::extension
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: Optional[Pattern[/^puppet:\/\//]]
Source of the puppet extension
Default value: undef
Data type: String
Path where to install the extension
Default value: '/etc/sensu/extensions'
Data type: Hash
Extension specific config
Default value: {}
Defines Sensu filters
== Parameters
The following parameters are available in the sensu::filter
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: Optional[Boolean]
Negate the filter
Default value: undef
Data type: Optional[Hash]
Hash of attributes for the filter
Default value: undef
Data type: Optional[Hash]
Hash of when entries for the filter
Default value: undef
Defines Sensu handlers
The following parameters are available in the sensu::handler
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: Enum['pipe','tcp','udp','amqp','set','transport']
Type of handler
Default value: 'pipe'
Data type: Optional[String]
Command to run as the handler when type=pipe
Default value: undef
Data type: Optional[Array]
Handlers to use when type=set
Default value: undef
Data type: Array
Severities handler is valid for
Default value: ['ok', 'warning', 'critical', 'unknown']
Data type: Optional[Hash]
Exchange information used when type=amqp Keys: host, port
Default value: undef
Data type: Optional[Hash]
Pipe information used when type=transport Keys: name, type, options
Default value: undef
Data type: Optional[Hash]
Socket information when type=tcp or type=udp Keys: host, port
Default value: undef
Data type: Array
Filter commands to apply
Default value: []
Data type: Optional[Pattern[/^puppet:\/\//]]
Source of the puppet handler
Default value: undef
Data type: String
Path to install the handler
Default value: $::osfamily
Data type: Optional[Hash]
Handler specific config
Default value: undef
Data type: Optional[Integer]
Handler timeout configuration
Default value: undef
Data type: Boolean
If events in the flapping state should be handled.
Default value: false
Data type: Boolean
If events in the silenced state should be handled.
Default value: false
Data type: Any
The handle mutator. Valid values: Any kind of data which can be added to the handler mutator.
Default value: undef
Data type: Any
The handle subdue. Valid values: Any kind of data which can be added to the handler subdue.
Default value: undef
This define manages Sense mutators
The following parameters are available in the sensu::mutator
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: String
Command to run.
Data type: Optional[Numeric]
The mutator execution duration timeout in seconds (hard stop).
Default value: undef
Data type: Optional[String]
Source of the puppet mutator
Default value: undef
Data type: Stdlib::Absolutepath
Path to install the mutator
Default value: '/etc/sensu/mutators'
Installs the Sensu community script and plugins which can be used as monitoring checks
The following parameters are available in the sensu::plugin
defined type.
Data type: Enum['file','url','package','directory']
Plugin source Valid values: file, directory, package, url
Default value: 'file'
Data type: Stdlib::Absolutepath
The path to install the plugin
Default value: $::osfamily
Data type: Boolean
When using a directory source, purge setting
Default value: true
Data type: Boolean
When using a directory source, recurse setting
Default value: true
Data type: Boolean
When using a directory source, force setting
Default value: true
Data type: Pattern[/^absent$/,/^installed$/,/^latest$/,/^present$/,/^[\d\.\-]+$/]
When using package source, version to install
Default value: 'latest'
Data type: Optional[String]
When using package to install plugins, provider to use. Valid values: sensu_gem, apt, aptitude, yum
Default value: $::sensu::sensu_plugin_provider
Data type: Optional[String]
The packake's MD5 checksum. Valid values: Any valid MD5 string of the wanted package
Default value: undef
Data type: Boolean
When using url source, disable certificate checking for HTTPS
Default value: false
Data type: Any
Optional configuration to use for the installation of the sensu plugin gem with sensu_gem provider. See: https://docs.puppetlabs.com/references/latest/type.html#package-attribute-install_options Example value: [{ '-p' => 'http://user:[email protected]:8080' }]
Default value: $::sensu::gem_install_options
This define verifies if install_dir exists without duplicate declarations
The following parameters are available in the sensu::plugins_dir
defined type.
Data type: Boolean
Value of the parameter force of file resource for the managed directory.
Data type: Boolean
Value of the parameter purge of file resource for the managed directory.
Data type: Boolean
Value of the parameter recurse of file resource for the managed directory.
Data type: String
Path of the directory to create. If not defined the $title is used
Default value: $name
This define manages Sensu subscriptions
The following parameters are available in the sensu::subscription
defined type.
Data type: Enum['present','absent']
Whether the check should be present or not
Default value: 'present'
Data type: Hash
Custom client variables
Default value: {}
Writes arbitrary hash data to a config file. Note: you must manually notify any Sensu services to restart them when using this defined resource type.
[notify_list] Array. A listing of resources to notify upon changes to the target JSON file. Default: []
sensu::write_json { '/etc/sensu/conf.d/check.json':
content => {"config" => {"key" => "value"}},
notify => [
Service['sensu-client'],
Service['sensu-server'],
],
}
The following parameters are available in the sensu::write_json
defined type.
Data type: Enum['present', 'absent']
Whether the file should be present or not.
Default value: 'present'
Data type: String
The file owner.
Default value: 'sensu'
Data type: String
The file group.
Default value: 'sensu'
Data type: Stdlib::Filemode
The file mode.
Default value: '0775'
Data type: Boolean
Write the json with "pretty" indenting & formating.
Default value: true
Data type: Hash
The hash content that will be converted to json and written into the target config file.
Default value: {}
Data type: Array[Variant[Data,Type]]
Default value: []
Manages Sensu API config
The following properties are available in the sensu_api_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The port that the Sensu API is listening on
Default value: 4567
The hostname that the Sensu API is listening on
Default value: 127.0.0.1
The bind IP that sensu will bind to
Default value: 0.0.0.0
The username used for clients to authenticate against the Sensu API
The password use for client authentication against the Sensu API
Port of the HTTPS (SSL) sensu api service. Enterprise only feature.
The file path for the SSL certificate keystore. Enterprise only feature.
The SSL certificate keystore password. Enterprise only feature.
The following parameters are available in the sensu_api_config
type.
namevar
This value has no effect, set it to what ever you want.
The base path to the client config file
Default value: /etc/sensu/conf.d/
Manages Sensu checks
The following properties are available in the sensu_check
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Valid values: /.*/, absent
Command to be run by the check
Valid values: /.*/, absent
Dependencies of this check
Valid values: /.*/, absent
List of handlers that responds to this check
Valid values: /^[\w.-]+$/, absent
Contact names to override handler configuration via Contact Routing
Valid values: /.*/, absent
A host is determined to be flapping when the percent change exceedes this threshold.
Valid values: /.*/, absent
When the check should be executed, using the Cron syntax.
Valid values: /.*/, absent
How frequently the check runs in seconds
Valid values: /.*/, absent
The number of event occurrences before the handler should take action.
Valid values: /.*/, absent
The number of seconds sensu-plugin-aware handlers should wait before taking second action.
Valid values: /.*/, absent
A host is determined to be flapping when the percent change is below this threshold.
Valid values: /.*/, absent
The check source, used to create a JIT Sensu client for an external resource (e.g. a network switch).
Valid values: /.*/, absent
Who is subscribed to this check
Custom check variables
Valid values: /.*/, absent
What type of check is this
Valid values: /.*/, absent
Whether this is a standalone check
Valid values: /.*/, absent
Check timeout in seconds, after it fails
Valid values: /.*/, absent
Whether check is aggregate
Valid values: /.*/, absent
An array of aggregates to add to the check
Valid values: /.*/, absent
Whether check event send to a handler
Valid values: /.*/, absent
Whether check is unpublished
Valid values: /.*/, absent
Check subdue
Valid values: /.*/, absent
Proxy Requests
Valid values: /.*/, absent
Check ttl in seconds
The following parameters are available in the sensu_check
type.
namevar
The name of the check.
The base path to the client config file
Default value: /etc/sensu/conf.d/checks
""
The following properties are available in the sensu_check_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The following parameters are available in the sensu_check_config
type.
namevar
The check name to configure
The base path to the client config file
Default value: /etc/sensu/conf.d/checks
Check configuration for the client to use
Configuration to send with the event to handlers
Manages Sensu client config
The following properties are available in the sensu_client_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
""
""
Valid values: /.*/, absent
""
Valid values: /.*/, absent
An array of strings that should be redacted in the sensu client config
A set of attributes that configure the Sensu client socket.
Require checks to be defined on server and client
Default value: false
Custom client attributes
Enable client de-registration
Valid values: /.*/, absent
Client deregistration attributes
Valid values: /.*/, absent
Client registration attributes
Keepalive config
A set of attributes that configure the Sensu client http socket.
Configure Service Now integration on Sensu client.
Configure ec2 integration on Sensu client.
Configure Chef integration on Sensu client.
Configure Puppet integration on Sensu client.
The following parameters are available in the sensu_client_config
type.
namevar
The name of the host
The base path to the client config file
Default value: /etc/sensu/conf.d/
Manages Sensu client subscriptions
The following properties are available in the sensu_client_subscription
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Subscriptions included, defaults to resource name
Custom client variables
The following parameters are available in the sensu_client_subscription
type.
namevar
The subscription name
The base path to the client config file
Default value: /etc/sensu/conf.d/
The name of the client config file
Manages Sensu contacts
The following properties are available in the sensu_contact
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Configuration hash for the contact.
The following parameters are available in the sensu_contact
type.
Valid values: /^[\w.-]+$/
namevar
The name of the contact, e.g. "support"
The base path to the contact config file
Default value: /etc/sensu/conf.d/contacts/
Manages Sensu Enterprise Dashboard API config
The following properties are available in the sensu_enterprise_dashboard_api_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The name of the Sensu API (used elsewhere as the datacenter name).
Valid values: /[0-9]+/
The port of the Sensu API.
Default value: 4567
Determines whether or not to use the HTTPS protocol.
Default value: false
Determines whether or not to accept an insecure SSL certificate.
Default value: false
The path of the Sensu API. Leave empty unless your Sensu API is not mounted to /.
Valid values: /[0-9]+/
The timeout for the Sensu API, in seconds.
Default value: 5
Valid values: /.+/
The username of the Sensu API. Leave empty for no authentication.
Valid values: /.+/
The password of the Sensu API. Leave empty for no authentication.
The following parameters are available in the sensu_enterprise_dashboard_api_config
type.
namevar
The hostname or IP address of the Sensu API.
The base path to the client config file
Default value: /etc/sensu/
Manages Sensu Enterprise Dashboard config
The following properties are available in the sensu_enterprise_dashboard_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The hostname or IP address on which Sensu Enterprise Dashboard will listen on.
Default value: 0.0.0.0
The port on which Sensu Enterprise Dashboard will listen on.
Default value: 3000
Determines the interval to poll the Sensu APIs, in seconds.
Default value: 5
A username to enable simple authentication and restrict access to the dashboard. Leave blank along with pass to disable simple authentication.
A password to enable simple authentication and restrict access to the dashboard. Leave blank along with user to disable simple authentication.
The auth definition scope, used to configure JSON Web Token (JWT) authentication signatures.
A hash of SSL attributes to enable native SSL
A hash of audit attributes to enable audit logging
A hash of GitHub authentication attributes to enable GitHub authentication via OAuth. Overrides simple authentication.
A hash of GitLab authentication attributes to enable GitLab authentication via OAuth. Overrides simple authentication.
A hash of Lightweight Directory Access Protocol (LDAP) authentication attributes to enable LDAP authentication. Overrides simple authentication.
The oidc definition scope, used to configure Role Based Access Controls with the RBAC for OpenID Connect (OIDC) driver. Overrides simple authentication.
The following parameters are available in the sensu_enterprise_dashboard_config
type.
namevar
This value has no effect, set it to what ever you want.
The base path to the client config file
Default value: /etc/sensu/
Manages Sensu extensions
The following properties are available in the sensu_extension
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The configuration for this extension
The following parameters are available in the sensu_extension
type.
namevar
This value has no effect, set it to what ever you want.
The base path to the client config file
Default value: /etc/sensu/conf.d/extensions/
Manages Sensu filters
The following properties are available in the sensu_filter
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Filter attributes
Used to determine when a filter is applied.
""
Default value: false
The following parameters are available in the sensu_filter
type.
namevar
The name of the filter.
The base path to the client config file
Default value: /etc/sensu/conf.d/filters/
Manages Sensu handlers
The following properties are available in the sensu_handler
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Type of handler
Command the handler should run
Exchange information used by the amqp type
Pipe information used by the transport type
Socket information used by the udp type
Handler specific data massager
Handler filters
Severities applicable to this handler
Handlers this handler mutexes into
Handler specific config
Handler timeout
If events in the flapping state should be handled
If events in the silenced state should be handled
The following parameters are available in the sensu_handler
type.
namevar
The name of the handler
The base path to the client config file
Default value: /etc/sensu/conf.d/handlers/
Manages Sensu mutators
The following properties are available in the sensu_mutator
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Command the mutator should run
The mutator execution duration timeout in seconds (hard stop).
The following parameters are available in the sensu_mutator
type.
namevar
The name of the mutator
The base path to the client config file
Default value: /etc/sensu/conf.d/mutators/
Manages Sensu RabbitMQ config
The following properties are available in the sensu_rabbitmq_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
Enable SSL transport to connect to RabbitMQ
Default value: false
The path on disk to the SSL private key needed to connect to RabbitMQ
Default value: ''
The path on disk to the SSL cert chain needed to connect to RabbitMQ
Default value: ''
The port that RabbitMQ is listening on
The hostname that RabbitMQ is listening on
The username to use when connecting to RabbitMQ
The password to use when connecting to RabbitMQ
The vhost to use when connecting to RabbitMQ
The RabbitMQ heartbeat value
The RabbitMQ AMQP consumer prefetch value
Rabbitmq Cluster
The following parameters are available in the sensu_rabbitmq_config
type.
namevar
This value has no effect, set it to what ever you want.
The base path to the client config file
Default value: /etc/sensu/conf.d/
Manages Sensu Redis config
The following properties are available in the sensu_redis_config
type.
Valid values: present, absent
The basic property that the resource should be in.
Default value: present
The port that Redis is listening on
The hostname that Redis is listening on
The password used to connect to Redis
Attempt to reconnect to RabbitMQ on error
Default value: true
The Redis instance DB to use/select
Default value: 0
Reconnect to Redis in the event of a connection failure
Default value: true
Redis Sentinel configuration for HA clustering
Default value: []
Redis master name in the sentinel configuration
Default value: absent
The following parameters are available in the sensu_redis_config
type.
namevar
This value has no effect, set it to what ever you want.
The base path to the client config file
Default value: /etc/sensu/conf.d/
Type: Ruby 3.x API
This function takes unsorted hash and outputs JSON object making sure the keys are sorted. Optionally you can pass a boolean as the second parameter, which controls if the output is pretty formatted.
Examples:
-------------------
-- UNSORTED HASH --
-------------------
unsorted_hash = {
'client_addr' => '127.0.0.1',
'bind_addr' => '192.168.34.56',
'start_join' => [
'192.168.34.60',
'192.168.34.61',
'192.168.34.62',
],
'ports' => {
'rpc' => 8567,
'https' => 8500,
'http' => -1,
},
}
-----------------
-- SORTED JSON --
-----------------
sorted_json(unsorted_hash)
{"bind_addr":"192.168.34.56","client_addr":"127.0.0.1",
"ports":{"http":-1,"https":8500,"rpc":8567},
"start_join":["192.168.34.60","192.168.34.61","192.168.34.62"]}
------------------------
-- PRETTY SORTED JSON --
------------------------
Params: data <hash>, pretty <true|false>.
sorted_json(unsorted_hash, true)
{
"bind_addr": "192.168.34.56",
"client_addr": "127.0.0.1",
"ports": {
"http": -1,
"https": 8500,
"rpc": 8567
},
"start_join": [
"192.168.34.60",
"192.168.34.61",
"192.168.34.62"
]
}
This function takes unsorted hash and outputs JSON object making sure the keys are sorted. Optionally you can pass a boolean as the second parameter, which controls if the output is pretty formatted.
Examples:
-------------------
-- UNSORTED HASH --
-------------------
unsorted_hash = {
'client_addr' => '127.0.0.1',
'bind_addr' => '192.168.34.56',
'start_join' => [
'192.168.34.60',
'192.168.34.61',
'192.168.34.62',
],
'ports' => {
'rpc' => 8567,
'https' => 8500,
'http' => -1,
},
}
-----------------
-- SORTED JSON --
-----------------
sorted_json(unsorted_hash)
{"bind_addr":"192.168.34.56","client_addr":"127.0.0.1",
"ports":{"http":-1,"https":8500,"rpc":8567},
"start_join":["192.168.34.60","192.168.34.61","192.168.34.62"]}
------------------------
-- PRETTY SORTED JSON --
------------------------
Params: data <hash>, pretty <true|false>.
sorted_json(unsorted_hash, true)
{
"bind_addr": "192.168.34.56",
"client_addr": "127.0.0.1",
"ports": {
"http": -1,
"https": 8500,
"rpc": 8567
},
"start_join": [
"192.168.34.60",
"192.168.34.61",
"192.168.34.62"
]
}
Returns: Any