• Stars
    star
    225
  • Rank 177,187 (Top 4 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created over 12 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Sensu Chef cookbook.

sensu

Build Status Cookbook Version pullreminders

Description

This cookbook provides custom resources and service recipes to install and configure Sensu, a monitoring framework.

The custom resources provide 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.

Dependencies

Platforms

  • Ubuntu/Debian
  • RHEL and derivatives
  • Fedora
  • Windows
  • AIX

Chef

  • Chef 13.3+ please check the metadata.rb file for the latest released version for example

Cookbooks

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.

Package versioning

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.

Prerequisites

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.

sensu::enterprise_dashboard

Installs and configures Sensu Enterprise Dashboard.

sensu::enterprise_dashboard_service

Enables and starts Sensu Enterprise Dashboard.

Attributes

Installation

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

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

node["sensu"]["apt_repo_codename"] - Override LSB release codename detected by ohai for purposes of configuring the apt repository definition.

node["sensu"]["yum_repo_releasever"] - Override $releasever string used in yum repository definition.

node['sensu']['yum_flush_cache'] - Override chefs in memory cache of yum cache during a chef-client run. For more information see here.

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

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

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

node["sensu"]["log_rotate_file_size"] - Windows only attribute to tell winsw to rotate log file when size reaches this.

node["sensu"]["log_rotate_file_keep"] - Windows only attribute to tell winsw to keep x number of log files on disk.

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: true).

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

node["sensu"]["loaded_tempfile_dir"] - Where Sensu stores temporary files. Set a persistent directory if you use hardened system that cleans temporary directory regularly.

Windows

Sensu requires Microsoft's .Net Framework to run on Windows. The following attributes influence the installation of .Net via this cookbook:

node["sensu"]["windows"]["install_dotnet"] - Toggles installation of .Net Framework using ms_dotnet cookbook. (default: true)

node["sensu"]["windows"]["dotnet_major_version"] - Major version of .Net Framework to install. (default: 4)

Adjusting the value of dotnet_major_version attribute will influence which recipe from ms_dotnet cookbook will be included. See ms_dotnet cookbook for additional details on using this cookbook.

Transport

node["sensu"]["transport"]["name"] - Name of transport to use for Sensu communications. Default "rabbitmq"

RabbitMQ

node["sensu"]["rabbitmq"]["hosts"] - Array of RabbitMQ hosts as strings, which will be combined with other RabbitMQ attributes to generate the Sensu RabbitMQ transport configuration as an array of hashes. Falls back to node["sensu"]["rabbitmq"]["host"] when empty. Defaults to an empty array.

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.

Sensu Enterprise

node["sensu"]["enterprise"]["repo_protocol"] - Sensu Enterprise repo protocol (e.g. http, https)

node["sensu"]["enterprise"]["repo_host"] - Sensu Enterprise repo host

node["sensu"]["enterprise"]["version"] - Desired Sensu Enterprise package version

node["sensu"]["enterprise"]["use_unstable_repo"] - Toggle use of Sensu Enterprise unstable repository

node["sensu"]["enterprise"]["log_level"] - Configure Sensu Enterprise log level

node["sensu"]["enterprise"]["heap_size"] - Configure Sensu Enterprise heap size

node["sensu"]["enterprise"]["heap_dump_path"] - Configure path where Sensu Enterprise will store heap dumps. Directory path will be managed by Chef. Honored by Enterprise version 2.0.0 and newer.

node["sensu"]["enterprise"]["java_opts"] - Specify additional Java options when running Sensu Enterprise

node["sensu"]["enterprise"]["max_open_files"] - Specify maxiumum number of file handles. Honored by Enterprise version 1.7.2 and newer.

Custom Resources (LWRPs)

Define a client

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

The sensu_client provider also supports the following optional attributes:

  • deregister
  • deregistration
  • keepalive
  • keepalives
  • redact
  • registration
  • safe_mode
  • socket

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

The sensu_check provider supports the following attributes:

  • additional
  • aggregate
  • aggregates
  • command
  • cron
  • handle
  • handlers
  • high_flap_threshold
  • interval
  • low_flap_threshold
  • publish
  • source
  • subdue
  • standalone
  • subscribers
  • timeout
  • ttl
  • type

