Could not delete Host which has / in its name

19 views
Skip to first unread message

Dinesh Sc

unread,
Dec 8, 2016, 11:23:40 AM12/8/16
to nagrestconf-users
I configured and added some host and services its awesome.

When i added one host with name "Testio-ABC-DEV/IT-1481175032". After created this host i did not get any entries of the particular host in nagios but still i nagios can restart nagios and other hosts and services also working fine.

When i apply configuration using nrcq it throws Fail output. I tried to delete this host from GUI as well as nrcq command line, nrcq command line is giving SUCCESS output and GUI showing [sed: -e expression #1, char 31: extra characters after command,Success] like this but still host is not removed..

Can you help me to remove this host without making problem to nagrestconf?

Mark Clarkson

unread,
Dec 9, 2016, 4:04:44 AM12/9/16
to nagrestc...@googlegroups.com
Hi Dinesh,
So sorry you were hit by this bug :(

The following command should find and fix the file on the nagios/nagrestconf server:

sed -i 's#\(^[^,]*\)/#\1#' `find /etc/nagios*/ -name "*_hosts.setup" | grep '/setup/'`

After this is run, all should work. Read on to see how I got that line and why you got the error...

In the rest reference page (1), you will see fields with 'E' flags. Those fields can contain any character. Other fields cannot and the GUI should not allow it. I have re-opened bug #35 where someone had the same problem, with the same character!

You can read that issue (2) to see how to fix, but I will also paste my previous answer below:

------------------------------- snip -----------------------------------

I need to block this in the GUI, or allow it and fix it. The former is easier of course!


You'll need to edit the csv files manually to get rid of it.


I can't remember exactly the directory but if you do the following you will find the file to edit:


find /etc/nagios*/ -name "*_hosts.setup"

It should be in the setup/ directory, not last_known_good (or similar to that).


It's just a csv file so you can just delete the '/' character and all should be good.


------------------------------- snip -----------------------------------

The above assumes some linux command line knowledge. Here's what happened when I added host 'Testio-ABC-DEV/IT-1481175032' then tried the above to fix it:

# find /etc/nagios*/ -name "*_hosts.setup"
/etc/nagios3/objects/local/setup.known_good/local_hosts.setup
/etc/nagios3/objects/local/versions/local_hosts.setup
/etc/nagios3/objects/local/setup/local_hosts.setup
/etc/nagios3/objects/local/setup.known_good.new/local_hosts.setup

So, it was the third line. Isolate it with grep:

# find /etc/nagios*/ -name "*_hosts.setup" | grep '/setup/'
/etc/nagios3/objects/local/setup/local_hosts.setup

And now take the slash out of ALL the first fields. Use vim, emacs, nano etc, or sed (as shown):

sed -i 's#\(^[^,]*\)/#\1#' `find /etc/nagios*/ -name "*_hosts.setup" | grep '/setup/'`

Now you will be able to configure or delete the host in the GUI.

Dinesh Sc

unread,
Dec 9, 2016, 6:15:04 AM12/9/16
to nagrestconf-users
It worked.. Thanks Mark
Reply all
Reply to author
Forward
0 new messages