Open fzebib opened 9 years ago
Hi,
I've created a custom nagios_conf::commands class where I define the new commands like:
class nagios_conf::commands (
$nrpe_command = '$USER1$/check_nrpe -H $HOSTADDRESS$ -t 15',
) {
nagios_command { 'check_nrpe_puppet_agent':
command_line => "${nrpe_command} -c check_puppet_agent",
}
[...]
with this new command available you define new checks like:
class nagios_conf::check::puppet_agent (
$ensure = undef,
$args = '-d 0 -l agent_disabled_lockfile -s /var/lib/puppet/state/last_run_summary.yaml',
$check_title = $::nagios::client::host_name,
$servicegroups = undef,
$privileged_user = 'root',
$plugin = 'puppet_agent',
$check_period = $::nagios::client::service_check_period,
$contact_groups = $::nagios::client::service_contact_groups,
$first_notification_delay = '120',
$max_check_attempts = $::nagios::client::service_max_check_attempts,
$notification_period = $::nagios::client::service_notification_period,
$use = $::nagios::client::service_use,
) {
# The check is being executed via sudo
file { '/etc/sudoers.d/nagios_puppet_agent':
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0440',
# We customize the user, the nagios plugin dir and few other things
content => template('nagios_conf/plugins/check_puppet_agent-sudoers.erb'),
}
# Service specific script
file { "${nagios::client::plugin_dir}/puppet_agent":
ensure => $ensure,
owner => 'root',
group => 'root',
mode => '0755',
source => 'puppet:///modules/nagios_conf/plugins/puppet_agent.sh',
}
nagios::client::nrpe_file { 'check_puppet_agent':
ensure => $ensure,
plugin => $plugin,
sudo => true,
args => $args,
}
nagios::service { "check_puppet_agent_${check_title}":
ensure => $ensure,
check_command => 'check_nrpe_puppet_agent',
service_description => 'puppet_agent',
servicegroups => $servicegroups,
check_period => $check_period,
contact_groups => $contact_groups,
first_notification_delay => $first_notification_delay,
notification_period => $notification_period,
max_check_attempts => $max_check_attempts,
use => $use,
}
}
This code will create a new puppet check for any node that includes it.
HTH, Arnau
What is the best way to add new/custom checks without changing anything? I believe I have it doing everything I want properly - which is adding the host on the nagios server of the client's puppet is using - but now I just want to make "templates" with specific checks.
Thanks!