Define a filter

sensu_filter "environment" do
  attributes(:client => {:environment => "development"})
  days(
    :all => [{ :begin => "05:00 PM", :end => "09:00 AM" }}],
    :saturday => [{ :begin => "09:00 AM", :end => "05:00 PM" }],
    :sunday => [{ :begin => "09:00 AM", :end => "05:00 PM" }]
  )
  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:[email protected]:6667#channel")
end

Install plugins

# define a hash of plugins (gems) WITH VERSIONS PINNED
default['MY_CUSTOM_NAMESPACE']['sensu']['plugins'] = {
  ## pretty much all checks rely on this
  'sensu-plugin' => '2.1.0',
  ## check consul
  'sensu-plugins-consul' => '1.4.1',
  ## check cpu
  'sensu-plugins-cpu-checks' => '1.1.2',
  ## check disks
  'sensu-plugins-disk-checks' => '2.4.0',
  ## check disks
  'sensu-plugins-http' => '2.6.0',
  ## check elasticsearch
  'sensu-plugins-elasticsearch' => '1.5.1',
  ## check load
  'sensu-plugins-load-checks' => '3.0.0',
  ## check memory
  'sensu-plugins-memory-checks' => '3.0.2',
  ## check network
  'sensu-plugins-network-checks' => '2.0.1',
  ## check processes
  'sensu-plugins-process-checks' => '2.4.0',
  ## check rabbitmq
  'sensu-plugins-rabbitmq' => '3.2.0',
  ## check redis
  'sensu-plugins-redis' => '2.0.0',
  ## check chef
  'sensu-plugins-chef' => '3.0.2',
  'hashie' => '3.5.6',
  ## check nginx
  'sensu-plugins-nginx' => '2.2.0'
}

# loop over each gem and install it into the sensu embedded ruby
node['MY_CUSTOM_NAMESPACE']['sensu']['plugins'].each do |plugin, version|
  sensu_gem plugin do
    version version
  end
end

To install gems with a Ruby other than the Sensu embedded Ruby, use Chef's gem_package in stead of sensu_gem.

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.

NOTE: 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.

Build and Release

For maintainers looking to release new versions of this cookbook you should follow this process:

  1. Add any README.md and CHANGELOG.md changes with links to Pull Requests. Commit this to develop branch.
  2. Update CHANGELOG.md with new version header and update diff links.
  3. Create a commit to then tag for release I would suggest something like this git commit -am 'prep for v$MAJOR.$MINOR.$RELEASE release'. Commit this to develop and make sure that everything is good to go (ci passing and such).
  4. Push from develop to master: git push origin develop:master
  5. checkout master branch and pull in changes: git checkout master && git pull
  6. Create a tagged release: hub release create v$MAJOR.$MINOR.$PATCH this should prompt you in an editor to modify the tag message. I typically leave it default, but feel free to include any useful release notes.
  7. Use the stove command to push the newly versioned cookbook to the supermarket: stove --no-git. This assumes that you have installed stove, properly configured authentication, and have been granted access to the supermarket.
  8. Optionally but recommended to update any associated PRs with a release link.

More Repositories

1

sensu

Monitoring for today's infrastructure.
Ruby
2,914
star
2

sensu-go

Simple. Scalable. Multi-cloud monitoring.
Go
1,027
star
3

uchiwa

Uchiwa is a simple yet effective open-source dashboard for the Sensu monitoring framework.
Go
919
star
4

sensu-community-plugins

Sensu community plugins for checks, handlers, & mutators.
468
star
5

sensu-puppet

Sensu Puppet module.
Ruby
165
star
6

sensu-ansible

An Ansible role to deploy a fully dynamic Sensu stack!
Ruby
126
star
7

sensu-dashboard

A dashboard for Sensu, for displaying & managing events & clients.
CoffeeScript
96
star
8

sensu-admin

An admin webui for Sensu
Ruby
86
star
9

sensu-docs-legacy

