Page 1 of 2

Problem - CCM has deleted some cfg files

Posted: Mon Sep 26, 2016 3:53 am
by redesgtt
I don't know why, CCM system has deleted a lot work I have done. I added a lot services and others configurations by console.

I always follow these steps:
- Add or change files in /usr/local/nagios/etc directories directly
- When I finish, I go across "Web UI" to "Verify Configuration", and so I verify no errors.
- After I go "Restart Nagios" and Web UI show me the changes has been done.

But now after the last step "- After I go "Restart Nagios" and Web UI show me the changes has been done." Nagios not show me the changes.
In "Configure" --> "Core Config Manager" "Services" there aren't things changed.

I try to fix this problem doing run "Apply Configuration", but has been worst. Nagios has deleted a lot of files !!

Before I run "Apply Configuration"

Code: Select all

[root@nagiosxi services]# pwd
/usr/local/nagios/etc/services
[root@nagiosxi services]# ll | wc -l
241

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
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 1805 services.
Checked 584 hosts.
Checked 72 host groups.
Checked 13 service groups.
Checked 21 contacts.
Checked 7 contact groups.
Checked 275 commands.
Checked 25 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 584 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 25 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

I run Apply Configuration:

Code: Select all

Write host configurations ...
WARNING! Ghost host config detected! Removing the file XXXXXX.cfg
WARNING! Ghost host config detected! Removing the file XXXXXX.cfg
WARNING! Ghost host config detected! Removing the file XXXXXX.cfg
WARNING! Ghost host config detected! Removing the file XXXXXX.cfg
Host configuration files successfully written!

Write service configurations ...
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.cfg
WARNING! Ghost service config detected! Removing the file XXXXXX.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 have changed original names cfg by XXXXXX )

Code: Select all

[root@nagiosxi services]# pwd
/usr/local/nagios/etc/services
[root@nagiosxi services]# ll | wc -l
164
241 - 164 = 77 files delete.

Code: Select all

Nagios Core 4.1.1
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-19-2015
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 1235 services.
Checked 580 hosts.
Checked 72 host groups.
Checked 13 service groups.
Checked 21 contacts.
Checked 7 contact groups.
Checked 274 commands.
Checked 25 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 580 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 25 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check


- Why Nagios has deleted my files?
- I have a backup of my "1805 services", "584 hosts" and "275 commands" CFG files. How can I "apply" the modified configuration in /usr/local/nagios/etc and apply to "Nagios UI"?

Re: Problem - CCM has deleted some cfg files

Posted: Mon Sep 26, 2016 11:30 am
by bwallace
Nagios XI is designed so that any modifications to object definitions must be done the via the UI, not manually, so what you are seeing is expected. Are you looking to import multiple config files into XI? If so, you can use the 'Config Import Tool" https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Re: Problem - CCM has deleted some cfg files

Posted: Tue Sep 27, 2016 1:27 am
by redesgtt
I simply was adding objects with the same form I used to do in Nagios Core. I hoped it could do it.

So what solution can you give me? I have the objects *.cfg files keep in /tmp/.
Could I add them without UI ?

Re: Problem - CCM has deleted some cfg files

Posted: Tue Sep 27, 2016 9:25 am
by lmiltchev
There are some options to use the CLI to manage your hosts and services in Nagios XI. Please, review the "Automated Host Management In Nagios XI" document below:
https://assets.nagios.com/downloads/nag ... gement.pdf

You can also use the new REST API in Nagios XI. From the Nagios XI web UI go to Help->Backend API Docs to review the documentation.

Another way would be the following: if you are confident that your configs don't contain any errors, you can simply place them in the "/usr/local/nagios/etc/import" directory, then run the "reconfigure_nagios.sh" script:

Code: Select all

cd /usr/local/nagiosxi/scripts
./reconfigure_nagios.sh
Lastly, if you would like to maintain your objects manually, similar to how it is done in Nagios Core, you can place your configs in the "/usr/local/nagios/etc/static" directory. For more information on the topic review our "Manual Config File Management" document below:
https://assets.nagios.com/downloads/nag ... ios-XI.pdf

Hope this helps.

Re: Problem - CCM has deleted some cfg files

Posted: Tue Sep 27, 2016 9:39 am
by bwallace
If you're making changes to a large amount of configs, then the Bulk Modifications Tool should work for you. The Bulk mod tool is a part of the Enterprise Edition license. If you did not purchase this then you can activate the trial which will let you use it
https://support.nagios.com/kb/article.php?id=165

Meanwhile, this doc explains exactly why you lose the config upon using CCM after manually editing files in /usr/local/nagios/etc
https://support.nagios.com/kb/article.php?id=161

Now if you really need to manually maintain config files it is entirely possible in XI to have all, or a portion of your config, stored in another directory (/usr/local/nagios/etc/static) so they will not be imported into the Nagios XI web configuration GUI. The doc below describes how it's done. If you do go this route, be careful not to create a duplicate host or service definition via the UI later on, when the definition already exists in the static directory as problems will ensue.
https://support.nagios.com/kb/article.php?id=160

**about using the "/usr/local/nagios/etc/import" directory as lmiltchev mentioned - be aware that the intention of the import folder is to bring new configs into the system, not to update existing configs. There is another forum thread discussing that

Re: Problem - CCM has deleted some cfg files

Posted: Wed Sep 28, 2016 3:58 am
by redesgtt
bwallace wrote:
lmiltchev wrote:
thanks a lot for reply. Yes, we have a Enterprise license.

