If you have not setup the Nagios Server have a look at that link to setup the Nagios server.
Configure Nagios to Monitor our first Host
I like to setup an isolated path for my custom host/service configigurations. First we will declare the configuration path for our servers.
Open up: /usr/local/nagios/etc/nagios.cfg
and add a new cfg_dir:
1
|
|
Now, create the directory:
1
|
|
Configure your email address for notifications in /usr/local/nagios/etc/objects/contacts.cfg
and configure:
1
|
|
Let’s say we want to configure a web server named web01 that sits at the location 10.10.10.10:
1
|
|
First we define our host configuration:
- We are using the
linux-server
template that is defined in/usr/local/nagios/etc/objects/templates.cfg
- We set the hostname, alias and address as well as notification prediods
1 2 3 4 5 6 7 8 9 10 |
|
While you have the config open, we want to define the services that we would like to monitor, and associate the services to the host that we defined.
In this example, we want to ping the server and check port tcp 22 and 80. Ensure that your web server is allowing the mentioned ports from the nagios server ip.
In the config, we are declaring the following:
- Use the
generic-service
template - Map the hostname which the service should be associated to
- The description that you will see in nagios
- Use the check_ping / check_ssh / check_http plugin and set the thresholds for ok, warning, critical
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
|
Save the config, test the config:
1
|
|
If you don’t see any errors, go ahead and restart to apply the configs:
1 2 |
|
Head over to nagios user interface at http://nagios-ip/nagios and you should see that the services are scheduled to be checked and should be reflecting in a minute or two.
Up Next
Next up, Setup the NRPE Server and Client to monitor remote systems using the nrpe plugin.