pdxcat-nrpe, hiera data in command

288 views
Skip to first unread message

Ugo Bellavance

unread,
Apr 21, 2016, 3:09:34 PM4/21/16
to Puppet Users
Hi,

I want to create a nrpe command using the pdxcat-nrpe, for check_ntp.  My NTP servers would check against public servers, and all others will check against my internal NTP servers.

The code looks like that:

      nrpe::command {
        'check_ntp':
          package_name  => 'nagios-plugins-ntp',
          ensure  => present,
          command => "check_ntp -H $ntpserver";
      }

I'd like to simply use a value in hiera for $ntpserver but it doesn't look possible without editing the module, which I'd like to avoid as much as possible.

Anyone has an idea?

Thanks,

Rob Nelson

unread,
Apr 21, 2016, 3:25:35 PM4/21/16
to puppet...@googlegroups.com
Can you link directly to the module you're using, on the forge or on github?


--

Ugo Bellavance

unread,
Apr 21, 2016, 3:28:33 PM4/21/16
to Puppet Users


On Thursday, April 21, 2016 at 3:25:35 PM UTC-4, Rob Nelson wrote:
Can you link directly to the module you're using, on the forge or on github?

Rob Nelson

unread,
Apr 21, 2016, 4:21:33 PM4/21/16
to puppet...@googlegroups.com
You cannot automatically pass parameters to defines with hiera. But, if you put the nrpe::commands in a profile, you can do APL that way. I.e.

class profile::something (
$ntpserver,
) {
nrpe::command {'check_ntp':
package_name  => 'nagios-plugins-ntp',
ensure  => present,
command => "check_ntp -H $ntpserver";
}
}
In your hiera data, add this at the right tier:

profile::something::
ntpserver: 127.0.0.1

You can have specific classes for each check, or a giant nrpe profile that includes all the commands. Just make all the variables you want to pass to nrpe::command instances parameters of the class, and hiera can do the heavy lifting. That should give you the best of both worlds.

Rob Nelson
rnel...@gmail.com

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5cc2f9ab-4341-4769-9d08-274bab779d42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Garrett Honeycutt

unread,
Apr 21, 2016, 4:25:29 PM4/21/16
to puppet...@googlegroups.com
Hi Ugo,

You don't have to to modify pdxcat/nrpe to get that to work. Wherever
you are calling this from, you need to set the value of $ntpserver. That
can happen as a parameter to the class which would automatically look it
up or with the hiera() function.

I also have an nrpe module. It allows you to specify all of your plugins
in Hiera.

They seem to be similar in OS support and functionality, though mine has
extensive unit testing.

https://github.com/ghoneycutt/puppet-module-nrpe#usage

Best regards,
-g

--
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

Ugo Bellavance

unread,
Apr 22, 2016, 4:02:17 PM4/22/16
to Puppet Users
Hi Ugo,

You don't have to to modify pdxcat/nrpe to get that to work. Wherever
you are calling this from, you need to set the value of $ntpserver. That
can happen as a parameter to the class which would automatically look it
up or with the hiera() function.

I also have an nrpe module. It allows you to specify all of your plugins
in Hiera.

They seem to be similar in OS support and functionality, though mine has
extensive unit testing.

https://github.com/ghoneycutt/puppet-module-nrpe#usage

Best regards,
-g

Hi Garrett,

I decided to give your module a try, I think it's worth it.  I like the idea of having small manifests and all the rest in hiera. However, can I use the value of a variable in hiera or do I need to put the whole command definition in each yaml file?

For example:

---
ntp::autoupdate: true
ntp::enable: true
ntp::servers:
nrpe::allowed_hosts: ['127.0.0.1', '192.168.xxx.xxx']
nrpe::plugins:
  check_load:
    args: '-w $ARG1$ -c $ARG2$'
  check_ntp:
    args: "-h $ntp::servers"
  check_users:
    args: '-w 5 -c 10'
  check_zombie_procs:
    plugin: 'check_proc'
    args: ' -w 5 -c 10 -s Z'

Thanks,
Reply all
Reply to author
Forward
0 new messages