The problem is that I have some services I have not been able still to add them to Nagios XI.

Its structure is follows:

Code: Select all

define service {
        host_name          Hosts1,Hosts2,!Hosts3,!Hosts4,!Hosts5,!Hosts6,!Hosts7,!Hosts8,!Hosts9,!Hosts10,!Hosts11,!Hosts12,!Hosts13,!Hosts14,!Hosts15,!Hosts16,!Hosts17,!Hosts18,!Hosts19,!Hosts20,!Hosts21,!Hosts22,!Hosts23,!Hosts24,!Hosts25,!Hosts26,!Hosts27,!Hosts28,!Hosts29,!Hosts30,!Hosts31,!Hosts32,!Hosts33,!Hosts34,!Hosts35,!Hosts36
        service_description               Service_
        hostgroup_name                   HostGroup1,HostGroup2,HostGroup3
        check_command                   check_XXXXX!90!95!!!!!!
        }
Well, When I try to add across UI, the first problem is not be able to put "hostnames negations".
I need to put them in this way because some Hosts included in "HostGroup1, 2 and 3" are used in others Services where isn't necessary put them in "Negation" style.
In Nagios Core there aren't problems with this "negations".

I thought this migth solve adding in "Service Management --> Misc Settings --> Manage Variable Definitions" the part of the "host_name" definition:

Code: Select all

        host_name          Hosts1,Hosts2,!Hosts3,!Hosts4,!Hosts5,!Hosts6,!Hosts7,!Hosts8,!Hosts9,!Hosts10,!Hosts11,!Hosts12,!Hosts13,!Hosts14,!Hosts15,!Hosts16,!Hosts17,!Hosts18,!Hosts19,!Hosts20,!Hosts21,!Hosts22,!Hosts23,!Hosts24,!Hosts25,!Hosts26,!Hosts27,!Hosts28,!Hosts29,!Hosts30,!Hosts31,!Hosts32,!Hosts33,!Hosts34,!Hosts35,!Hosts36
But "Variable value" hast a limit of 256 character (after "Apply Configuration", I see "hosts" are cut in the 256 character) and my "hosts" take up 336
Would it be possible to increase this limit? I haven't found it how.

If I could do it, I don't matter add and manage hosts, services, etc by UI, because all the problems I had when the migration Nagios Core to Nagios XI have been for these reasons. But in the future, when I have migrated them, I could use Nagios UI, but I am seeing some restrictions...

The solution of put things in "/usr/local/etc/import" and run "reconfigure_nagios.sh" is not viable for everything I just said. Furthermore I have tried and it doesn't work.
In the documentation that you have told me:
https://assets.nagios.com/downloads/nag ... 1456472706
is clearly:
" Importing a Configuration File - Service definitions should only be applied to a single host, not a host list or a hostgroup".

What can I do?
Regards

Re: Problem - CCM has deleted some cfg files

Posted: Wed Sep 28, 2016 11:02 am
by lmiltchev
The value field in the "tbl_variabledefinition" table is set to varchar(255). Verify this by running:

Code: Select all

echo 'desc tbl_variabledefinition;' | mysql -t -uroot -pnagiosxi nagiosql
Change it to text by running:

Code: Select all

echo 'ALTER TABLE tbl_variabledefinition MODIFY value TEXT NOT NULL;' | mysql -t -uroot -pnagiosxi nagiosql
Let us know if this fixed your issue.

FYI, I don't think you will be able to import exclusions by dumping your configs in the "import" directory, and running "reconfigure_nagios.sh".
In upcoming Nagios XI 5.3.0 (in about 2 weeks) you won't be able to import objects with exclusions (negations), but you will be able to set exclusions in the CCM.
example01.PNG

Re: Problem - CCM has deleted some cfg files

Posted: Wed Sep 28, 2016 11:35 am
by redesgtt
lmiltchev wrote:The value field in the "tbl_variabledefinition" table is set to varchar(255). Verify this by running:

Code: Select all

echo 'desc tbl_variabledefinition;' | mysql -t -uroot -pnagiosxi nagiosql
Change it to text by running:

Code: Select all

echo 'ALTER TABLE tbl_variabledefinition MODIFY value TEXT NOT NULL;' | mysql -t -uroot -pnagiosxi nagiosql
Let us know if this fixed your issue.

FYI, I don't think you will be able to import exclusions by dumping your configs in the "import" directory, and running "reconfigure_nagios.sh".
In upcoming Nagios XI 5.3.0 (in about 2 weeks) you won't be able to import objects with exclusions (negations), but you will be able to set exclusions in the CCM.
example01.PNG
Thanks a lot !!. I finally have been able to add more characters in value field :)

thanks for the last info. I am going to finish our import Core to XI before long. I often need to put "negatives" in differents objects when I add a new object. This will be able in next update or I will need put them in "Manage Variable Definitions" just like I do now?

Re: Problem - CCM has deleted some cfg files

Posted: Wed Sep 28, 2016 11:48 am
by lmiltchev
Yes, this functionality will be in Nagios XI 5.3.0. You will still be able to put them in "Manage Variable Definitions" if you wish. Let us know if it is OK to lock this topic and mark it as "resolved". Thanks!

Re: Problem - CCM has deleted some cfg files

Posted: Thu Sep 29, 2016 1:41 am
by redesgtt
Yes. For me is all OK.

Thanks a lot for your support.