Nagios tries to read configuration from the file ("/usr/local/nagios/etc/nagios.cfg").
In this file look into all the enabled lines for cfg_file
So if we need to monitor other instances, we need to write the object configurations which are referred as object definitions
Object Configuration & Object Definitions
What are Objects
Objects are elements involved in monitoring & notifications
Types of objects
Services
Service Groups
Hosts
Host Groups
Contacts
Contact Groups
Commands
Timeperiods
Notification & Execution Dependencies
Escalations
Where are these objects defined?
Objects can be defined in file or a directory having multiple files (.cfg) defined in main nagios configuration file (/usr/local/nagios/etc/nagios.cfg) under section cfg_file or cfg_dir
How do i define then?
Nagios objects can be defined in a template format. Basic information about them is over here as object Definitions
Create one linux machine and add it to your monitoring using nagios
Create a linux vm (Using aws)
Since we have a new host now, lets add host definition Refer Here
Lets enable webserver.cfg in main nagios configuration
Nagios will not show new objects till we restart nagios. There is one catch here, if there is any mistake in object definition and if you to restart nagios, nagios will not start.
There is a way to verify your nagios configuration, which is referred as pre-flight check
Since preflight checks have passed, lets restart nagios
sudo systemctl restart nagios.service
So service is the check which we want to perform, so lets copy one simple service from localhost.cfg into webserver.cfg. Add this to your webserver.cfg
define service {
use local-service ; Name of service template to use
host_name webserver
service_description PING
check_command check_ping!100.0,20%!500.0,60%
}
Run preflight check and if it successful restart nagios and navigate to web page
So our next steps would creating object definitions from scratch, understanding inheritance.