puppetcamp sea @ blk 71 - nagios in under 10 mins with puppet

30
Nagios in <10 mins with Puppet December 3 rd , 2012 PuppetCamp SEA #2, Singapore Goh Choon Ming, OlinData

Upload: walter-heck

Post on 04-Dec-2014

3.244 views

Category:

Technology


0 download

DESCRIPTION

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

TRANSCRIPT

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

Nagios in <10 mins with PuppetDecember 3rd, 2012PuppetCamp SEA #2,Singapore

Goh Choon Ming, OlinData

Page 2: PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
Page 3: PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet
Page 4: PuppetCamp SEA @ Blk 71 -  Nagios in under 10 mins with Puppet

Setup difficulty?

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

Puppet made it simpler to setup

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

Puppet resource types

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

@@nagios_host { $::fqdn: ensure => present, address => $::fqdn, use => "generic-host", tag => $domain, }

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

@@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, }

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

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\'", }

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

nagios_contact { 'choonming': ensure => present, alias => 'CM', email => '[email protected]', 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', }

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

And many many othershttp://docs.puppetlabs.com/references/stable/type.

html

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

Yet there is another problem?What is it and how do we fix it?

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

Functions

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

Tagging

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

Exported resources

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

@@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' ], }

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

How to create a multi-environment Nagios setup?

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

Environments

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

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' ], }

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

Taking another step further with Nagios

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

Executing plugins on remote machines with NRPE

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

Defined resource types

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

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/$command\n", require => Package["nagios-nrpe-server"], notify => Service["nagios-nrpe-server"], }}

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

@@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" }

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

Taking another step further with Nagios and Puppet's resources resource type

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

resources { 'nagios_host': purge => true, } resources { 'nagios_service': purge => true, }

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

DEMO

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

Questions?

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

How to find me?

Email:▫ choonming[at]olindata.com

• Twitter:▫ @chononming

• Github:▫ https://github.com/choonming▫ https://github.com/tribily

• Facebook:▫ https://fb.me/olindata

• IRC:▫ Freenode - choonming

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

Thank you!