PuppetCamp SEA @ Blk 71 - Nagios in under 10 mins with Puppet
-
Upload
walter-heck -
Category
Technology
-
view
3.244 -
download
0
description
Transcript of 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
Setup difficulty?
Puppet made it simpler to setup
Puppet resource types
@@nagios_host { $::fqdn: ensure => present, address => $::fqdn, use => "generic-host", tag => $domain, }
@@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, }
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\'", }
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', }
And many many othershttp://docs.puppetlabs.com/references/stable/type.
html
Yet there is another problem?What is it and how do we fix it?
Functions
Tagging
Exported resources
@@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' ], }
How to create a multi-environment Nagios setup?
Environments
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' ], }
Taking another step further with Nagios
Executing plugins on remote machines with NRPE
Defined resource types
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"], }}
@@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" }
Taking another step further with Nagios and Puppet's resources resource type
resources { 'nagios_host': purge => true, } resources { 'nagios_service': purge => true, }
DEMO
Questions?
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
Thank you!