Error message with empty variable

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
ji330k
Posts: 4
Joined: Tue Apr 30, 2019 4:01 pm

Error message with empty variable

Post by ji330k »

Hi there,

We have a Nagios XI license, but it wouldn't let me post to the customer support forum for some reason. We're getting the following error when saving changes via Apply Configuration:
An error occurred while attempting to apply your configuration to Nagios Core. Monitoring engine configuration files have been rolled back to their last known good checkpoint.

Error: Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 375)
Line 375 of servicetemplates.cfg is the last line of the file (a comment). 'Verify Files' generates the following output:
Nagios Core 4.4.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-01-15
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 690 services.
Warning: Host 'DNS1' has no default contacts or contactgroups defined!
Warning: Host 'DNS2' has no default contacts or contactgroups defined!
<removed a few more default contact errors>
Checked 133 hosts.
Checked 12 host groups.
Checked 7 service groups.
Checked 17 contacts.
Checked 5 contact groups.
Checked 145 commands.
Checked 18 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 133 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 18 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 14
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check
Write Configs generates the following output:
Write host configurations ...
Configuration file: <removed>.cfg successfully written!
WARNING! Ghost host config detected! Removing the file cm-nexus.cfg
Host configuration files successfully written!

Write service configurations ...
Configuration file: linux-service.cfg successfully written!
WARNING! Ghost service config detected! Removing the file cm-nexus-bandwidth.cfg
Service configuration files successfully written!

Configuration file: hostgroups.cfg successfully written!
Configuration file: servicegroups.cfg successfully written!
Configuration file: hosttemplates.cfg successfully written!
Configuration file: servicetemplates.cfg successfully written!
Configuration file: timeperiods.cfg successfully written!
Configuration file: commands.cfg successfully written!
Configuration file: contacts.cfg successfully written!
Configuration file: contactgroups.cfg successfully written!
Configuration file: contacttemplates.cfg successfully written!
Configuration file: servicedependencies.cfg successfully written!
Configuration file: hostdependencies.cfg successfully written!
Configuration file: serviceescalations.cfg successfully written!
Configuration file: hostescalations.cfg successfully written!
Configuration file: serviceextinfo.cfg successfully written!
Configuration file: hostextinfo.cfg successfully written!
I've tried the Delete Files button and it results in the same error. I'm not sure how to proceed on troubleshooting this because it's not pointing me to an actual service definition template name (and it won't save any changes I make anyway because of the error).

Thanks,
Jordan
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Error message with empty variable

Post by tgriep »

Check this folder on the server for any files.

Code: Select all

/usr/local/nagios/etc/import/
If there are any files in it, remove them and see if the Apply Config runs without any errors.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ji330k
Posts: 4
Joined: Tue Apr 30, 2019 4:01 pm

Re: Error message with empty variable

Post by ji330k »

There's nothing in there unfortunately:

Code: Select all

[root@nagios-xi import]# ls -lah /usr/local/nagios/etc/import/
total 8.0K
drwxrwxr-x 2 apache nagios 4.0K Apr 12 10:52 .
drwxrwxr-x 8 apache nagios 4.0K Apr 30 14:26 ..
Thanks,
Jordan
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Error message with empty variable

Post by tgriep »

You can try this procedure on the server to see if you can fix the error.

Login to the XI GUI and go to the Core Config Manager
Under "Tools", click "Write Config Files" or if you are running a newer versions of XI, The menu is called "Config File Management"
Click the click the "Write" button, then the "Delete" button then click the "Write" button and then the "Verify" button
If you get any errors, resolve them and click on the "Delete" button, "Write", "Verify" until all of the errors are resolved.
Click the Apply Configuration link and click the "Apply Configuration" button only after ALL of the errors are resolved.

If you still get the service templates error, do this.
Go to the Core Config Manager > Service Templates menu.
Click on the View Config icon in the right hand of the menu on any of the templates.
That will bring up a new window showing all of the templates.
Copy all of the text and post it here so we can view it.

Another cause of this issue could be a corrupted MYSQL table or a setting for the MYSQL server that needs to be changed.

To repair the databases, run this as root.

Code: Select all

mysqlcheck -f -r -u root -pnagiosxi --all-databases --use-frm
When it is done, see if the Apply Config can run after fixing the config errors if any.

To check the MYSQL configs, I will need you to get the /etc/my.cnf file and all of the files in the /etc/my.cnf.d folder if they exist and upload them to the post.
And, run this so I can see what version of MYSQL the server is running.

Code: Select all

mysql -V
Let us know how it works out.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ji330k
Posts: 4
Joined: Tue Apr 30, 2019 4:01 pm

Re: Error message with empty variable

Post by ji330k »

Hi there,

I tried that procedure several times and unfortunately ended up back in the same place, and mysqlcheck reported that everything was OK. Here is the servicetemplates.cfg file: http://alwaysmanaged.com/files/dtv/serv ... es.cfg.txt

There was a ghost file error, and I thought that's what was causing the service template issue, but it seems that I was able to resolve the ghost file error. 'Write Configs' is now showing no issues, but 'Verify Files' reports the service template error, as follows:
Error: Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 375)

Nagios Core 4.4.3
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2019-01-15
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Error: Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 375)
Error processing object config files!


***> One or more problems was encountered while processing the config files...

Check your configuration file(s) to ensure that they contain valid
directives and data definitions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
'Whats New' section to find out what has changed.
If the servicetemplates.cfg looks correct, could we set up a time to work with you guys over remote desktop to resolve this? I also noticed that it appears we're running 5.6.1, but it says that there is an update available to go to 5.6.1 -- when trying to upgrade, it fails due to the above service template issue.

Thanks,
Jordan
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: Error message with empty variable

Post by tgriep »

Thanks for the servicetemplate.cfg file.

If you open it up and take a look starting at line 369, you will see the following

Code: Select all

define service {
    name                            xiwizard_nagiosxiserver_http_service
    use                             
    register                        0
}

define service {
    name                            xiwizard_nagiosxiserver_ping_service
    use                             
    register                        0
}
Both of those service templates have empty use options and that is causing the errors.

Go in to the Core Config Manager > Service templates and edit the xiwizard_nagiosxiserver_http_service template
Click the Manage Templates button and add the following template to it.

Code: Select all

xiwizard_generic_service
Save it and edit the xiwizard_nagiosxiserver_ping_service template
Click the Manage Templates button and add the following template to it.

Code: Select all

xiwizard_generic_service
Save it and Apply the Config.

The rest of the file looked OK to me but if any of the other template files error out, click on the View Config icon for them and post that here.
Be sure to check out our Knowledgebase for helpful articles and solutions!
ji330k
Posts: 4
Joined: Tue Apr 30, 2019 4:01 pm

Re: Error message with empty variable

Post by ji330k »

Thanks, that solved it! I could've sworn I checked for empty 'use' lines, but must've missed those. Cheers, appreciate your help.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Error message with empty variable

Post by scottwilkerson »

ji330k wrote:Thanks, that solved it! I could've sworn I checked for empty 'use' lines, but must've missed those. Cheers, appreciate your help.
Glad to hear it is resolved!

Locking thread
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked