Puppet & Nagios/NRPE with Plugins...

920 views
Skip to first unread message

Gavin Williams

unread,
Dec 3, 2012, 6:47:24 AM12/3/12
to puppet...@googlegroups.com
Morning all

I've had a quick google, but couldn't find anything useful for our scenario...

Basically, we use Nagios & NRPE in our environment, along with a hand-full of in-house written plugins specific to our applications etc...
These scripts change on a fairly regular basis, so hand rolling a RPM each time is too much work as far as i'm concerned...

So I can easily get NRPE installed on a node using Puppet... However what I'm struggling with is getting all the plugins synced over aswell...

One suggestion I read was to use a file resource, however I've also read about severe performance issues when working with tens of files...
I dont really want to have to create some kind of NFS file share to distribute the files...

So, any other ideas?

Cheers
Gavin

P.S. Env consists of a single 3.0 Puppet Master, currently with about a dozen nodes connected, but this will rapidly increase once we start full roll-out...

Nikola Petrov

unread,
Dec 3, 2012, 7:14:06 AM12/3/12
to puppet...@googlegroups.com
Well you can tell puppet to source a whole directory and put it
somewhere for you. Here is an example from our nagios application
specific manifest



<snip>
class app {
#install the app package
include app::install
include base
#generic nagios checks like memory, load, etc
include nagios::target



#application specific checks
file {'/usr/local/nagios':
ensure => 'directory',
}

file {'/usr/local/nagios/libexec/':
ensure => 'directory',
recurse => 'true', #enable recursive directory management
purge => 'true', #purge all unmanaged junk
force => 'true', #also purge subdirs and links etc.
owner => 'nagios',
group => 'nagios',
mode => '0544',
source => 'puppet:///modules/app/nagios',
}

Class['app::params'] -> Class['app']
}
</snip>

Pay attention to the file resources. You can now put
your nagios checks in *modelpath/files/nagios/*. Change the path as
/usr/local/nagios/libexec is used here for historical reasons

Hope that helps.

Best, Nikola

Peter Brown

unread,
Dec 3, 2012, 6:56:35 PM12/3/12
to puppet-users
Hi Gavin,

I have a module i wrote that seems like it will do what you need.
I also have a nagios module that uses it to setup nrpe services on each node and exports nagios checks to be imported into a nagios instance.

I basically setup nrpe on each node to use a config directory and have a define that uses templates to generate each nrpe service that need to be setup.
My nagios module needs some rewriting before I will be happy releasing it.
The nrpe module is pretty much good to go though.
It can also use sudo, also managed by another module I have (Yeah I have a lot olf modules and most of them talk to other modules I wrote)

I am going start putting my stuff on github and puppet forge as soon as I have them ready.

Are you interested in being a guinea pig?

:)

Pete.


--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/NgMZ8MKfN1oJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

fatmcgav

unread,
Dec 4, 2012, 2:05:56 AM12/4/12
to puppet...@googlegroups.com
Pete

Sounds good to me... N be easier than me re-inventing the wheel...

Would be happy to guinea pig... :)

Cheers
Gav

Peter Brown

unread,
Dec 4, 2012, 6:26:40 PM12/4/12
to puppet-users
On 4 December 2012 17:05, fatmcgav <fatm...@gmail.com> wrote:
Pete

Sounds good to me... N be easier than me re-inventing the wheel...

Would be happy to guinea pig... :)


Awesome.
I have an account on gitorious which I am going to use to put my code on.
Gimme a bit to get my module cleaned up and make sure it works by itself.
Will let you know when it's up there.

Pete.

Peter Brown

unread,
Dec 4, 2012, 10:30:41 PM12/4/12
to puppet-users
Hi Gav,

I just put my nrpe module up on gitorious.

https://gitorious.org/rendhalver-puppet/nrpe

I had to pull out my nrpe::firewall class for now because it uses my firewall module which I will be releasing at some point as well.
I tagged the stable release as v1.0 so if you are going to clone it check out that tag if you prefer.
The docs are non-existent as yet but the code is pretty self explanatory.

it sets up nrpe on a node and you use the nrpe::plugin define to add new services.
I use nrpe::params to set my variables so you need something in your node like this to set those.
You can of course use hiera if you prefer.

include nrpe
class {'nrpe::params':
  nagios_extra_plugins => '/srv/scripts/nagios',
  nagios_ips => '192.168.0.1',
}

You can also set the port, user and group nrpe runs as as well as a few other vars.

the nrpe::plugin works something like this.

class monitoring::service::disk ( $ensure = $nagios_ensure, $host_name = $nagios_host_name, $service_type = 'standard_service', $notifications = $nagios_notifications ) {

  @@nagios_service { "${host_name}_disk":
    ensure          => $ensure,
    use           => $service_type,
    host_name       => $host_name,
    service_description   => 'DISK',
    servicegroups     => $nagios_host_type ? { 'nonotify_server' => 'system', default => 'system,important_email' },
    check_command     => 'check_nrpe!check_disk',
    contact_groups      => $nagios_sms_alerts ? { false => 'admins,linux_admins', true => 'admins,linux_admins,linux_admin_sms' },
    notifications_enabled => $notifications ? { default => undef, false => 0 },
    register        => 1,
    notify          => Service[nagios],
    tag           => "nagios_${monitoring_server}",
  }
  nrpe::plugin { 'disk':
    ensure      => $ensure,
    plugin      => 'main',
    sudo => true, # you will need an sudo rule for that.
    check_command => 'check_disk -w 20% -c 10% --all',
    notify      => Class['nrpe::service'],
  }
}

That is how I use that define in my monitoring class which will get released as well once I split out the nagios code into it's own module.

if you find any bugs please let me know and I shall fix them as soon as I can.

I will be putting it on puppet forge as well once I work out how that works.

Hope that helps.

If anyone else is keen to try it out let me know how it goes.

Pete.

Peter Brown

unread,
Dec 4, 2012, 11:45:05 PM12/4/12
to puppet-users
Hi again,

It seems github is a better option as they have an issue tracker.

https://github.com/rendhalver/puppet-nrpe

Gavin Williams

unread,
Dec 5, 2012, 8:17:04 AM12/5/12
to puppet...@googlegroups.com
Pete

Cheers for that...

Will have a read through the code and give it a spin :)

Cheers
Gavin

Peter Brown

unread,
Dec 5, 2012, 9:32:33 PM12/5/12
to puppet-users
Cool.

Let me know how it goes.
I am making a start at splitting out my code for nagios into a module by itself and setting up one for icinga as well.

Will likely post to the list when it's ready for consumption.


Pete.



To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/f2uEiE3CjGwJ.

Gavin Williams

unread,
Feb 11, 2013, 10:12:11 AM2/11/13
to puppet...@googlegroups.com
Pete

Bit of a blast from the past, but this is next on my hit-list...

Code looks like it fits quite well overall, however I'm struggling to see how you handle adding additional plugin scripts to the boxes... Can see plugin.pp adding the required nagios cfg additions, but it doesnt appear to be copying the actual plugin file(s)... Is that something you handle separately?

Cheers
Gavin

Peter Brown

unread,
Feb 11, 2013, 11:52:42 PM2/11/13
to puppet-users
Hi Gavin.

Those are in my monitoring module which uses nrpe::plugin define to add resources to a node.
It's on forge and github now if you want to take a look...

I am trying to write more portable code that manages one service as opposed to how I had it before which was one module managing nagios,nrpe,nsca and assorted goodies.
I also need to write some docs...


To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.

To post to this group, send email to puppet...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages