Page 1 of 2
Import config not working
Posted: Mon Sep 15, 2014 2:52 pm
by mikemontreal
So anytime I import a host config file that I make changes to manually,I lose changes.
So I do the following
1-I make copy of hostabc.cfg to /usr/local/nagios/etc/hosts/example/hostabc.cfg
2- Edit file like change template name
3- Import with Overwrite Database checked
4- Apply config changes
5- All changes lost
I have also tried placing the updated config to the import folder with no luck.I must be doing something wrong??
Re: Import config not working
Posted: Mon Sep 15, 2014 2:59 pm
by Box293
Create the following folders:
Code: Select all
mkdir /usr/local/nagios/etc/cfgprep
mkdir /usr/local/nagios/etc/cfgprep/orig
Place your hostabc.cfg file into the orig directory and it should be left alone.
Check out this document:
http://assets.nagios.com/downloads/nagi ... p-Tool.pdf
Re: Import config not working
Posted: Mon Sep 15, 2014 3:17 pm
by mikemontreal
sorry for not being clear
I am using Nagiosxi config files,hosts that exist in my Nagiosxi already
hostabc.cfg < is a host in nagiosxi and I am simply making some manual changes.
The reason behind this is I need to change 100+ host cnnfig host template names so I just wanted to use the sed command
sed -i 's/qt_qa_xiwizard_windowsserver_host/qt_xiwizard_windowsserver_host/' ./*
and re-import new configs .
Like i said earlier so anytime I import a host config file that I make changes to manually,I lose the changes.
So I do the following
1-I make copy of a nagiosxi hostabc.cfg to /usr/local/nagios/etc/hosts/example/hostabc.cfg
2- Edit file
cd example/
sed -i 's/qt_qa_xiwizard_windowsserver_host/qt_xiwizard_windowsserver_host/' hostabc.cfg
3- Import through web gui with Overwrite Database checked
4- Apply config changes
5- All changes lost
Re: Import config not working
Posted: Mon Sep 15, 2014 3:32 pm
by Box293
Every time you Apply Configuration, your manual changes will be overwritten. All the settings are stored in CCM and the flat config files are pushed down from CCM.
That's why the files start with:
Code: Select all
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Date: 2014-09-15 10:31:13
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
If you must maintain the cfg files yourself, anything in /usr/local/nagios/etc/static/ is not touched by Apply Config.
To do what you want to do, copy the files to /usr/local/nagios/etc/cfgprep/orig/ first and then do your sed command. Then run the import tool.
Re: Import config not working
Posted: Mon Sep 15, 2014 4:09 pm
by mikemontreal
So I did as you said. But it seems to append changes and not replace??
Before import
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define host {
host_name host
use qt_qa_xiwizard_linuxserver_host
alias host
address host.qt.com
register 1
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
After import
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define host {
host_name host
use qt_qa_xiwizard_linuxserver_host,qt_xiwizard_linuxserver_host
alias host
address host.qt.com
register 1
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
cat orig/host.cfg
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define host {
host_name host
use qt_xiwizard_linuxserver_host
alias host
address host.qt.com
register 1
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
Re: Import config not working
Posted: Mon Sep 15, 2014 4:28 pm
by Box293
I've just tested what you've said and I've been able to reproduce the issue where it is appending the changes to the templates it's using instead of overwritting.
I'll look into this further and get back to you.
Re: Import config not working
Posted: Mon Sep 15, 2014 4:33 pm
by sreinhardt
It should essentially be overwriting that whole config upon import, not appending. It certainly looks like the template changes took, were you expecting just the qt_xiwizard_linuxserver_host template and not the qt_qa_xiwizard_linuxserver_host, template? Maybe I missed it in all that output, but could you post the full config before and after the modifications you are doing, this should be entirely outside of the idea of importing, just flat config files please.
Re: Import config not working
Posted: Tue Sep 16, 2014 8:35 am
by mikemontreal
Started with this
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define host {
host_name host
use qt_qa_xiwizard_linuxserver_host
alias host
address host.qt.com
register 1
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
What I would like to do is to replace qt_qa_xiwizard_linuxserver_host with qt_xiwizard_linuxserver_host on 100 + hosts cfgs
Example
###############################################################################
#
# Host configuration file
#
# Created by: Nagios Core Config Manager 2.2.0
# Version: Nagios 3.x config file
#
# --- DO NOT EDIT THIS FILE BY HAND ---
# Nagios CCM will overwrite all manual settings during the next update if you
# would like to edit files manually, place them in the 'static' directory or
# import your configs into the CCM by placing them in the 'import' directory.
#
###############################################################################
define host {
host_name host
use qt_xiwizard_linuxserver_host
alias host
address host.qt.com
register 1
}
###############################################################################
#
# Host configuration file
#
# END OF FILE
#
###############################################################################
Re: Import config not working
Posted: Tue Sep 16, 2014 10:24 am
by sreinhardt
Gotcha! As box mentioned, we have reproduced and submitted a bug, for this issue. Hopefully it gets resolved shortly, but we will post back when a patch is ready.
Re: Import config not working
Posted: Tue Sep 16, 2014 12:40 pm
by mikemontreal
Thank you for your time, I look forward to the patch.
Work around for now that I'm using is copy all host.cfgs to other location> delete all hosts and services and apply >make changes to copys>move back to /../nagios/etc/hosts/ > follow import doc