Possible bug since 3.0.rc3 - ending lines with backslashes?

Christopher House chouse at gmail.com
Thu Oct 16 20:39:09 CEST 2008


I am stuck on 3.0rc2 because of a change that seemed to have been made
between 3.0rc2 and rc3 with regards to the behavior for parsing
configuration lines that end with a backslash. The problem is
described in a post to nagios-devel back in February/2008 by Tobias
Klausmann (<klausman <at> schwarzvogel.de>) and I have copied it to
the end of this message for reference.

I have just downloaded 3.0.4 to see if this problem has been resolved
and it still remains. I was able to upgrade from Nagios 2.x to 3.0rc2
at the beginning of the year without issue but cannot upgrade past
3.0rc2 because of this behavior with the backslashes at the end of
config lines.


[nagios at licorice nagios-3.0.4]$ /usr/local/nagios-dev/bin/nagios -v
/usr/local/nagios-dev/etc/nagios.cfg

Nagios 3.0.4
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 10-15-2008
License: GPL

Reading configuration data...

Error: Unexpected token or statement in file
'/usr/local/nagios-dev/etc/objects/services/serviceext/EXCH02.cfg' on
line 4.

***> One or more problems was encountered while processing the config files...

     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.


Inspecting serviceext/EXCH02.cfg shows the problem is with line 2
which is commented out but ends with a backslash. If I remove the
offending backslash, the configuration parser will complain about a
line further down that also is commented-out and also ends with a
backslash. I've added the line numbers below for clarity for the
object with the first offending backslash.

1.
2. # ExtInfo for EXCH02, Disk S:\Restore\
3. define serviceextinfo{
4. 	host_name		EXCH02
5. 	icon_image		 dot.png' border="0"></a><A TARGET="_blank"
HREF="graphs.cgi?host=EXCH02&service=Disk S:\Restore\"><img
src='/nagios/images/logos/graph.png'
6. 	service_description	Disk S:\Restore\
7. }

If I remove all lines in the EXCH02.cfg file that end with a
backslash, the parser moves on and complains about a different file
that has similar lines that end with backslashes.

I have a lot of auto-generated serviceext files (courtesy of
nagiosgrapher) for services where I have set service_description's
that end with backslashes. I'd like to avoid having to change them all
if possible.

define service {
	use				default-service-template
	host_name			EXCH01, EXCH02
	service_description		Disk S:\Restore\
	servicegroups			EXCHdisks, WINDisks
	check_command			check_windows_diskfree_mountpoint!Restore!10!2
}

Once I clean up the files that the parser complains about unexpected
token or statement (the serviceext files), then it complains (but only
gives warnings) about the names of the services that have
service_descriptions that end with a backslash:

[nagios at licorice nagios-3.0.4]$ /usr/local/nagios-dev/bin/nagios -v
/usr/local/nagios-dev/etc/nagios.cfg

Nagios 3.0.4
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 10-15-2008
License: GPL

Reading configuration data...

Running pre-flight check on configuration data...

Checking services...
Error: The description string for service 'Disk S:\Restore
servicegroups  EXCHdisks, WINDisks' on host 'EXCH01' contains one or
more illegal characters.
Error: The description string for service 'Disk S:\SG1  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH01' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG2  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH01' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG3  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH01' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG4  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH01' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\Restore
servicegroups  EXCHdisks, WINDisks' on host 'EXCH02' contains one or
more illegal characters.
Error: The description string for service 'Disk S:\SG1  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH02' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG2  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH02' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG3  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH02' contains one or more
illegal characters.
Error: The description string for service 'Disk S:\SG4  servicegroups
        EXCHdisks, WINDisks' on host 'EXCH02' contains one or more
illegal characters.
        Checked 3716 services.
Checking hosts...
        Checked 447 hosts.
Checking host groups...
        Checked 34 host groups.
Checking service groups...
        Checked 71 service groups.
Checking contacts...
        Checked 16 contacts.
Checking contact groups...
        Checked 6 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 101 commands.
Checking time periods...
        Checked 154 time periods.
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:   10

***> 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.

Also, now that I've pasted this in to firefox, it points out that
'definition' is misspelled in the beginning of the error paragraph
above that begins "Check your configuration file(s) to ensure that
they contain valid directives and data defintions. "

Any help or guidance would be appreciated!


Original message from Feb/2008 (Thanks Tobias!)
-----
From: Tobias Klausmann <klausman <at> schwarzvogel.de>
Subject: Solved - still a bug but a different one; was Re: Possible
bug in 3.0rc3
Newsgroups: gmane.network.nagios.devel
Date: 2008-02-29 10:35:59 GMT (32 weeks, 6 days, 7 hours and 34 minutes ago)

Hi!

On Fri, 29 Feb 2008, Joerg Linge wrote:
> > Apparently, this line:
> >
> > service_perfdata_file_template=$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\t$TIMET$
>
> Works like a charm here with nagios 3.0rc3

I've found it after doing som rigorous debugging using
fopen/fprintf. I have to say that it's obscure and while Nagios
isn't at fault /per se/ (it does exactly what it's told to do),
it's a nast, nasty trap to fall into. It might be worthwhile to
consider fixing Nagios in this regard.

What happened was that I was playing around with different
settings for service_perfdata_file_template. In that process, I
ended up with this block of cfg file lines:

host_perfdata_file_template=[HOSTPERFDATA]\t$TIMET$\t$HOSTNAME$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$
# service_perfdata_file_template=[SERVICEPERFDATA]\t$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$
# service_perfdata_file_template=$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\
service_perfdata_file_template=$HOSTNAME$\t$SERVICEDESC$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\t$TIMET$

Can you spot the problem? If you do, congratulations, it took you
about six hours less than me. The problem is in the second to
last line: it ends with a \ - thus, logically, the following line
gets appended to it. Since the line containing the \ is a
comment, the last line vanishes entirely.

It might be a good idea to *not* interpret a \ at the end of
comment lines.

Regards,
Tobias


--
Christopher House
chouse at gmail.com

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/




More information about the Developers mailing list