Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms

RSS

sensu (52) Versions 2.12.0

Installs/Configures Sensu

Berkshelf/Librarian
Policyfile
Knife
cookbook 'sensu', '= 2.12.0'
cookbook 'sensu', '= 2.12.0', :supermarket
knife cookbook site install sensu
knife cookbook site download sensu
README
Dependencies
Changelog
Quality 0%

DESCRIPTION

Provides LWRP's and service recipes to install and configure Sensu, a monitoring framework.

This cookbook provides the building blocks for creating a monitoring cookbook specific to your environment (wrapper). Without such a wrapper, no Sensu configuration files will be created for your nodes.

An example wrapper cookbook can be found HERE.

How to Write Reusable Chef Cookbooks

CONTRIBUTING

See CODE_OF_CONDUCT.md, CONTRIBUTING.md and TESTING.md documents.

COOKBOOK DEPENDENCIES

NOTE: This cookbook either constrains its dependencies optimistically (>=) or not at all. You're strongly encouraged to more strictly manage these dependencies in your wrapper cookbook.

PACKAGES

This cookbook makes no attempt to manage the versions of its package dependencies. If you desire or require management of these versions, you should handle these via your wrapper cookbook.

REQUIREMENTS

SSL configuration

Running Sensu with SSL is recommended; by default this cookbook attempts to load SSL credentials from a data bag sensu, with an item ssl, containing the required SSL certificates and keys. These data bag items may be encrypted via native Chef encrypted data bags or via Chef Vault.

The data loaded from the data bag by default is expected to be formatted as follows:

{
  "server": {
    "cert": "CERTIFICATE_DATA",
    "key": "PRIVATE_KEY_DATA",
    "cacert": "CA_CERTIFICATE_DATA"
  },
  "client": {
    "cert": "CERTIFICATE_DATA",
    "key": "PRIVATE_KEY_DATA"
  }
}

All of the above values are expected to be strings comprised of PEM-formatted credentials with escaped line endings. See test/integration/data_bags/sensu/ssl.json for a more literal example.

If the attempt to load SSL credentials from a data bag fails, the cookbook will log a warning but proceed with the rest of the Chef run anyway, on the assumption that credentials will be inserted into the Chef "run state" (i.e. node.run_state['sensu']['ssl']) in the same format using the Sensu::ChefRunState helper methods, set_sensu_run_state and get_sensu_run_state.

Please see the documentation for the run state helper methods for more information.

This cookbook comes with a tool to generate the certificates and data bag items. If the integrity of the certificates is ever compromised, you must regenerate and redeploy them.

cd examples/ssl
./ssl_certs.sh generate
knife data bag create sensu

Use the plain-text data bag item:

knife data bag from file sensu ssl.json

Or, encrypt it with your data bag secret. See Encrypt a Data Bag for more information.

knife data bag --secret-file /path/to/your/secret from file sensu ssl.json
./ssl_certs.sh clean

RECIPES

sensu::default

Installs Sensu and creates a base configuration file, intended to be extended. This recipe must be included before any of the Sensu LWRP's can be used. This recipe does not enable or start any services.

sensu::rabbitmq

Installs and configures RabbitMQ for Sensu, from configuring SSL to creating a vhost and credentials. This recipe relies heavily on the community RabbitMQ cookbook LWRP's.

sensu::redis

Installs and configures Redis for Sensu. This recipe uses the RedisIO cookbook and installs Redis from source.

sensu::enterprise

Installs and configures Sensu Enterprise.

sensu::server_service

Enables and starts the Sensu server.

sensu::client_service

Enables and starts the Sensu client.

sensu::api_service

Enables and starts the Sensu API.

sensu::enterprise_service

Enables and starts Sensu Enterprise.

ATTRIBUTES

Installation

node["sensu"]["version"] - Sensu build to install.

node["sensu"]["use_unstable_repo"] - If the build resides on the "unstable" repository.

node["sensu"]["directory"] - Sensu configuration directory.

node["sensu"]["log_directory"] - Sensu log directory.

node["sensu"]["log_level"] - Sensu log level (eg. "warn").

node["sensu"]["use_ssl"] - If Sensu and RabbitMQ are to use SSL.

node["sensu"]["user"] - The user who owns all sensu files and directories. Default "sensu".

node["sensu"]["group"] - The group that owns all sensu files and directories. Default "sensu".

node["sensu"]["use_embedded_ruby"] - If Sensu Ruby handlers and plugins use the embedded Ruby in the Sensu package (default: false).

node["sensu"]["init_style"] - Style of init to be used when configuring Sensu services, "sysv" and "runit" are currently supported.

node["sensu"]["service_max_wait"] - How long service scripts should wait for Sensu to start/stop.

RabbitMQ

node["sensu"]["rabbitmq"]["host"] - RabbitMQ host.

node["sensu"]["rabbitmq"]["port"] - RabbitMQ port, usually for SSL.

node["sensu"]["rabbitmq"]["ssl"] - RabbitMQ SSL configuration, DO NOT EDIT THIS.

node["sensu"]["rabbitmq"]["vhost"] - RabbitMQ vhost for Sensu.

node["sensu"]["rabbitmq"]["user"] - RabbitMQ user for Sensu.

node["sensu"]["rabbitmq"]["password"] - RabbitMQ password for Sensu.

Redis

node["sensu"]["redis"]["host"] - Redis host.

node["sensu"]["redis"]["port"] - Redis port.

Sensu API

node["sensu"]["api"]["host"] - Sensu API host, for other services to reach it.

node["sensu"]["api"]["bind"] - Sensu API bind address.

node["sensu"]["api"]["port"] - Sensu API port.

LWRP'S

Define a client

sensu_client node["name"] do
  address node["ipaddress"]
  subscriptions node["roles"] + ["all"]
  additional(:cluster => node["cluster"])
end

Define a handler

sensu_handler "pagerduty" do
  type "pipe"
  command "pagerduty.rb"
  severities ["ok", "critical"]
end

Define a check

sensu_check "redis_process" do
  command "check-procs.rb -p redis-server -C 1"
  handlers ["default"]
  subscribers ["redis"]
  interval 30
  additional(:notification => "Redis is not running", :occurrences => 5)
end

Define a filter

sensu_filter "environment" do
  attributes(:client => {:environment => "development"})
  negate true
end

Define a mutator

sensu_mutator "opentsdb" do
  command "opentsdb.rb"
end

Define a custom configuration snippet

sensu_snippet "irc" do
  content(:uri => "irc://sensu:password@irc.freenode.net:6667#channel")
end

Helper modules and methods

Run State Helpers

The Sensu::ChefRunState module provides helper methods which populate node.run_state['sensu'] with arbitrary key/value pairs. This provides a means for wrapper cookbooks to populate the node.run_state with data required by the cookbook, e.g. SSL credentials, without cookbook itself enforcing source for that data.

n.b. The node.run_state is not persisted locally nor on a Chef server. Data stored here exists only for the duration of the Chef run.

set_sensu_state

This method sets values inside the node.run_state['sensu'] Mash, and expects arguments in the following order:

  1. the Chef node object
  2. one or more keys, providing the path to walk
  3. the value to set at that path

Example:

set_sensu_state(node, 'food', 'nachos', true)

The above sets the value of node.run_state['sensu']['food']['nachos'] to true.

get_sensu_state

This method retrieves the value of a key inside the node.run_state['sensu'] Mash and expects arguments in the following order:

  1. the Chef node object
  2. one or more keys, providing the path to walk

Examples:

get_sensu_state(node, 'food', 'nachos') would return true

When no value is set for a requested path, this method returns nil:

get_sensu_state(node, 'this', 'path', 'is', 'invalid') returns nil

SUPPORT

Please visit sensuapp.org/support for details on community and commercial support resources, including the official IRC channel.

Sensu cookbook changelog

This file is used to track changes made in each version of the sensu cookbook.

2.12.0 - 2016-03-14

Project changes

The Sensu cookbook project has adopted a new contribution workflow and a new code of conduct policy. Please see the relevant documents in repo for details.

