Ticket ID #220 ‐ Expand Nagios Monitoring with Puppet - GriffinKat/group-a GitHub Wiki

Creating Host Groups

Host groups allow us to group hosts that share common characteristics. For example, we can create a host group for all servers running SSH and another for the database server.

  • Host group for SSH servers

    Write the following code in the config.pp file to create a host group for SSH servers.

    nagios_hostgroup { 'my-ssh-servers':
      target               => '/etc/nagios4/conf.d/ppt_hostgroups.cfg',
      alias                => 'My SSH Servers',
      mode                 => '0644',
      members              => 'db-a, apps-a, backup-a'
    }
    
  • Host group for Database servers

    Write the following code in the config.pp file to create a host group for Database servers.

    nagios_hostgroup { 'my-db-servers':
      target               => '/etc/nagios4/conf.d/ppt_hostgroups.cfg',
      alias                => 'My Database Servers',
      mode                 => '0644',
      members              => 'db-a'
    }
    

Creating Services

We will define services that we want to monitor. Services represent specific functions or applications running on hosts. For example, we can define a service to monitor SSH or HTTP, or MySQL services. Write the following code in the config.pp file.

  • Service to monitor SSH:

     nagios_service { "ssh":
          service_description => "SSH Servers",
          hostgroup_name => "my-ssh-servers",
          target => "/etc/nagios4/conf.d/ppt_services.cfg",
          check_command => "check_ssh",
          max_check_attempts => 3,
          retry_check_interval => 1,
          normal_check_interval => 5,
          check_period => "24x7",
          notification_interval => 30,
          notification_period => "24x7",
          notification_options => "w,u,c",
          contact_groups => "admins",
          mode => '0644'
    }
    
  • Service to monitor MYSQL:

    nagios_service { "MySQL":
          service_description => "Database Servers",
          hostgroup_name => "my-db-servers",
          target => "/etc/nagios4/conf.d/ppt_services.cfg",
          check_command => "check_mysql",
          max_check_attempts => 3,
          retry_check_interval => 1,
          normal_check_interval => 5,
          check_period => "24x7",
          notification_interval => 30,
          notification_period => "24x7",
          notification_options => "w,u,c",
          contact_groups => "admins",
          mode => '0644'
    }
    

    Below is the screenshot of the config.pp file reflecting the above code.

    image

Apply the module to the management server.

Use the following command to apply the module. sudo /opt/puppetlabs/bin/puppet agent --test image

Verification

Below is the screenshot of the nagios web-interface showing the new hosts, hostgroups and services respectively.

image

image

image