Possible bug since 3.0.rc3 - ending lines with backslashes?
Andreas Ericsson
ae at op5.se
Fri Oct 17 15:23:28 CEST 2008
Christopher House wrote:
> 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.
>
You can't avoid that. Line continuation is here to stay. See below though.
> 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
> }
>
>
> Any help or guidance would be appreciated!
>
sed -i 's/\\$//' $(sed -i 's/^cfg_file=//' /path/to/nagios.cfg)
Then you can run whatever version you want. Note that it'll break your
configuration if you're using (intentional) line continuation in some
places though, and it won't work if you're using the cfg_dir statement
in your nagios.cfg. You might want to make a backup, now that I think
of it.
Sorry, but line continuation is here to stay. Unless you (or someone
else who's interested) ship a patch to disable it based on a config
option (or command-line option), your configuration in its current
state will never work with Nagios past 3.0rc2.
--
Andreas Ericsson andreas.ericsson at op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
-------------------------------------------------------------------------
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