Page 2 of 2
Re: Missing host_name in service.cfg after update - riccardo
Posted: Thu Oct 19, 2017 2:32 pm
by tgriep
Try running this procedure to repair the MYSQL database and to rebuild the indexes.
Login to the server as root and run the following.
Code: Select all
service nagios stop
service ndo2db stop
killall -9 nagios
mysqlcheck -f -r -u root -pnagiosxi --use_frm --databases nagios nagiosql
service ndo2db start
service nagios start
Give the system a few minutes to run and see if the issue is still there.
Also, can you post this file from the Nagios server so I can check it's settings?
Let us know how it works out.
Re: Missing host_name in service.cfg after update - riccardo
Posted: Wed Oct 25, 2017 5:12 am
by diegobonfigli
Hi,
we found out the problem.
The short story is that we were restoring a configuration snapshot made on a pre-upgrade version, so the database schema was outdated (it lacked the "exclude" field in tbl_lnkServiceToHost table), the effect was that the "apply configuration" just skipped the host_name field in writing down the services file.
Isn't there a db consistency check that catch these situations before applying a configuration? If not, it could really save some headaches.
The long story: why were we restoring a snapshot made in a previous version? Because we updated nagios XI (manually), everithing seems to be ok but, again, "apply configuration" was giving a similar but different error:
Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 620)
Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 628)
Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line 1154)
And /usr/local/nagios/etc/servicetemplates.cfg had something similar to:
define service {
name xiwizard_oracleserverspace_service
use
check_command check_xi_oracleserverspace
register 0
}
note the "use" field empty, this was not only in the lines reported by the errors but in almost all the services.
After deep debug session we recognize that in the long past we rename the service called "xiwizard_generic_service" (the one usally with id 2) into something else (e.g. "TMP_srv_gen_noH24"), and the update scripts for some reason didn't like the new name (again, with a somewhat cryptic message).
So we restored the server as before the nagios XI update (we had a virtual machine snapshot), changed the name of service template "TMP_srv_gen_noH24" back to "xiwizard_generic_service" and applied again the update procedure, this time everything went fine.
The question now is: is changing default service names forbidden? Or is it a fault of the update scripts?
Re: Missing host_name in service.cfg after update - riccardo
Posted: Wed Oct 25, 2017 3:30 pm
by kyang
Thanks for posting up your resolution.
@riccardo.spisa, please update us.
When you say "we" are you connected with
@riccardo.spisa?
If you are not, then I would ask to create another thread if you have a different question.
How are you changing the default service names?
Are you using the bulk renaming tool? Located at --> XI home --> Configure --> Core Config Manager --> Under tools --> Bulk Renaming tool?
Or are you doing it another way?
Re: Missing host_name in service.cfg after update - riccardo
Posted: Thu Oct 26, 2017 4:08 am
by diegobonfigli
> When you say "we" are you connected with @riccardo.spisa?
yes, He's a collegue.
> How are you changing the default service names?
We had only changed the service template named "xiwizard_generic_service" (the one that come with the default installation, with id 2) to the new name "TMP_srv_gen_noH24" (a long time ago, well before the upgrade attempt), via CCM -> service tempates -> selected the template with id 2 -> template name.
> Are you using the bulk renaming tool? Located at --> XI home --> Configure --> Core Config Manager --> Under tools --> Bulk Renaming tool?
No, the bulk renaming tool was not used, we just changed back the name of the service template with id 2 to "xiwizard_generic_service" and the upgrade completed just fine.
If the service template with id 2 had the custom name "TMP_srv_gen_noH24", the update stopped with the errors (Template '' specified in service definition could not be not found (config file '/usr/local/nagios/etc/servicetemplates.cfg', starting on line xxx).
Note that many other service templates use the service template with id 2 (they have it in Manage Tempates -> assigned).
Re: Missing host_name in service.cfg after update - riccardo
Posted: Thu Oct 26, 2017 10:50 am
by kyang
Thanks for clarifying!
I see what you mean now, so you changed the name of the service template "xiwizard_generic_service" to --> "TMP_srv_gen_noH24"
In that case, I wouldn't change the xiwizard_generic_service template name, but create a new template for TMP-srv_gen_noH24 so there are no mix-ups.
Here's a kb article to explain templates a bit more.
https://support.nagios.com/kb/article.php?id=508
Nonetheless, your issue is solved and we're glad to see the update worked just fine now. Are we okay to close this thread?
Re: Missing host_name in service.cfg after update - riccardo
Posted: Fri Oct 27, 2017 4:11 am
by diegobonfigli
Yes, you can close the thread.
Re: Missing host_name in service.cfg after update - riccardo
Posted: Fri Oct 27, 2017 9:20 am
by kyang
Sounds great! I'll be closing this topic.
If you have any more questions, feel free to create another thread!
Thank you for using the Nagios Support Forum!