<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=utf-8">
<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:12.0pt;
        font-family:"Times New Roman","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
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@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="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Unless your script is located at /script then you’re using the wrong path.  The path is the normal path you would use on the command line to execute it as a
 normal script from your shell.  If it’s in your current directory use xymoncmd ./script, just as you would any other time. 
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<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""> Xymon [mailto:xymon-bounces@xymon.com]
<b>On Behalf Of </b>Joshua Hunt<br>
<b>Sent:</b> Wednesday, July 6, 2016 11:57 AM<br>
<b>To:</b> Jeremy Laidman<br>
<b>Cc:</b> xymon@xymon.com<br>
<b>Subject:</b> Re: [Xymon] Server Script<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">How do I run my script under xymoncmd? I've tried both just using the command "xymoncmd /script" as well writing out the path to xymoncmd and pulling it directly from there, and neither way seems to be running my
 script in a xymon environment?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Thu, Jun 30, 2016 at 12:59 PM, Jeremy Laidman <<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>> wrote:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:.5in">
(Please cc to the list so others can help or learn.)<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Fri, 1 Jul 2016, 01:47 Joshua Hunt <<a href="mailto:joshuasocrates@gmail.com" target="_blank">joshuasocrates@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<p id="c1-id-6" style="FONT-FAMILY: Arial"><span id="c1-id-7" style="FONT-SIZE: 8pt; FONT-FAMILY: Calibri; LETTER-SPACING: normal"><strong id="c1-id-39"><span id="c1-id-41" style="font-size:9pt">Scot Kreienkamp  | Senior Systems Engineer | La-Z-Boy Corporate</span></strong><br id="c1-id-8">
</span><span id="c1-id-9" style="FONT-SIZE: 8pt; FONT-FAMILY: Calibri; LETTER-SPACING: normal">One La-Z-Boy Drive | Monroe, Michigan 48162 | Office: 734-384-6403 | | Mobile: 7349151444 | Email: Scot.Kreienkamp@la-z-boy.com</span></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal" style="margin-left:.5in"> Here is the error I receive when I run using $XYMONHOME/server/bin/xymongrep : <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">/server/bin/xymongrep: No such file or directory<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">The environment variable XYMONHOME isn't set.  Such scripts are usually run within a xymon environment. For testing, it's easiest to setup the environment by running xymoncmd.  You can either run xymoncmd with no
 arguments and use it as an interactive shell (and then run your script like you have been), or you can give your script to xymoncmd as an argument.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Like:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$ xymoncmd /your/script<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">However, I have gone ahead and put in a manual path without using Xymon built in variables,
</span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">This is probably the cause of you're troubles.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">and that seems to work just fine.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">"Seems to", meaning with no error?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">When I do that though, the majority of the script flat out doesn't run.
</span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">If the output of xymongrep is empty (either an error, or no matching lines) then the while loop body won't execute even once.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Note that xymongrep uses some xymon environment variables to do what it needs to do, so of you're not running it via xymoncmd or xymonlaunch, it might not be able to get any output for your script to use. At the
 very least, xymongrep needs HOSTCFG to be set to the path of the hosts.cfg file, according to the xymongrep man page.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">Anything following "while read L" is skipped, so I'm assuming that my problem is ultimately lying in that line.</span><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Yes, or the input to that line via the pipe is the problem.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">HOSTTAG="tagname"<br>
COLUMN="${HOSTTAG}"<br>
$XYMONHOME/server/bin/xymongrep "${HOSTTAG}" | while read L<br>
do<br>
<br>
     set "$L"<br>
<br>
     HOSTIP="$1"<br>
     MACHINEDOTS="$2"<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Try running this exact xymongrep command manually, after setting HOSTTAG and XYMONHOME, like:<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$ HOSTTAG="tagname"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$ XYMONHOME=~xymon<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$ <span style="font-size:10.0pt">$XYMONHOME/server/bin/xymongrep "${HOSTTAG}"</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">I suspect you'll get no output because xymongrep can't do what it needs because environment.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><span style="font-size:10.0pt">Then do the same but within a xymoncmd shell.</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">     MACHINE=$(echo $2 | $SED -e's/\./,/g')     # I am not sure what this line is for or what it entirely does. Under the impression it replaces periods with commas.<o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Yes that's correct. This is historical and harks back to the days of xymon's forerunner, BigBrother. MACHINEDOTS is the FQDN hostname with dots as normal, MACHINE is the same but with commas instead. Xymon doesn't
 care, but its the convention.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">Running your script under xymoncmd will setup these two variables for you.<o:p></o:p></p>
</div>
<div>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Thu, Jun 30, 2016 at 2:10 AM, Jeremy Laidman <<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>> wrote:<o:p></o:p></p>
<p style="margin-left:.5in">Can you show the exact errors? Also, show the whole script?<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-left:.5in">On Thu, 30 Jun 2016, 01:16 Joshua Hunt <<a href="mailto:joshuasocrates@gmail.com" target="_blank">joshuasocrates@gmail.com</a>> wrote:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<div>
<p class="MsoNormal" style="margin-left:.5in">So I'm trying to implement a server script, and I'm getting some errors with the beginning of my code, specifically the section that ties to Xymon. <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">HOSTTAG="tag"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">COLUMN="$HOSTTAG"<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"># Here is where I get my first error. Directory apparently does not exist. However, later in the script <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">I source from a similar location and all works fine. I have manually checked, this location does exist.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">$XYMONHOME/server/bin/xymongrep "$HOSTTAG" | while read L<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in">do<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in">_______________________________________________<br>
Xymon mailing list<br>
<a href="mailto:Xymon@xymon.com" target="_blank">Xymon@xymon.com</a><br>
<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.xymon.com_mailman_listinfo_xymon&d=CwMFaQ&c=4ttFxmcAQgEEq7frGXnTOw&r=dgAMwALqDvUPw6VAjJ-s-MTjfpII88afu0Wr5VfiVdI&m=sgyBG7KeudYlfqiRVqiaCYXUkj-BAQAc8ZSXn6KzGZ8&s=Tanxe_We47DT42mcY1WfvNPgN9rbmyDwNp_tUsJgu88&e=" target="_blank">http://lists.xymon.com/mailman/listinfo/xymon</a><o:p></o:p></p>
</blockquote>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</blockquote>
</div>
</div>
</div>
</div>
<p class="MsoNormal" style="margin-left:.5in"><o:p> </o:p></p>
</div>
</div>
<p id="c1-id-10" style="FONT-FAMILY: 'Arial Narrow'; LINE-HEIGHT: 14px"><span id="c1-id-11" style="FONT-FAMILY: Arial; COLOR: #000000"><span id="c1-id-12" style="FONT-SIZE: 8pt; LETTER-SPACING: normal"><span id="c1-id-13" style="FONT-SIZE: 8pt"><span id="c1-id-14" style="FONT-SIZE: 8pt">This
</span></span><span id="c1-id-15" style="FONT-SIZE: 8pt"><span id="c1-id-16" style="FONT-SIZE: 8pt">message</span><span id="c1-id-17" style="FONT-SIZE: 8pt"> is intended
</span></span><span id="c1-id-18" style="FONT-SIZE: 8pt"><span id="c1-id-19" style="FONT-SIZE: 8pt">only</span></span><span id="c1-id-20" style="FONT-SIZE: 8pt"><span id="c1-id-21" style="FONT-SIZE: 8pt"> for t</span></span><span id="c1-id-22" style="FONT-SIZE: 8pt"><span id="c1-id-23" style="FONT-SIZE: 8pt">he
 individual or entity to which it is addressed.  It may contain privileged, confi</span></span></span><span id="c1-id-24" style="FONT-SIZE: 8pt; LETTER-SPACING: normal"><span id="c1-id-25" style="FONT-SIZE: 8pt"><span id="c1-id-26" style="FONT-SIZE: 8pt">dential
 information which is exempt from disclosure under applicable laws.  If you are not the intended recipient, you are strictly prohibited from disseminating or distributing this information (other than to the intended recipient) or copying this information. 
 If you have received this communication in error, please notify </span></span></span><span id="c1-id-27" style="FONT-SIZE: 8pt; LETTER-SPACING: normal"><span id="c1-id-28" style="FONT-SIZE: 8pt"><span id="c1-id-29" style="FONT-SIZE: 8pt">us</span></span></span><span id="c1-id-30" style="FONT-SIZE: 8pt; LETTER-SPACING: normal"><span id="c1-id-31" style="FONT-SIZE: 8pt"><span id="c1-id-32" style="FONT-SIZE: 8pt">
 immediately by e-mail or by telephone at the above number.</span></span></span><span id="c1-id-33" style="FONT-SIZE: 8pt; LETTER-SPACING: normal"><span id="c1-id-34" style="FONT-SIZE: 8pt"><span id="c1-id-35" style="FONT-SIZE: 8pt"> Thank you</span></span></span></span><span id="c1-id-36" style="FONT-SIZE: 8pt; FONT-FAMILY: Calibri; LETTER-SPACING: normal"><span id="c1-id-37" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Arial Narrow'"><span id="c1-id-38" style="FONT-SIZE: 8pt; FONT-FAMILY: 'Arial Narrow'">.</span></span></span></p>
</body>
</html>