In the previous articles, we discussed how to install Nagios, how to install Nagios plugins, how to upgrade Nagios core and how to install Nagios client. Now in this article will discuss how to configure new clients in the Nagios server.
There are different configuration files Linux and Windows clients to add in nagios.
You need to go your configuration files path in the server which is /usr/local/nagios/etc/objects.
# cd /usr/local/nagios/etc/objects
Now run ll command you will the available configuration files here.
root@nagios-server:/usr/local/nagios/etc/objects# ls -l total 2600 -rw-r--r-- 1 root root 10961 Oct 20 09:50 commands.cfg -rw-r--r-- 1 root root 7358 Oct 20 09:50 contacts.cfg -rw-r--r-- 1 root root 1247988 Oct 21 06:51 localhost.cfg -rw-r--r-- 1 root root 3070 Oct 20 09:50 printer.cfg -rw-r--r-- 1 root root 3252 Oct 20 09:50 switch.cfg -rw-r--r-- 1 root root 11709 Oct 20 09:50 templates.cfg -rw-r--r-- 1 root root 3180 Oct 20 09:50 timeperiods.cfg -rw-r--r-- 1 root root 17779 Oct 20 09:50 windows.cfg root@nagios-server:/usr/local/nagios/etc/objects#
localhost.cfg is by default to add Linux hosts on it. Add these following lines to the file.
# vim localhost.cfg
Note: replace with your client-hostname and ipaddress
Now you defined host details. You also need to define host servers that you want to monitor. See the below screenshot.
How to add linux based client:
In the above configuration, we added CPU idle, PING, Root Partition and RAM usage services. You can also add extra services in the same format as tables, home partition, httpd etc.
Now check if configurations are correct or any errors are there with this command.
root@nagios-server:~# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg Nagios Core 4.4.6 Copyright (c) 2009-present Nagios Core Development Team and Community Contributors Copyright (c) 1999-2009 Ethan Galstad Last Modified: 2020-04-28 License: GPL Website: https://www.nagios.org Reading configuration data… Read main config file okay… Read object config files okay… Running pre-flight check on configuration data… Checking objects… Checked 1213 services. Checked 147 hosts. Checked 2 host groups. Checked 0 service groups. Checked 5 contacts. Checked 4 contact groups. Checked 36 commands. Checked 5 time periods. Checked 0 host escalations. Checked 0 service escalations. Checking for circular paths… Checked 147 hosts Checked 0 service dependencies Checked 0 host dependencies Checked 5 timeperiods Checking global event handlers… Checking obsessive compulsive processor commands… Checking misc settings… Total Warnings: 0 Total Errors: 0 Things look okay - No serious problems were detected during the pre-flight check
That’s it, restart nagios service and login to nagios in web and you can see your latest host and their services.