Hi
We have written a powershell script to take a CSV file and generate host and service config objects that we want to import into Nagios XI.
As a test we generate a file called:
<hostname>.cfg
The contents are:
define host {
host_name <hostname>
use <template name>
address <FQDN>
parents <host1>,<host2>
}
I put it in the /usr/local/nagios/etc/import folder. Then run the xiprepimport check against it. There is no output or change or new files created. I then import through the UI.
It errors with "Table for import definition '" is not available!".
There are now 2 <hostname>.cfg files. One in the import folder and another in the /etc parent folder. The one in the /etc folder contains the same information as the one in import folder.
"Apply Configuration" now is failing with an error "Could not register service (config file '/usr/local/nagions/etc/services/<hostname>.cfg',starting on line 30".
This is bizzare as there are no services assigned to that configuration, its just a host.
The file '/usr/local/nagions/etc/services/<hostname>.cfg' does not exist, and there is no such configuration in the dropdown for the services, so there is no way I can fix it from the UI.
The only option is to reverse to snapshot, so I am bit confused and unsure how to progress.
rgds
G
Importing Config Files
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Importing Config Files
Hi rexmundo,
If the configuration fails it will revert back to the last known good configuration. You can do this manually by going to Configure > CCM > Quick Tools > Configuration Snapshots. However, as long as you have files in the import directory, it will attempt to import those when you Apply Configuration.
Run the following tail command during the apply configuration to capture more details on the error and post them to the thread.
Then zip up the configuration files, and send them in PM message. Thanks, Benjamin
If the configuration fails it will revert back to the last known good configuration. You can do this manually by going to Configure > CCM > Quick Tools > Configuration Snapshots. However, as long as you have files in the import directory, it will attempt to import those when you Apply Configuration.
Run the following tail command during the apply configuration to capture more details on the error and post them to the thread.
Code: Select all
tail -f /usr/local/nagiosxi/var/cmdsubsys.log
Code: Select all
zip -r /tmp/nagiossupport.zip /usr/local/nagios/etc
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: Importing Config Files
Hi
thanks for the response.
Removing the file from the import folder indeed causes the commit to succeed.
Tailing the log file however produced no output at all.. just dots..
I started comparing the files with other hosts from the hosts folder. I knew my config is ok because I could create that host using that data using the API.
In the end it was the file encoding. Mine was UTF8 and Nagios didnt like it. I had to convert it to ASCII by opening it in VI and writing it using ++enc=ascii
Is there a way for Nagios to read UTF8 files?
thanks for the response.
Removing the file from the import folder indeed causes the commit to succeed.
Tailing the log file however produced no output at all.. just dots..
I started comparing the files with other hosts from the hosts folder. I knew my config is ok because I could create that host using that data using the API.
In the end it was the file encoding. Mine was UTF8 and Nagios didnt like it. I had to convert it to ASCII by opening it in VI and writing it using ++enc=ascii
Is there a way for Nagios to read UTF8 files?
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: Importing Config Files
HI,
--Benjamin
I believe there might be another issue here (possibly with the file itself), my default system is using ASCII, but if I change language (to Japanese) the configuration files will be written in UTF-8 character set and it is able to apply configuration and import config files in UTF-8 character set.Is there a way for Nagios to read UTF8 files?
--Benjamin
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Be sure to check out our Knowledgebase for helpful articles and solutions!