Changed Hostname and Nagios puked on "&"?

Hey all. Not exactly new to web gui configurations, but never seen this problem before. I’m using v5.2.1 and attempted to change the host name of an entry from an IP Address (172.16.6.100) to a location (THE ALAMEDA & MISSION) on the Hosts config screen and it looked like it took it properly. But when I ran pre-flight on it it puked and gave me “Error: The name of host ‘THE ALAMEDA & MISSION’ contains one or more illegal characters.” Now I’m unable to delete the entry on the config screen, and have no idea how to resolve this issue.

First, I gotta say it’s pretty useless that a monitoring system can’t take certain characters in the host name, but really bad that the gui itself doesn’t warn you what will happen if you do use certain characters it doesn’t like.

Does anyone know what I can do short of backend mysql work? If nothing, what are the sql steps needed to delete the entry completely? Bear in mind I’ve never dealt with the unix back end but do have access to it if needed.

Rob

Hi,

what you could do is modify your nagios.cfg:
you will find an option named “illegal_object_name_chars” => remove the “&”;
that should directly solve your immediate problem … but I really don’t know the further consequences (ie: the answer to "why this character was deemed illegal ?)

Thanks, Loose. I’m a bit scared to delete that character without knowing what may happen to the rest of the app. Has anyone else been able to do this without causing any other problems?

rob

well; I’ve already deleted a few characters from the illegal list, and nothing happened so far :slight_smile:
I should say you can safely delete it (or you could try to set up a test nagios to check that nothing is happening).

Okay, you talked me into it. I did a ‘vi nagios.cfg’ and deleted the “&” character from the list – here’s what’s left below.

ILLEGAL OBJECT NAME CHARS

illegal_object_name_chars=`~!$%^*|‘"<>?,()’=

I then did a “:wq” and got this so it looks like it took:
“nagios.cfg” 308L, 7055C written

I then ran this a “service nagios restart” and got this:
root@access-02 etc# service nagios restart
Running configuration check…done
Shutting down nsca:
NSCA shutdown [OK]
Stopping network monitor: nagios

Starting network monitor: nagios
Nagios start complete
Starting nsca:
NSCA start complete [OK]

I’m assuming I need to do something else since when I go back int the web gui and run pre-flight I still get this error:
Checking hosts…
Error: The name of host ‘THE ALAMEDA & MISSION’ contains one or more illegal characters.

Total Warnings: 0
Total Errors: 1

***> One or more problems was encountered while running the pre-flight check…

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
‘Whats New’ section to find out what has changed.

Can someone point out what I’m missing so I can get this done? Thanks for all your help Loose.

rob

Well, if this didn’t work, I don’t know what to do;
you could try deleting the “&” in the name

if your interface doesn’t work, you can do it directly by editing the right file; the name (and the line) of the file should be written in the error message.

I just realized the nagios.cfg file is in 2 locations. Which one do I edit?

/usr/local/groundwork/nagios/etc/nagios.cfg
/usr/local/groundwork/monarch/workspace/nagios.cfg

I don’t know; it depends on your install :slight_smile:
it is probably this one: “/usr/local/groundwork/nagios/etc/nagios.cfg”, but to know for sure, you’ll have to open your nagios-daemon file to see which one it uses

First off, don’t be pretentious about a package you don’t know anything about. Nagios configs aren’t stored in SQL. If you even read 2 lines of documentation you would know that. Complain in the GroundWork forums.

Go to your /usr/local/groundwork/nagios/etc/hosts.cfg and remove the & from there, or whatever file groundwork is saving your hosts to. grep ALAMEDA

Oddly enough, when I get into that file I see nothing indicating the monitor I edited has anything different than any of the other monitors. Here’s the entry for that monitor I changed:

define host {
host_name 172.16.6.100
alias 172.16.6.100
address 172.16.6.100
use generic-host

This entry is identical to all other entries in that file so I’m still at a loss here. What specific file did I change when I edited the original “172.16.6.100” entry to “THE ALAMEDA & MISSION” in the web gui? I continue to see this error when preflighting:

Nagios 2.10
Copyright © 1999-2007 Ethan Galstad (nagios.org)
Last Modified: 10-21-2007
License: GPL

Reading configuration data…

Running pre-flight check on configuration data…

Checking services…
Checked 222 services.
Checking hosts…
Error: The name of host ‘THE ALAMEDA & MISSION’ contains one or more illegal characters.
Checked 222 hosts.
Checking host groups…
Checked 4 host groups.
Checking service groups…
Checked 0 service groups.
Checking contacts…
Checked 3 contacts.
Checking contact groups…
Checked 1 contact groups.
Checking service escalations…
Checked 0 service escalations.
Checking service dependencies…
Checked 0 service dependencies.
Checking host escalations…
Checked 0 host escalations.
Checking host dependencies…
Checked 0 host dependencies.
Checking commands…
Checked 177 commands.
Checking time periods…
Checked 4 time periods.
Checking extended host info definitions…
Checked 0 extended host info definitions.
Checking extended service info definitions…
Checked 222 extended service info definitions.
Checking for circular paths between hosts…
Checking for circular host and service dependencies…
Checking global event handlers…
Checking obsessive compulsive processor commands…
Checking misc settings…

Total Warnings: 0
Total Errors: 1

***> One or more problems was encountered while running the pre-flight check…

Check your configuration file(s) to ensure that they contain valid
directives and data defintions. If you are upgrading from a previous
version of Nagios, you should be aware that some variables/definitions
may have been removed or modified in this version. Make sure to read
the HTML documentation regarding the config files, as well as the
’Whats New’ section to find out what has changed.

In Control > Nagios Main Configuration screen, I edited the page 4 entry to allow the “&” character and no longer get the error when preflighting, but I still can not delete the “THE ALAMEDA & MISSION” entry on the Hosts page. In fact, when I attempt to edit the alias and IP information for that entry I get the following error:

Error(s): Please correct the following:
Error: insert into host_overrides values(NULL,NULL,NULL,NULL,NULL,’\n\n ') DBD::mysql::st execute failed: Column ‘host_id’ cannot be null at /usr/local/groundwork/monarch/lib/MonarchStorProc.pm line 659.

I got into that file and line 659 is the “$sth->execute()};” line below, and is greek to me. Does anyone see anything amiss that I should be aware of there?

ug);
return 1; # record with these values already exists; return immediately
}
}

    my $sqlstmt = "insert into $table values($valstr)";
    print STDERR "in insert_obj() sql is $sqlstmt]\n" if ($debug);
    my $sth = undef;
    eval{$sth = $dbh->prepare ($sqlstmt);
    $sth->execute()};
    if ($@) {
            $sth->finish;
            return "Error: $sqlstmt $@";
    } else {
            $sth->finish;
            return 1;
    }

}

Oooh, the ‘nagios-daemon’ file is another can of worms for this newb. Can you point me in the direction of where that would be located? Thanks!

rob

well, the “nagios-daemon” file would be the script that is called when you do a reload/restart in command line … but I don’t know if it helps you or not;
look for it in the “nagios-install-dir/bin” directory

considering how you’re getting stuck with this control panel … I’d say: get rid of it, and do everything by yourself by editing the config files with “vi” :slight_smile: