Discussion:
[Nagios-users] error when including resource.cfg
Andrew Edwards
2008-06-05 00:08:49 UTC
Permalink
I have been recently working on upgrading my nagios1.0 install to 3.0.2
and whenever I have my resources.cfg file included in the nagios.cfg
file I get
Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 37.

and line 37 is where I define $USER1$ is defined and I get this error on
every $USERx$ that is defined. I'm installing on freebsd7 from ports
and the only thing I found searching online is a reference to a
minimal.cfg but I don't know how to tell if that's my problem.

Thanks,
Andrew Edwards
Thomas Guyot-Sionnest
2008-06-05 02:27:03 UTC
Permalink
Post by Andrew Edwards
I have been recently working on upgrading my nagios1.0 install to 3.0.2
and whenever I have my resources.cfg file included in the nagios.cfg
file I get
Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 37.
and line 37 is where I define $USER1$ is defined and I get this error on
every $USERx$ that is defined. I'm installing on freebsd7 from ports
and the only thing I found searching online is a reference to a
minimal.cfg but I don't know how to tell if that's my problem.
I suggest you look for typos, misspelled macros, leading and trailing
spaces in there... Otherwise make a copy of it with non-sensitive data,
verify it still breaks and send it over (as attachment) for inspection.

Thomas
Andrew Edwards
2008-06-05 02:32:18 UTC
Permalink
I get the same result if I use the resource.cfg-sample provide with the
install.

$ nagios -v /usr/local/etc/nagios/nagios.cfg

Nagios 3.0.2
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL

Reading configuration data...

Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 26.


$ cat resource.cfg
########################################################################
###
#
# RESOURCE.CFG - Sample Resource File for Nagios 3.0.2
#
# Last Modified: 09-10-2003
#
# You can define $USERx$ macros in this file, which can in turn be used
# in command definitions in your host config file(s). $USERx$ macros
are
# useful for storing sensitive information such as usernames, passwords,
# etc. They are also handy for specifying the path to plugins and
# event handlers - if you decide to move the plugins or event handlers
to
# a different directory in the future, you can just update one or two
# $USERx$ macros, instead of modifying a lot of command definitions.
#
# The CGIs will not attempt to read the contents of resource files, so
# you can set restrictive permissions (600 or 660) on them.
#
# Nagios supports up to 32 $USERx$ macros ($USER1$ through $USER32$)
#
# Resource files may also be used to store configuration directives for
# external data sources like MySQL...
#
########################################################################
###

# Sets $USER1$ to be the path to the plugins
$USER1$=/usr/local/libexec/nagios

# Sets $USER2$ to be the path to event handlers
#$USER2$=/usr/local/libexec/nagios/eventhandlers

# Store some usernames and passwords (hidden from the CGIs)
#$USER3$=someuser
#$USER4$=somepassword

-----Original Message-----
From: Thomas Guyot-Sionnest [mailto:***@aei.ca]
Sent: Wednesday, June 04, 2008 10:27 PM
To: Andrew Edwards
Cc: Nagios-***@lists.sourceforge.net
Subject: Re: [Nagios-users] error when including resource.cfg

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Post by Andrew Edwards
I have been recently working on upgrading my nagios1.0 install to
3.0.2
Post by Andrew Edwards
and whenever I have my resources.cfg file included in the nagios.cfg
file I get
Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 37.
and line 37 is where I define $USER1$ is defined and I get this error
on
Post by Andrew Edwards
every $USERx$ that is defined. I'm installing on freebsd7 from ports
and the only thing I found searching online is a reference to a
minimal.cfg but I don't know how to tell if that's my problem.
I suggest you look for typos, misspelled macros, leading and trailing
spaces in there... Otherwise make a copy of it with non-sensitive data,
verify it still breaks and send it over (as attachment) for inspection.

Thomas
Morris, Patrick
2008-06-05 04:16:34 UTC
Permalink
Post by Andrew Edwards
-----Original Message-----
Sent: Wednesday, June 04, 2008 7:32 PM
To: Thomas Guyot-Sionnest
Subject: Re: [Nagios-users] error when including resource.cfg
I get the same result if I use the resource.cfg-sample provide with the
install.
$ nagios -v /usr/local/etc/nagios/nagios.cfg
Nagios 3.0.2
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL
Reading configuration data...
Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 26.
Have you, by any chance, told Nagios to load all files in /usr/local/etc/nagios using the cfg_dir directive, or told it to load it using the cfg_file directive rather than the resource_file one? That would cause the error you're seeing.
Andrew Edwards
2008-06-06 04:21:08 UTC
Permalink
I have in my nagios.cfg

