Delete Parent Host without affecting Child
-
- Posts: 41
- Joined: Wed Sep 30, 2015 1:58 pm
Delete Parent Host without affecting Child
Hi All,
I am trying to delete the host which is no longer valid. But I can see the there lots of child host associated to it. Could someone guide me how could I delete parent which have no impact on child?
I am trying to delete the host which is no longer valid. But I can see the there lots of child host associated to it. Could someone guide me how could I delete parent which have no impact on child?
Re: Delete Parent Host without affecting Child
You would need to remove the relationship before deleting the parent, that way the child can remain. Nagios will not let you delete an object that still has a relationship established.
Former Nagios Employee
Re: Delete Parent Host without affecting Child
just search your configs for where that parent is declared and replace it automatically with nothing, then you can delete the parentpradeepanan wrote: Could someone guide me how could I delete parent which have no impact on child?
if you are using a config management tool it should do this automatically
Looking forward to seeing you all at #NagiosCon2019?
-Dedicated Lover of Nconf,PNP4Nagios and Nagvis
-Dedicated Lover of Nconf,PNP4Nagios and Nagvis
Re: Delete Parent Host without affecting Child
Thanks @nozlaf!
@pradeepanan - let us know if you have any further questions.
@pradeepanan - let us know if you have any further questions.
Former Nagios Employee
-
- Posts: 41
- Joined: Wed Sep 30, 2015 1:58 pm
Re: Delete Parent Host without affecting Child
Sorry for delayed response. I understood we need to remove relationship to delete paent. However my eventual goal is to delete and parent and assign all the child host to new parent. So is there a way to do that without editing each child host to point to new parent?
- Box293
- Too Basu
- Posts: 5126
- Joined: Sun Feb 07, 2010 10:55 pm
- Location: Deniliquin, Australia
- Contact:
Re: Delete Parent Host without affecting Child
A sed command would work.
Assuming the new parent exists, something like:
That command may very well replace the original host as well, you may need to go back and change it back to be correct.
sed is pretty powerful, make a copy of your configs and test/play with your configs before doing it in production. Depending on how many relationships you need to update, it might be quicker to manually do it compared to learning how to make the sed command work correctly.
Assuming the new parent exists, something like:
Code: Select all
sed -i 's/the_original_parent_name/the_new_parent_name/g' /usr/local/nagios/etc/*.cfg
sed is pretty powerful, make a copy of your configs and test/play with your configs before doing it in production. Depending on how many relationships you need to update, it might be quicker to manually do it compared to learning how to make the sed command work correctly.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
-
- Posts: 41
- Joined: Wed Sep 30, 2015 1:58 pm
Re: Delete Parent Host without affecting Child
Thats great. Thanks a lot. I did another thing which worked as well. Updated the database with new parent instead old one and did export. So editing *.cfg and database both same?
If am not wrong, when we do export, the database will be updated and it overrides the .cfg file with whatever new on the database. Is my understanding right?
If am not wrong, when we do export, the database will be updated and it overrides the .cfg file with whatever new on the database. Is my understanding right?
Re: Delete Parent Host without affecting Child
Could you please clarify? Core doesn't use a database at all, it uses flat files to organize configuration. If you're using ndo, then yes, the database will overwrite the configuration files.pradeepanan wrote:Thats great. Thanks a lot. I did another thing which worked as well. Updated the database with new parent instead old one and did export. So editing *.cfg and database both same?
If am not wrong, when we do export, the database will be updated and it overrides the .cfg file with whatever new on the database. Is my understanding right?
Former Nagios Employee
-
- Posts: 41
- Joined: Wed Sep 30, 2015 1:58 pm
Re: Delete Parent Host without affecting Child
Yes am using ndo. So when I do export from config tool, it will first update the database and then, the database will override the config file?
Re: Delete Parent Host without affecting Child
Could you please clarify what you mean by an 'export'? If you're making changes using the Core Config Manager, it will first update the database, which then on an apply configuration will write out FROM the database TO flat files.
Former Nagios Employee