Deleting Hosts

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Deleting Hosts

Post by peter.zanetti »

I was curious about what goes on behind the scenes when deleting a host from the GUI. Does a script get called and delete the host or is it strictly deleting a row from the database?
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Deleting Hosts

Post by jolson »

When you delete a host from the Web GUI, you are removing it from the database on the backend. This database is used to write out the configuration files, which are actually used by Nagios. What this means is that the next time you run an 'Apply Configuration' from the Web GUI, the flat configuration file will be removed from your Nagios server.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Deleting Hosts

Post by peter.zanetti »

So if I wanted to delete a host through the command line is that doable or does it need to be through the database?
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Deleting Hosts

Post by tmcdonald »

It is doable but not something we can recommend doing.

When you delete a host, you are essentially deleting a row from the database. However, in the web interface when you delete a host there are a few checks that go on to ensure proper deletion is possible. If you try to delete a host that has services attached to it, or is a parent, or is a master in a dependency somewhere, or there are any other connections that the host is a part of, you will need to sever those connections first and the web interface will not allow deletion. This is to prevent your configs from becoming invalid, such as having a service for a host that no longer exists.

Though to answer your question directly, anything that can be done in the database can essentially be done through the CLI, you just use an echo statement to pipe your SQL commands into the mysql command, instead of logging in to mysql and using their frontend to run commands.
Former Nagios employee
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Deleting Hosts

Post by peter.zanetti »

So assuming a host has no dependencies of any kind besides being a member of a host group, is it as simple as deleting a row from the nagios_hosts table in the database?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Deleting Hosts

Post by lmiltchev »

We don't recommend modifying database directly. If you want to add/remove hosts/services from the command like, you can review the following document:

https://assets.nagios.com/downloads/nag ... gement.pdf
Be sure to check out our Knowledgebase for helpful articles and solutions!
peter.zanetti
Posts: 90
Joined: Wed Oct 01, 2014 8:34 am

Re: Deleting Hosts

Post by peter.zanetti »

thank you! I'll do some testing and let you know if I have any questions.
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Deleting Hosts

Post by tmcdonald »

And one thing to keep in mind, any tables that start with "nagios_" are part of the ndoutils database (named "nagios"), and will not reflect what files actually get written to disk and used. That's the CCM database (named "nagiosql"), and tables there begin with "tbl_". Big difference, and this is another part of why we cannot suggest direct manipulation. All too often we see people work with the wrong database and lose information they didn't want to.
Former Nagios employee
Locked