Slide 1

Slide 1 text

Monitoring with Sensu Peter Eisentraut [email protected] @petereisentraut PGConf NYC 2014

Slide 2

Slide 2 text

Life with Nagios and Munin • cumbersome to add/change hosts • not built with configuration management in mind • stale projects

Slide 3

Slide 3 text

Life with Sensu • hosts register automatically • built with configuration management in mind • active project

Slide 4

Slide 4 text

Sensu Architecture

Slide 5

Slide 5 text

Installation • use Chef or Puppet • see documentation

Slide 6

Slide 6 text

Configuration /etc/sensu/config.json { "rabbitmq": { "host": "sensu.example.net", "port": 5671, "vhost": "/sensu", "user": "sensu", "password": "password", "ssl": { "cert_chain_file": "/etc/sensu/ssl/cert.pem", "private_key_file": "/etc/sensu/ssl/key.pem" } } }

Slide 7

Slide 7 text

A Check /etc/sensu/conf.d/checks/check-cpu.json { "checks": { "check-cpu": { "command": "/etc/sensu/community/plugins/system/ check-cpu.rb -w 80 -c 95", "handlers": ["email", "pagerduty"], "subscribers": ["default"], "interval": 60, "occurrences": 10, "refresh": 1800 } } }

Slide 8

Slide 8 text

https://github.com/sensu/sensu-community-plugins

Slide 9

Slide 9 text

Use Chef sensu_check "check-cpu" do command "/etc/sensu/community/plugins/system/check-cpu .rb -w 80 -c 95" handlers ["email", "pagerduty"] subscribers ["default"] interval 60 additional(occurrences: 10, refresh: 1800) end

Slide 10

Slide 10 text

Use Puppet sensu::check { 'check-cpu': command => '/etc/sensu/community/plugins/system/ check-cpu.rb -w 80 -c 95', handlers => ['email', 'pagerduty'], subscribers => ['default'], interval => 60, custom => { 'occurrences' => 10, 'refresh' => 1800, }, }

Slide 11

Slide 11 text

A Handler /etc/sensu/conf.d/handlers/email.json { "handlers": { "email": { "type": "pipe", "command": "mail -s 'sensu alert' your@address" } } }

Slide 12

Slide 12 text

A Client /etc/sensu/conf.d/client.json { "client": { "name": "server01.example.net", "address": "10.10.10.10", "subscriptions": [ "default" ] } }

Slide 13

Slide 13 text

Dashboard

Slide 14

Slide 14 text

What about PostgreSQL?

Slide 15

Slide 15 text

Use check_postgres! sensu_check "check_postgres_backends" do interval 60 command "check_postgres --action=backends" subscribers ["postgresql"] handlers ['dba'] end

Slide 16

Slide 16 text

Standalone Checks

Slide 17

Slide 17 text

Standalone Checks sensu_check "check_postgres_backends_5432" do interval 60 command "check_postgres --action=backends --port=5432" standalone true handlers ['dba'] end sensu_check "check_postgres_backends_5433" do interval 60 command "check_postgres --action=backends --port=5433" standalone true handlers ['dba'] end

Slide 18

Slide 18 text

Metrics

Slide 19

Slide 19 text

Metrics • check: returns quasi-Boolean result • metric: returns numeric result

Slide 20

Slide 20 text

A Metric { "checks": { "cpu_metrics": { "command": "/etc/sensu/community/plugins/system/ cpu-pcnt-usage-metrics.rb", "handlers": ["graphite"], "subscribers": ["default"], "type": "metric", "interval": 60 } } }

Slide 21

Slide 21 text

What about PostgreSQL?

Slide 22

Slide 22 text

Nagios “Performance Data” $ check_postgres --action=backends POSTGRES_BACKENDS OK: DB "postgres" 1 of 100 connections (1%) | time=0.02s commitfest=0;90;95;0;100 contrib_regression=0;90;95;0;100 foo=0;90;95;0;100 postgres=1;90;95;0;100 template0=0;90;95;0;100 template1=0;90;95;0;100 test=0;90;95;0;100 test2 =0;90;95;0;100

Slide 23

Slide 23 text

Mutators check (metric) -> mutator -> handler check_postgres -> ??? -> graphite

Slide 24

Slide 24 text

write your own

Slide 25

Slide 25 text

Idea check_postgres --output=graphite

Slide 26

Slide 26 text

Other Features • REST API • port 3030 • sensu-admin • remediation • multimaster server • custom check attributes • severity filtering • check dependencies • flap detection • subduing

Slide 27

Slide 27 text

Links • http://sensuapp.org/ • http://sensuapp.org/docs • https://github.com/sensu