Behavior changes

  • Values for owner and group properties on sensu_json_file resources now default to lazy evaluation of node attributes sensu.admin_user and sensu.group respectively. (#426)

  • Data bags remain default source of SSL certificates, but are now optional:

    With the addition of Sensu state helpers in #410 recipes which access credentials via data bags (i.e. default, rabbitmq and enterprise recipes) have been updated to make these data bag items optional.

    Please see the readme and integration test suite for examples of using these helpers.

  • Testing notes have been added in TESTING.md to describe some of the platform/suite combinations which are disabled or otherwise require special configuration.

Features

Added ChefSpec test coverage for the following:

  • default and client_service recipes
  • sensu_gem LWRP
  • Sensu::Helpers library #select_attributes and #gem_binary methods

Added source attribute to sensu_gem resource Added upgrade action to sensu_gem resource Added helpers for storing key/value pairs which persist for duration of the Chef run

Fixes

Allow "standard" as a value of type attribute on sensu_check resources, as described in Sensu documentation.

2.11.0 - 2015-11-11

Features

Added ability to disable repo installation similar to the Uchiwa cookbook

Added enterprise dashboard recipe and attributes

Added sensitive to some file creation resources for security

Fixes

Set default log level of Enterprise to info

Updated repository URLs for Sensu

Fixed dependency and extension for chef-vault

Reverted previous change to enterprise service notifications back to immediate restart to resolve issue #373

Updated node attribute access from dot notation to quoted strings for better compatibility

Other

Bumped the default version of Sensu to 0.20.3-1

Bumped the default version of Enterprise to 1.5.2-1

The Berksfile is now ignored to allow ChefDK users to use their own Berksfile

Removed Enterprise data bag item

Added ChefSpec matcher for create_sensu_dashboard_config

2.10.0 - 2015-05-25

Fixes

Changed restart notifications with enterprise for client, api, and server configurations to delayed instead of immediate.

Other

Bumped the default version of Sensu to 0.18.1-1

Bumped the default version of Enterprise to 1.1.0-1

Added winrm-transport gem for Test Kitchen in the Gemfile

2.9.0 - 2015-04-02

Features

Bumped the default version of Sensu to 0.17.1-1.

Updated the Linux recipe to use the updated YUM repository structure: el/i386 and el/x86_64. The RHEL release directories have been linked, eg. el/5/i386.

2.8.0 - 2015-03-17

Features

Enable Sensu transport and Redis reconnect_on_error by default (true). This allows Sensu to recover from unexpected transport and Redis client errors. Connection loss always results in a reconnect, regardless of this setting.

2.7.0 - 2015-03-17

Features

Bumped the default version of Sensu to 0.17.0-1.

The 0.17.0-1 MSI (Windows) has SSL/TLS support.

Fixes

Sensu user and group attributes no longer Linux platform specific.

2.6.0 - 2015-02-18

Features

Data bag name and item attributes, enabling control over data bags.

2.5.0 - 2015-01-29

Fixes

Sensu directory mode attributes have been moved out of the Linux platform attributes, allowing Windows nodes to converge.

Sensu service specific RabbitMQ credentials are now only managed if they have been configured.

Features

The random_password helper has been updated to ensure a certain level of complexity, meeting Windows server 2012 user password requirements.

API stash LWRP and silencing definitions now support Sensu API stack expiration (in seconds).

A copy of the Sensu client certificate and key are now stored on the RabbitMQ node(s), intended to be used for RabbitMQ Federation. They can be found in /etc/rabbitmq/ssl/client/.

2.4.0 - 2015-01-23

Fixes

Ensure RabbitMQ verifies peer certificates.

Runit runsvdir is now managed idempotently.

Use esl-erlang on Ubuntu 12.04 and previous releases to address the poodle exploit.

Updated ServerSpec tests to work with v2.

Features

Chef-Vault support for encrypted data bags.

Sensu configuration directory mode attribute.

Sensu service config data bag item support.

RabbitMQ user ACL (permissions) support, allowing Sensu clients to use a separate RabbitMQ user with different permissions than Sensu servers etc.

2.3.0 - 2014-12-18

Fixes

Reordered RabbitMQ attribute overrides and recipe includes.

Fixed Windows sensu-client service install resource gate.

Features

Sensu Enterprise recipes, install and service.

Sanitize helper works with delayed eval values.

YUM allow downgrade for the Sensu package.

Sensu user & group attributes.

Other

Bumped the default version of Sensu to 0.16.0-1.

ChefSpec matchers.

2.2.0 - 2014-10-23

Features

Dropped content data type requirements for the Sensu configuration snippet LWRP, sensu_snippet, as it may be a string or array etc.

2.1.0 - 2014-10-03

Non-backwards compatible changes

The Sensu amqp handler type is now transport, and has the configuration definition attribute of pipe instead of exchange.

Fixes

Including the redisio::default recipe in the redis recipe, in order to support all current versions of the cookbook.

Other

Bumped the default version of Sensu to 0.14.0-1.

2.0.0 - 2014-07-25

Non-backwards compatible changes

Removed the Sensu Dashboard service recipe, dashboard_service, and associated cookbook attributes, as the dashboard is no longer part of Sensu core.

Fixes

Don't create the sensu user with a random password on Windows, if it already exists.

Features

Added Sensu extension directory to Windows service configuration.

Windows package options and DISM source cookbook attributes.

Added the sensu_asset and sensu_plugin LWRPs for fetching/installing Sensu plugins etc.

Other

Bumped the default version of Sensu to 0.13.0-1.

Cleaned up Linux package installation recipe.

1.0.0 - 2014-04-23

Fixes

Windows installation fixes/improvements.

Features

Random password generator helper.

Support for Amazon Linux.

Cookbook attribute for admin_user, defaulting to "root" for Linux, "Administrator" for Windows. This allows recipes to be used on both platforms.

0.8.0 - 2014-01-02

Features

Cookbook attributes for Sensu repository URLs.

Validate Sensu client and check names with LWRPs.

Support for Sensu client keepalive configuration.

Support for Sensu aggregate check configuration.

0.7.1 - 2013-12-19

Other

Bumped the default version of Sensu to 0.12.3-1.

0.7.0 - 2013-12-19

Fixes

Sensu LWRPs now properly set updated_by_last_action().

The Yum cookbook >= 3.0 is now supported, and gpgcheck is set to false when the resource attribute is available.

Features

Embedded Runit support for Sensu services. The init_style defaults to "sysv", but can be changed to "runit". The sensu_service LWRP is used in service recipes, eg. sensu::server_service.

Data bag item helper, supported plain-text and encrypted Sensu data bag items.

Sensu configuration through attributes is now merged with Sensu data bag items, supporting encrypted secrets.

Other

Bumped the default version of Sensu to 0.12.2-1.

Updated tests to use ServerSpec, using a wrapper cookbook called sensu-test.

0.6.2 - 2013-10-28

Other

Bumped the default version of Sensu to 0.12.0-1.

0.6.1 - 2013-10-26

Other

Bumped the default version of Sensu to 0.11.3-1.

Updated example Vagrantfile to use Ubuntu 13.04.

0.6.0 - 2013-10-02

Non-backwards compatible changes

Redis recipe, switched to redisio cookbook. The cookbook is available on the OpsCode community site & has better platform/release support.

Foodcritic Metric
            

2.12.0 failed this metric

FC015: Consider converting definition to a LWRP: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/rabbitmq_credentials.rb:1
FC015: Consider converting definition to a LWRP: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_check.rb:1
FC015: Consider converting definition to a LWRP: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_client.rb:1
FC023: Prefer conditional attributes: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_check.rb:7
FC023: Prefer conditional attributes: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_check.rb:16
FC023: Prefer conditional attributes: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_client.rb:2
FC023: Prefer conditional attributes: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/definitions/silence_client.rb:11
FC023: Prefer conditional attributes: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/recipes/_windows.rb:36
FC052: Metadata uses the unimplemented "suggests" keyword: /tmp/cook/d017ab591a8ca7a09215e67d/sensu/metadata.rb:25