Page 1 of 1

No hosttemplates.cfg file. Config Error.

Posted: Tue Apr 08, 2025 8:39 am
by amelzer
I am extremely new to Nagios and am trying to get a number of servers added, but immediately ran into an issue. I followed the directions in: https://library.nagios.com/documentatio ... with-ncpa/ and verified that the host is reporting checks to the NCPA dashboard per step 4.

I used the Windows Server Configuration Wizard and got this error at the end: "Configuration Error. An error occurred while attempting to apply your configuration to the monitoring engine. Contact your Nagios administrator if this problem persists."

The Command Output of said Config Error reads:
Reading configuration data...
Read main config file okay...
Error: Template '' specified in host definition could not be not found (config file '/usr/local/nagios/etc/hosttemplates.cfg', starting on line 504)
Error: Template '' specified in host definition could not be not found (config file '/usr/local/nagios/etc/hosttemplates.cfg', starting on line 710)
Error processing object config files!

I checked the host server at C: > Program Files > Nagios > NCPA > etc, but there is no hosttemplates.cfg file, and the ncpa.cfg file only reaches 362 lines. The template assigned to the host in question is xiwizard_ncpa_host, which is set to Active. I tried the Config File Management > Delete Files > Write Files > Verify Files step suggested in another thread.

All hosts that were added to Nagios a year ago used one of the config wizards, many using xiwizard_ncpa_host as well.

This host shows up in Core Config Manager, but not on the dashboard.

Re: No hosttemplates.cfg file. Config Error.

Posted: Tue Apr 08, 2025 1:09 pm
by DoubleDoubleA
Hi @amelzer,

That error is related to the Nagios XI server, and not the server you are trying to monitor via NCPA.

Also, to clarify, you are not missing the config file itself. In two separate places in that file (hosttemplates.cfg) expected configuration settings are missing.

Nagios monitors things that are defined in config files. When the Nagios process starts up on your Nagios server, the Nagios process reads the files into memory and then monitors those things.

When you use a configuration wizard in the Nagios XI interface, there are a couple of intermediate steps in there but the end result is that the thing you just configured to monitor has its information added to the config files. Then the Nagios process gets restarted so the new configs are read in and the new thing is monitored.

For some reason, the hosttemplates.cfg is getting written out incorrectly, and so in the process of reading the files into memory, Nagios is stopping because something isn't right. It almost looks as though two templates don't have their names configured.

The configuration wizard is probably working as expected, but the database that contains the information from which the config files are written has bad data in two spots.

You could get to the command line on your Nagios XI server and open the /usr/local/nagios/etc/hosttemplates.cfg file and look at the things being configured immediately above and below lines 504 and 710.

What version of Nagios XI are you running?

Aaron

Re: No hosttemplates.cfg file. Config Error.

Posted: Wed Apr 09, 2025 6:48 am
by amelzer
System Info shows we are running NagiosXI Version 2024R1.4.1
I was able to find what I believe to be the running hosttemplates.cfg file:

# Hosttemplates configuration file
#
# Created by: Nagios CCM 3.1.9
# Date: 2025-04-08 09:11:41
# Version: Nagios Core 4.x

I searched for the wizard in question and found the following:

define host {
name xiwizard_ncpa_host
check_command check_xi_host_ping!3000.0!80%!5000.0!100%
use
register 0
}

Re: No hosttemplates.cfg file. Config Error.

Posted: Wed Apr 09, 2025 9:42 am
by DoubleDoubleA
Here's what I have in my hosttemplates.cfg file, with line numbers:

Code: Select all

    284 define host {
    285     name                            xiwizard_ncpa_host
    286     check_command                   check_xi_host_ping!3000.0!80%!5000.0!100%
    287     use                             xiwizard_generic_host
    288     register                        0
    289 }
As I compare your config to mine, my line 287 has xiwizard_generic_host where yours does not.

The important thing to know here is that editing this file will not help you, since XI re-writes these files all the time. What you want to do is go into the CCM, go to Templates, Host Templates, use the search function (just searching "ncpa" should bring it up) to find the xiwizard_ncpa_host template.

Once in that template, click on the Manage Templates button, and then click on the xiwizrd_generic_host and make sure it appears on the right.

The things you do in the CCM get added to the database, and when you apply configs, XI takes the database (which we just changed) and uses the configs in the database to write out all the .cfg files for Core to read. Which is why modifying the actual file won't help you.

Besides all that, the reason I directed you to the line numbers in the errors you got is because you have one more broken definition there, so you are going to want to go looking for that as well.

Worst case, after you change the xiwizard_ncpa_host, if you don't try to change the other one, in theory if you apply config it will not work, but it will also only reference one template in the hosttemplates.cfg file and give you the line number again, and you can find that one and fix it as well.

Re: No hosttemplates.cfg file. Config Error.

Posted: Fri Apr 11, 2025 6:44 am
by amelzer
xiwizard_generic_host was assigned, but inactive! Bless you. I activated it and ran the config again, got the green light and my pilot server is reporting to the host dash, pingable and checkable.