[Deprecated] Sensu documentation for versions < 0.29. Note that new docs are close enough to old ones so you should probably visit them instead!
Ruby
48
star
10

sensu-build

Deprecated build tooling for Sensu versions prior to 0.27
Ruby
41
star
11

sensu-docs

Sensu documentation
HTML
41
star
12

sensu-go-ansible

Official Ansible module for Sensu Go
Python
36
star
13

uchiwa-chef

Ruby
33
star
14

web

Open-source Web UI for Sensu Go clusters
TypeScript
30
star
15

sensu-prometheus-collector

Collect Prometheus metrics with Sensu!
Go
28
star
16

sensu-go-workshop

Sensu Go 6 Monitoring as Code workshop.
Shell
22
star
17

grafana-sensu-go-datasource

A Grafana data source plugin for querying the Sensu Go API
TypeScript
22
star
18

sandbox

The place to get started for new Sensu users
Shell
21
star
19

uchiwa-web

Uchiwa is a simple yet effective open-source dashboard for the Sensu monitoring framework.
JavaScript
20
star
20

sensu-influxdb-handler

Sensu Go InfluxDB Metrics Handler
Go
14
star
21

sensu-salt

Your source to use Sensu with SaltStack
14
star
22

sensu-transport

The Sensu transport abstraction library.
Ruby
14
star
23

sensu-k8s-quick-start

Shell
14
star
24

sensu-kube-demo

The Sensu Kubernetes monitoring demo repository.
Shell
13
star
25

sensu-omnibus

Build full-stack platform-specific Sensu packages
Ruby
12
star
26

sensu-go-chef

Chef Library Cookbook for Sensu Go
Ruby
11
star
27

sensu-perf

The Sensu performance testing project.
Shell
11
star
28

sensu-email-handler

Sensu Go Email Handler Plugin
Go
11
star
29

sensu-alpha-documentation

Sensu 2.0 Alpha Documentation and Examples
10
star
30

sensu-slides

Sensu intro slide deck, using ShowOff.
CSS
9
star
31

uchiwa-build

Omnibus build tooling for Uchiwa, a Sensu dashboard.
9
star
32

sensu-settings

The Sensu settings library, loader and validator.
Ruby
9
star
33

sensu-extensions-occurrences

The Sensu Core built-in occurrences filter extension
Ruby
9
star
34

catalog

Monitoring as code for Sensu Go. "There's a template for that!"
Shell
8
star
35

sensu-operator

An operator to manage Sensu 2.0 clusters
Go
8
star
36

sensu-extensions-check-dependencies

Ruby
7
star
37

sensu-plugin-sdk

A framework for creating Sensu plugins
Go
7
star
38

sensu-translator

A CLI tool for translating Sensu 1.x configuration into the Sensu Go format.
Ruby
7
star
39

sensu-flow

Github Action for Sensu flow resource management pattern.
Shell
7
star
40

sensu-go-fatigue-check-filter

An event filter for Sensu Go for managing alert fatigue
JavaScript
6
star
41

sensu-pagerduty-handler

Sensu Go PagerDuty Handler
Go
6
star
42

sensu-aws

Sensu Go AWS Plugins
Go
6
star
43

sensu-plugin-tool

Go
5
star
44

monitoring-plugins

Sensu Assets for the monitoring-plugins.org project
Shell
5
star
45

sensu-admin-chef

Sensu Admin Chef cookbook.
Ruby
5
star
46

sensu-summit-notes

Place to share takeaways from Community Day year over year
5
star
47

snmptrapd2sensu

Convert SNMP traps from Net-SNMP snmptrapd into Sensu Go events via the Sensu Go API.
Go
4
star
48

sensu-go-graphite-handler

Go
4
star
49

sensu-bash

Do not try this at home.
Shell
4
star
50

sensu-go-plugin

Template repo for Sensu Go plugins
Go
4
star
51

sensu-extensions

The Sensu extension loader library.
Ruby
4
star
52

sensu-extension

The Sensu extension library.
Ruby
4
star
53

sensu-go-python

Python client library for Sensu Go
Python
4
star
54

