How do you do it?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
peakyblinder
Posts: 63
Joined: Tue Mar 25, 2014 4:39 am

How do you do it?

Post by peakyblinder »

Hi,

To note, I already have a Nagios Core server up and running, monitoring around 400 hosts and around 4000 services.
My server started out as a POC and never really got promoted to a proper production server and carried on as it is. So its the first build I did and now time to migrate to Nagios XI.

Anyway, I currently have all my hosts in their own .cfg files (400+). Each hosts file contains the services to monitor for that host. And of course, I have hostgroups and servicegroups configured and make use of templates.
Now, I'm pretty sure that each host having its own .cfg file with all its monitored services is not the best option. Especially when I want to migrate to Nagios XI and using the config import tool.

How do you guys setup your hosts/services? All hosts in one .cfg file and the same with services or...?

I know there is not a correct or wrong way but there are at least better ways so just wanted to see what the experts think.

Thanks,
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: How do you do it?

Post by cdienger »

Greetings,

XI stores hosts in seperate config files under /usr/local/nagios/etc/hosts. Each host then also has a config file for services under /usr/local/nagios/etc/services. Here's a directory listing of /usr/local/nagios/etc where all the cfg files are stored:

drwsrwsr-x 7 apache nagios 4.0K Apr 4 11:10 .
drwxr-xr-x 10 root root 4.0K Mar 24 16:39 ..
-rw-rw-r-- 1 apache nagios 828 Mar 31 16:33 cgi.cfg
-rw-rw-r-- 1 apache nagios 26K Apr 4 10:58 commands.cfg
-rw-rw-r-- 1 apache nagios 1.3K Mar 24 16:38 common.cfg
-rw-rw-r-- 1 apache nagios 1.1K Apr 4 10:58 contactgroups.cfg
-rw-rw-r-- 1 apache nagios 2.4K Apr 4 10:58 contacts.cfg
-rw-rw-r-- 1 apache nagios 1.7K Apr 4 10:58 contacttemplates.cfg
-rw-rw-r-- 1 apache nagios 817 Apr 4 10:58 hostdependencies.cfg
-rw-rw-r-- 1 apache nagios 819 Apr 4 10:58 hostescalations.cfg
-rw-rw-r-- 1 apache nagios 837 Apr 4 10:58 hostextinfo.cfg
-rw-rw-r-- 1 apache nagios 1.1K Apr 4 10:58 hostgroups.cfg
drwsrwsr-x 2 apache nagios 20K Apr 4 10:57 hosts
-rw-rw-r-- 1 apache nagios 16K Apr 4 10:58 hosttemplates.cfg
drwsrwsr-x 2 apache nagios 4.0K Apr 3 10:01 import
-rwxrwxr-x 1 apache nagios 5.6K Feb 17 09:27 nagios.cfg
-rwxrwxr-x 1 apache nagios 5.6K Mar 17 17:00 nagios.cfg.xi
-rwxrwxr-x 1 apache nagios 2.2K Mar 17 17:00 ndo2db.cfg
-rwxrwxr-x 1 apache nagios 4.8K Mar 17 17:00 ndomod.cfg
-rw-rw-r-- 1 apache nagios 11K Mar 24 16:33 nrpe.cfg
-rwxrwxr-x 1 apache nagios 5.3K Mar 17 17:00 nsca.cfg
-rwxrwxr-x 1 apache nagios 5.3K Mar 17 17:00 nsca.cfg.orig
drwsrwsr-x 4 apache nagios 4.0K Mar 31 14:37 pnp
-rwxrwxr-x 1 apache nagios 210 Feb 17 09:27 resource.cfg
-rwxrwxr-x 1 apache nagios 210 Mar 17 17:00 resource.cfg.xi
-rwxrwxr-x 1 apache nagios 1.6K Mar 17 17:00 send_nsca.cfg
-rwxrwxr-x 1 apache nagios 1.6K Mar 17 17:00 send_nsca.cfg.orig
-rw-rw-r-- 1 apache nagios 823 Apr 4 10:58 servicedependencies.cfg
-rw-rw-r-- 1 apache nagios 825 Apr 4 10:58 serviceescalations.cfg
-rw-rw-r-- 1 apache nagios 843 Apr 4 10:58 serviceextinfo.cfg
-rw-rw-r-- 1 apache nagios 813 Apr 4 10:58 servicegroups.cfg
drwsrwsr-x 2 apache nagios 4.0K Apr 4 09:27 services
-rw-rw-r-- 1 apache nagios 25K Apr 4 10:58 servicetemplates.cfg
drwsrwsr-x 2 apache nagios 4.0K Mar 31 14:37 static
-rw-rw-r-- 1 apache nagios 4.4K Apr 4 10:58 timeperiods.cfg
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: How do you do it?

Post by mcapra »

On quickstarts for XI, I generally recommend people group their machines into hostgroups with common services to monitor. For example, you might have a "windows-servers" hostgroup with all your common Windows service checks (cpu, memory, C: drive, etc) and a "linux-servers" hostgroup with all your common Linux service checks (cpu, memory, /root usage, etc).

That way, instead of defining a CPU check for each and every Linux host, you could define a CPU check once, assign it to the linux-servers hostgroup, then add all your Linux servers to that hostgroup. Your individual Linux servers would then inherit that hostgroup's associated CPU check service. Repeat as needed, and if servers have specific services you want to check, you can still assign them to individual hosts if you like.

The biggest timesave is identifying the common services, assigning them to a hostgroup (rather than an individual host), and grouping the necessary hosts into that hostgroup.

@box293 gave a wonderful talk at one of our previous conferences. Some of it is pretty specific to Nagios XI, but much if it also applies to Nagios Core:
https://www.youtube.com/watch?v=6WlZrG-_sAI&t=1317s
Former Nagios employee
https://www.mcapra.com/
Locked