Call for configs

Andreas Ericsson ae at op5.se
Tue Aug 28 10:09:36 CEST 2012


On 08/27/2012 09:39 PM, Frost, Mark {BIS} wrote:
> 
> 
> 
> 
>> -----Original Message----- From: Andreas Ericsson
>> [mailto:ae at op5.se] Sent: Monday, August 27, 2012 9:37 AM To:
>> nagios-devel; Nagios-users at lists.sourceforge.net Subject:
>> [Nagios-devel] Call for configs
> 
> 
> 
> <...>
> 
> 
> 
>> I've created a small scriptlet that will let you anonymize most of
> 
>> your configuration, which can be downloaded from here:
> 
>> http://dl.dropbox.com/u/83439435/scripts/nagios-anonymizer.sh
> 
> 
> 
> Andreas,
> 
> 
> 
> I decided to give this a whirl to see what I wound up with and if it
> was something I felt I could send along.  As it turns out I'm having
> trouble getting this script to work right.  I've been trying to debug
> the script on our servers, but given that I'm not entirely certain
> what each step is supposed to be doing, it makes it difficult to
> figure out how to fix it.
> 
> 
> 
> First thing is that the bourne shell's I've got here (SLES Linux
> 11.1) don't like parens when you call a shell function so I needed to
> change:
> 
> 
> 
> 12c12
> 
> < if test "$#" -ne 2; then usage(); fi
> 
> ---
> 
>> if test "$#" -ne 2; then usage; fi
> 
> 
> 
> to make it not error out.
> 
> 
> 
> The usage seems to indicate that I should be running it as
> 
> 
> 
> ./nagios-anonymizer.sh /opt/nagios/core/bin/nagios
> /opt/nagios/core/etc/nagios.cfg
> 
> 
> 
> That runs OK and gets the vs-output file, but when it runs the sed
> line
> 
> 
> 
> sed -i "s/^cfg_.*/$ncpath/" > nagios.cfg
> 
> 
> 
> sed gives me a talkin' to with
> 
> 
> 
> + sed -i 's/^cfg_.*//opt/nagios/core/etc/nagios.cfg/'
> 
> sed: -e expression #1, char 12: unknown option to `s'
> 
> 
> 
> 
> 
> I'm assuming that I should use the GNU sed feature that allows me to
> use a different separator, but additionally, I don't see where
> there's an input file specified for sed either.   I changed it to
> 
> 
> 
> sed -i "s#^cfg_.*#$ncpath#" $ncpath > nagios.cfg
> 
> 
> 
> While that doesn't generate errors, it also doesn't generate anything
> in the nagios.cfg output file.  I'm not sure what this line is
> supposed to be doing.  It would appear that the intent is to replace
> a line in nagios.cfg like
> 
> 
> 
> cfg_dir=/opt/nagios/core/etc/oconf
> 
> 
> 
> with just
> 
> 
> 
> /opt/nagios/core/etc/nagios.cfg
> 
> 
> 
> (that doesn't seem right to me either).  Perhaps the intent was to do
> something like
> 
> 
> 
> sed -i "s#^cfg_.*#$ncpath#" vs-output > nagios.cfg
> 
> 
> 
> ?
> 
> 
> 
> Then it seems to just hang on the next sed line ("Processing object
> config files...") presumably because there's no input file there and
> it's try to read stdin.
> 
> 
> 
> Oh, and perhaps rather importantly, you define "wkdir=" at the top,
> but then refer to "workdir" everywhere else in the file).
> 
> 

Oh the shame. That's really embarrassing. I even tested it before I
broke it when polishing it up :-/

Many thanks. I've updated the script at the original location with
your fixed version.

-- 
Andreas Ericsson                   andreas.ericsson at op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231

Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/




More information about the Developers mailing list