<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=us-ascii"><meta name=Generator content="Microsoft Word 14 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-priority:99;
        mso-style-link:"Plain Text";
        font-family:"Calibri","sans-serif";}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span style='color:#1F497D'>I think I got the gist of things.  How about the attached?  It works for me.<o:p></o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='margin-left:.5in'><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Frost, Mark {BIS} [mailto:mark.frost1@pepsico.com] <br><b>Sent:</b> Monday, August 27, 2012 3:40 PM<br><b>To:</b> Nagios Developers List<br><b>Subject:</b> Re: [Nagios-devel] Call for configs<o:p></o:p></span></p></div></div><p class=MsoNormal style='margin-left:.5in'><o:p> </o:p></p><p class=MsoPlainText style='margin-left:.5in'><o:p> </o:p></p><p class=MsoPlainText style='margin-left:.5in'><o:p> </o:p></p><p class=MsoPlainText style='margin-left:.5in'>> -----Original Message-----<br>> From: Andreas Ericsson [<a href="mailto:ae@op5.se">mailto:ae@op5.se</a>] <br>> Sent: Monday, August 27, 2012 9:37 AM<br>> To: nagios-devel; <a href="mailto:Nagios-users@lists.sourceforge.net">Nagios-users@lists.sourceforge.net</a><br>> Subject: [Nagios-devel] Call for configs<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'><o:p> </o:p></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><…><o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><o:p> </o:p></p><p class=MsoPlainText style='margin-left:.5in'>> I've created a small scriptlet that will let you anonymize most of<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'>> your configuration, which can be downloaded from here:<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'>> <a href="http://dl.dropbox.com/u/83439435/scripts/nagios-anonymizer.sh"><span style='color:windowtext;text-decoration:none'>http://dl.dropbox.com/u/83439435/scripts/nagios-anonymizer.sh</span></a><o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>Andreas,<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>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.<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>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:<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>12c12<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>< if test "$#" -ne 2; then usage(); fi<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>---<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>> if test "$#" -ne 2; then usage; fi<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>to make it not error out.<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>The usage seems to indicate that I should be running it as<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>./nagios-anonymizer.sh /opt/nagios/core/bin/nagios /opt/nagios/core/etc/nagios.cfg<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>That runs OK and gets the vs-output file, but when it runs the sed line<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>sed -i "s/^cfg_.*/$ncpath/" > nagios.cfg<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>sed gives me a talkin’ to with<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>+ sed -i 's/^cfg_.*//opt/nagios/core/etc/nagios.cfg/'<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>sed: -e expression #1, char 12: unknown option to `s'<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'>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<o:p></o:p></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>sed -i "s#^cfg_.*#$ncpath#" $ncpath > nagios.cfg<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>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<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>cfg_dir=/opt/nagios/core/etc/oconf<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>with just<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>/opt/nagios/core/etc/nagios.cfg<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>(that doesn’t seem right to me either).  Perhaps the intent was to do something like<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:1.0in'><span style='font-size:10.0pt;font-family:"Courier New";color:black'>sed –i “s#^cfg_.*#$ncpath#” vs-output > nagios.cfg<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>?<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>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.<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>Oh, and perhaps rather importantly, you define “wkdir=” at the top, but then refer to “workdir” everywhere else in the file).<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'>Mark<o:p></o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><span style='color:black'><o:p> </o:p></span></p><p class=MsoPlainText style='margin-left:.5in'><o:p> </o:p></p></div></body></html>