Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet

1,249 views

Published on

Choon Ming, senior consultant at OlinData, gave an overview of how Puppet compliments Nagios, and how you can make Puppet work with Nagios in under 10 minutes.

Published in: Technology
  • Be the first to comment

PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet

  1. 1. Nagios in <10 mins with Puppet December 3rd, 2012 PuppetCamp SEA #2, Singapore Goh Choon Ming, OlinData
  2. 2. Setup difficulty?
  3. 3. Puppet made it simpler to setup
  4. 4. Puppet resource types
  5. 5. @@nagios_host { $::fqdn: ensure => present, address => $::fqdn, use => "generic-host", tag => $domain, }
  6. 6. @@nagios_service { "check_ping_$::fqdn" : host_name => $::fqdn, use => "generic-service", check_command => "check_ping!600,20%!1000,50%", service_description => "check_ping", tag => $::domain, }
  7. 7. nagios_command { check_http_alt: ensure => present, command_line => "/usr/lib/nagios/plugins/check_http -H $HOSTADDRESS$ -p $ARG1$ -u $ARG2$-e HTTP/1.1 200 OK", }
  8. 8. nagios_contact { choonming: ensure => present, alias => CM, email => choonming@olindata.com, host_notification_commands => notify-service-by-email, service_notification_commands => notify-service-by-email, host_notification_period => 24x7, service_notification_period => 24x7, host_notification_options => d,r, service_notification_options => w,c,u,r, }
  9. 9. And many many othershttp://docs.puppetlabs.com/references/stable/type. html
  10. 10. Yet there is another problem?What is it and how do we fix it?
  11. 11. Functions
  12. 12. Tagging
  13. 13. Exported resources
  14. 14. @@nagios_host { $::fqdn: address => $::fqdn, use => "generic-host", tag => $::domain, }Nagios_host <<| tag == olindata.com |>> { target => /etc/nagios3/conf.d/services.cfg, notify => Service[ nagios3 ], }
  15. 15. How to create a multi-environment Nagios setup?
  16. 16. Environments
  17. 17. if ($environment == "production" ) { Nagios_host <<| tag == "prod.olindata.com" |>> { target => "/etc/nagios3/conf.d/hosts.cfg", notify => Service[ nagios3 ], } Nagios_service <<| tag == "prod.olindata.com" |>> { target => "/etc/nagios3/conf.d/services.cfg", notify => Service[ nagios3 ], }else { Nagios_host <<| tag == "test.olindata.com" |>> { target => "/etc/nagios3/conf.d/hosts.cfg", notify => Service[ nagios3 ], } Nagios_service <<| tag == "test.olindata.com" |>> { target => "/etc/nagios3/conf.d/services.cfg", notify => Service[ nagios3 ], }
  18. 18. Taking another step further with Nagios
  19. 19. Executing plugins on remote machines with NRPE
  20. 20. Defined resource types
  21. 21. define nagios::nrpe($command, $sudo=false) { $sudo_command = $sudo ? { true => "/usr/bin/sudo ", False => , } file { "/etc/nagios/nrpe.d/$name.cfg": content => "command[$name]=$sudo_command/usr/lib/nagios/plugins/$commandn", require => Package["nagios-nrpe-server"], notify => Service["nagios-nrpe-server"], }}
  22. 22. @@nagios_service { "check_disk_${::fqdn}": check_command => "check_nrpe_1arg!check_disk", use => "generic-service", host_name => $f::qdn, service_description => "check_disk", tag => $::domain, }nagios::nrpe { "check_disk" : command => "check_disk -w 20% -c 10% -l" }
  23. 23. Taking another step further with Nagios and Puppets resources resource type
  24. 24. resources { nagios_host: purge => true, }resources { nagios_service: purge => true, }
  25. 25. DEMO
  26. 26. Questions?
  27. 27. How to find me? Email: ▫ choonming[at]olindata.com• Twitter: ▫ @choonming• Github: ▫ https://github.com/choonming ▫ https://github.com/tribily• Facebook: ▫ https://fb.me/olindata• IRC: ▫ Freenode - choonming
  28. 28. Thank you!

×