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",
}
Here is ow it looks in the webpage
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",
}
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",
}
Here how it look in the webpage
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",
}
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",
}
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
Restart Nagios
sudo systemctl restart nagios4
Challenges
N/A
External Resources
N/A
Ticket Reference
https://rt.dataraster.com/Ticket/Display.html?id=223