Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding more checks #44

Open
fzebib opened this issue Dec 21, 2014 · 2 comments
Open

Adding more checks #44

fzebib opened this issue Dec 21, 2014 · 2 comments

Comments

@fzebib
Copy link

fzebib commented Dec 21, 2014

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!

@pelacables
Copy link

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

@pmoranga
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants