Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Monitoring with Sensu

Monitoring with Sensu

If you feel stuck with the likes of Nagios and Munin, then Sensu might be for you. Sensu is a new open-source monitoring framework built with and for modern technology. Learn how it works and how you can use it to monitor your PostgreSQL installations.

(originally presented at PGConf NYC 2014, http://nyc.pgconf.us/2014/event/17/)

1299b89b8b3f683a581bcf502fd0205a?s=128

Peter Eisentraut

April 03, 2014
Tweet

Transcript

  1. Monitoring with Sensu Peter Eisentraut peter@eisentraut.org @petereisentraut PGConf NYC 2014

  2. Life with Nagios and Munin • cumbersome to add/change hosts

    • not built with configuration management in mind • stale projects
  3. Life with Sensu • hosts register automatically • built with

    configuration management in mind • active project
  4. Sensu Architecture

  5. Installation • use Chef or Puppet • see documentation

  6. 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" } } }
  7. 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 } } }
  8. https://github.com/sensu/sensu-community-plugins

  9. 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
  10. 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, }, }
  11. A Handler /etc/sensu/conf.d/handlers/email.json { "handlers": { "email": { "type": "pipe",

    "command": "mail -s 'sensu alert' your@address" } } }
  12. A Client /etc/sensu/conf.d/client.json { "client": { "name": "server01.example.net", "address": "10.10.10.10",

    "subscriptions": [ "default" ] } }
  13. Dashboard

  14. What about PostgreSQL?

  15. Use check_postgres! sensu_check "check_postgres_backends" do interval 60 command "check_postgres --action=backends"

    subscribers ["postgresql"] handlers ['dba'] end
  16. Standalone Checks

  17. 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
  18. Metrics

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

    result
  20. A Metric { "checks": { "cpu_metrics": { "command": "/etc/sensu/community/plugins/system/ cpu-pcnt-usage-metrics.rb",

    "handlers": ["graphite"], "subscribers": ["default"], "type": "metric", "interval": 60 } } }
  21. What about PostgreSQL?

  22. 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
  23. Mutators check (metric) -> mutator -> handler check_postgres -> ???

    -> graphite
  24. write your own

  25. Idea check_postgres --output=graphite

  26. Other Features • REST API • port 3030 • sensu-admin

    • remediation • multimaster server • custom check attributes • severity filtering • check dependencies • flap detection • subduing
  27. Links • http://sensuapp.org/ • http://sensuapp.org/docs • https://github.com/sensu