Ticket #223: Expand Nagios Monitoring with Puppet - SupaHotBall/OE2-Group-D GitHub Wiki

Task

Define Nagios Hosts

  • Add nagios_host resources for all servers (app-x.oe2.org.nz, backup-x.oe2.org.nz, and mgmt-x.oe2.org.nz).
  • Ensure all host configurations are written to /etc/nagios4/conf.d/ppt_hosts.cfg.

Create Host Groups

  • Define a host group for SSH servers (my-ssh-servers).
  • Define a host group for the database server (my-db-servers).
  • Ensure host group configurations are written to /etc/nagios4/conf.d/ppt_hostgroups.cfg.

Define Services

  • Create a service to monitor SSH for the my-ssh-servers host group.
  • Create a service to monitor MySQL for the my-db-servers host group.
  • Ensure service configurations are written to /etc/nagios4/conf.d/ppt_services.cfg.

Steps Taken

Open config.pp file in manager server

cd /etc/puppetlabs/code/modules/nagios/manifests

then

sudo nano config.pp

Once you are inside the file create other 3 server host

 nagios_host { "apps-d":
        target               => "/etc/nagios4/conf.d/ppt_hosts.cfg",
        alias                => "apps",
        check_period         => "24x7",
        max_check_attempts   => 3,
        check_command        => "check-host-alive",
        notification_interval => 30,
        notification_period  => "24x7",
        notification_options => "d,u,r",
        mode                 => "0444",
    }
    nagios_host { "backup-d":
        target               => "/etc/nagios4/conf.d/ppt_hosts.cfg",
        alias                => "backup",
        check_period         => "24x7",
        max_check_attempts   => 3,
        check_command        => "check-host-alive",
        notification_interval => 30,
        notification_period  => "24x7",
        notification_options => "d,u,r",
        mode                 => "0444",
    }
    nagios_host { "mgmt-d":
        target               => "/etc/nagios4/conf.d/ppt_hosts.cfg",
        alias                => "mgmt",
        check_period         => "24x7",
        max_check_attempts   => 3,
        check_command        => "check-host-alive",
        notification_interval => 30,
        notification_period  => "24x7",
        notification_options => "d,u,r",
        mode                 => "0444",
    }

{BAD46739-AD37-4B10-9042-BD9DCE7A5915}

Here is ow it looks in the webpage {16B9AA6D-0D9B-4C7F-8B01-27F588FDE8B3}

Create Host Group for SSH server (config.pp)

nagios_hostgroup { "my-ssh-servers":
        target => "/etc/nagios4/conf.d/ppt_hostgroups.cfg",
        mode => "0644",
        alias => "My SSH Servers",
        members => "db-d, apps-d, backup-d",
    }

{5D82840A-DB44-41BC-8208-1C3D9F4CFE7A}

Create Host Group for database server (config.pp)

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

{0C420E38-1413-4EC8-AE41-FF1EC2B1A1A4}

Here how it look in the webpage {B4E7053F-B275-41DC-B010-FE458927702D}

Create SSH Services

 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",
        }

{C195299C-AF32-47AF-848C-5072215EA307}

Create MySQL Services

 nagios_service { "mysql":
        service_description => "DB 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",
        }

{9ACD00D0-A70D-4F8E-AA58-C16143B2607B}

{6ACE486B-67C5-49F9-886F-FE3E8743D855}

If you want to remove Swap Usage from being displayed in the Nagios web interface, follow these steps:

Navigate to the Configuration Directory

cd /etc/nagios4/objects

Edit the localhost.cfg File

sudo nano localhost.cfg

Comment Out the Swap Usage Section

{F578C1A8-3157-48D5-9FE8-5525754ABB62}

Restart Nagios

sudo systemctl restart nagios4

Challenges

N/A


External Resources

N/A


Ticket Reference

https://rt.dataraster.com/Ticket/Display.html?id=223