cfg_dir=/usr/local/etc/nagios/objects/common
cfg_dir=/usr/local/etc/nagios/objects/mfg

but I do not include any parent dir's only these. I then tried copying
the resource.cfg file into the commond dir and I get the same problem.

Are there caviates to using the cfg_dir directive? I used to have
relatively large config files (80-100k) and I've found it very usefull
to break these up into many smaller files and I could include these one
by one but it's very handy to use the cfg_dir. I do need my $USERx$
macros's so how can I work-around this problem?

-----Original Message-----
From: Morris, Patrick [mailto:***@hp.com]
Sent: Thursday, June 05, 2008 12:17 AM
To: Andrew Edwards; Thomas Guyot-Sionnest
Cc: Nagios-***@lists.sourceforge.net
Subject: RE: [Nagios-users] error when including resource.cfg
Post by Andrew Edwards
-----Original Message-----
Sent: Wednesday, June 04, 2008 7:32 PM
To: Thomas Guyot-Sionnest
Subject: Re: [Nagios-users] error when including resource.cfg
I get the same result if I use the resource.cfg-sample provide with
the
Post by Andrew Edwards
install.
$ nagios -v /usr/local/etc/nagios/nagios.cfg
Nagios 3.0.2
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 05-19-2008
License: GPL
Reading configuration data...
Error: Unexpected token or statement in file
'/usr/local/etc/nagios/resource.cfg' on line 26.
Have you, by any chance, told Nagios to load all files in
/usr/local/etc/nagios using the cfg_dir directive, or told it to load it
using the cfg_file directive rather than the resource_file one? That
would cause the error you're seeing.
Marc Powell
2008-06-06 12:14:50 UTC
Permalink
Post by Andrew Edwards
I have in my nagios.cfg
cfg_dir=/usr/local/etc/nagios/objects/common
cfg_dir=/usr/local/etc/nagios/objects/mfg
but I do not include any parent dir's only these. I then tried copying
the resource.cfg file into the commond dir and I get the same problem.
Are there caviates to using the cfg_dir directive? I used to have
Yes -- They must only contain things that would otherwise be defined
as cfg_file in nagios.cfg. As Patrick pointed out, resource.cfg is not
one of those types of files.

--
Marc
Post by Andrew Edwards
-----Original Message-----
Have you, by any chance, told Nagios to load all files in
/usr/local/etc/nagios using the cfg_dir directive, or told it to load it
using the cfg_file directive rather than the resource_file one? That
would cause the error you're seeing.
Andrew Edwards
2008-06-06 13:41:57 UTC
Permalink
Okay, I see the problem now. I had specified resource.cfg as a cfg_file
instead of a resource_file.

Thanks for the help,
Andrew

-----Original Message-----
From: nagios-users-***@lists.sourceforge.net
[mailto:nagios-users-***@lists.sourceforge.net] On Behalf Of Marc
Powell
Sent: Friday, June 06, 2008 8:15 AM
To: Nagios Users Mailinglist
Subject: Re: [Nagios-users] error when including resource.cfg
Post by Andrew Edwards
I have in my nagios.cfg
cfg_dir=/usr/local/etc/nagios/objects/common
cfg_dir=/usr/local/etc/nagios/objects/mfg
but I do not include any parent dir's only these. I then tried copying
the resource.cfg file into the commond dir and I get the same problem.
Are there caviates to using the cfg_dir directive? I used to have
Yes -- They must only contain things that would otherwise be defined
as cfg_file in nagios.cfg. As Patrick pointed out, resource.cfg is not
one of those types of files.

--
Marc
Post by Andrew Edwards
-----Original Message-----
Have you, by any chance, told Nagios to load all files in
/usr/local/etc/nagios using the cfg_dir directive, or told it to load it
using the cfg_file directive rather than the resource_file one? That
would cause the error you're seeing.
------------------------------------------------------------------------
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nagios-users mailing list
Nagios-***@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when
reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
Continue reading on narkive:
Loading...