sensu-go-bonsai-asset

Shell
3
star
55

sensu-slack-handler

The Sensu Go Slack handler for notifying a channel.
Go
3
star
56

sensu-ruby-runtime

The Sensu Go Ruby Runtime Asset
Shell
3
star
57

sensu-spawn

The Sensu spawn process library.
Ruby
3
star
58

system-profile-linux

A Sensu plugin for collecting system resource metrics from the procfile system, with the aim to provide a Sensu-native alternative to Collectd's built-in system resource telemetry.
Go
3
star
59

sensu-docker

Official Docker images for the Sensu Go commercial distribution. Visit https://sensu.io/downloads for the latest Sensu Go downloads, including the newest Docker images.
Shell
3
star
60

sensu-remediation-handler

Sensu Go handler for implementing "self healing" workflows
Go
2
star
61

sensu-ruby32-runtime

Shell
2
star
62

homebrew-tap

Sensu Homebrew formulas
Ruby
2
star
63

sensu-logger

The Sensu logger library.
Ruby
2
star
64

check-disk-usage

Go
2
star
65

sensu-omnibus-packer

Shell
2
star
66

sensu-redis

The Sensu Redis client library.
Ruby
2
star
67

check-ntp

Sensu NTP offset check for Linux (ntpd or chrony)
Go
2
star
68

training-vagrant

Shell
2
star
69

http-checks

HTTP checks for use with Sensu
Go
2
star
70

nginx-check

A Sensu check and metrics collector for NGINX
Go
2
star
71

sensu-check-log

The Sensu Go log file monitoring check plugin and asset.
Go
2
star
72

package-deployer

Ruby
2
star
73

sensu-logo

The Sensu logo.
1
star
74

handler-plugin-template

Go
1
star
75

sensu-homebrew

Shell
1
star
76

sensu-core-extensions

1
star
77

sensu-api-tools

API Tools for sensu-go
Go
1
star
78

puppet-module-sensuclassic

Puppet module to manage Sensu Classic (ruby version)
Ruby
1
star
79

sensu-json

The Sensu JSON parser abstraction library.
Ruby
1
star
80

sensu-opcua-checks

Sensu checks for OPC-UA endpoints
Go
1
star
81

docker-buildx-orb

1
star
82

sensu-2.0-migration-workshop

Vagrant/Virtualbox resources for a walk through migrating 1.x sensu core workload to 2.x sensu
Ruby
1
star
83

system-check

Go
1
star
84

sensu-kubernetes-events

Go
1
star
85

sensu-eval-stack

AWS Provisioned Sensu Enterprise Evaluation Stack
Ruby
1
star
86

sensu-timescaledb-handler

Sensu Go TimescaleDB Handler https://sensu.io
Go
1
star
87

sensu-project-status

Simple status overview of Sensu Core projects
HTML
1
star
88

sensu-extensions-debug

The Sensu Core built-in debug handler
Ruby
1
star
89

sensu-1.x-filter-wrapper

Proof-of-concept ruby gRPC extension for wrapping evaluation of sensu 1.x filters in 2.x
Ruby
1
star
90

sensu-data-analysis

Configure Sensu Monitoring Jobs to query data platforms and analyze observability data.
Go
1
star
91

check-memory-usage

Simple cross-platform memory and swap usage checks
Go
1
star
92

core

Core API for sensu-go
Go
1
star
93

sensu-install

The Sensu Ruby Plugin installer
Ruby
1
star
94

sensu-kafka-handler

Sensu handler to send Sensu events to Kafka messages
Go
1
star
95

sensu-ruby26-runtime

Shell
1
star
96

sensu-plugins-omnibus

Ruby
1
star
97

sensu-test-day

Repository for coordinating Sensu Test Day activities. File issues here to report on test day success and failures.
Shell
1
star
98

sensu-cloudwatch-check

AWS Cloudwatch plugin for Sensu Go (including AWS service presets)
Go
1
star
99

awscli-windows-orb

1
star
100

sensu-relay-handler

The Sensu Go Relay handler to relay Events to another Sensu Go installation.
Go
1
star