Version 3 (modified by Ross, 9 years ago) (diff)


Creating a nagios monitor

This page explains how to create a nagios monitor configuration in puppet. You will need to make changes to get the correct configuration for the specific type of monitoring needed.

Set up an executable

These files are stored in puppet/modules/mayfirst/files/monitor-utils/ you can find examples of different versions of monitoring scripts there.

Set up a cronjob


You'll need to add your script to this directory.

Add to utils.pp


The code should look something like this, with the correct file from the executable specified.:

  file { "/usr/local/sbin/mf-monitor-mailq":
    source => "puppet:///modules/mayfirst/monitor-utils/mf-monitor-mailq",
    ensure => present,
    mode => 755,
    owner => "root",
    group => "root"

Define hostgroup


This code section should look something like this:

define hostgroup {
  hostgroup_name  mailq-servers
  alias           Mail Check Servers

Define nagios command


Should look like this:

define command{
  command_name    check-upgrade
  command_line    /usr/local/share/nagios/plugins/mf-nagios-check-upgrade '$HOSTNAME$'

Create parsing script

You will also need to create a script that parses the output of the monitoring files.


You can model scripts that already exist to check this.

Add the check as a service

The service part of the infrastructure is the display component for nagios.


Copy a pre-existing stanza and make the necessary changes. It will look something like this:

define service{
        hostgroup_name                  upgrade-servers
        service_description             Upgrade 
        check_command                   check-upgrade
        notification_interval           0
        use                             generic-service

Finally add the hostgroup to nagios manifest


One example for standard_hostgroups is:

  if ( $include_standard_hostgroups == true ) {
    $standard_hostgroups = [ 'df-servers', 'upgrade-servers', 'mailq-servers' ]
    $assigned_hostgroups = concat($hostgroups, $standard_hostgroups)
  } else {
    $assigned_hostgroups = $hostgroups

This is from 'define m_nagios_host'.

Make sure all executable scripts have execute permissions