[Xymon] Server Script

Scot Kreienkamp Scot.Kreienkamp at la-z-boy.com
Wed Jul 6 18:05:40 CEST 2016


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.

From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Joshua Hunt
Sent: Wednesday, July 6, 2016 11:57 AM
To: Jeremy Laidman
Cc: xymon at xymon.com
Subject: Re: [Xymon] Server Script

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?

On Thu, Jun 30, 2016 at 12:59 PM, Jeremy Laidman <jlaidman at rebel-it.com.au<mailto:jlaidman at rebel-it.com.au>> wrote:
(Please cc to the list so others can help or learn.)
On Fri, 1 Jul 2016, 01:47 Joshua Hunt <joshuasocrates at gmail.com<mailto:joshuasocrates at gmail.com>> wrote:

Scot Kreienkamp  | Senior Systems Engineer | La-Z-Boy Corporate
One La-Z-Boy Drive | Monroe, Michigan 48162 | Office: 734-384-6403 | | Mobile: 7349151444 | Email: Scot.Kreienkamp at la-z-boy.com
 Here is the error I receive when I run using $XYMONHOME/server/bin/xymongrep :

/server/bin/xymongrep: No such file or directory

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.

Like:

$ xymoncmd /your/script

However, I have gone ahead and put in a manual path without using Xymon built in variables,

This is probably the cause of you're troubles.

and that seems to work just fine.

"Seems to", meaning with no error?

When I do that though, the majority of the script flat out doesn't run.

If the output of xymongrep is empty (either an error, or no matching lines) then the while loop body won't execute even once.

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.

Anything following "while read L" is skipped, so I'm assuming that my problem is ultimately lying in that line.

Yes, or the input to that line via the pipe is the problem.

HOSTTAG="tagname"
COLUMN="${HOSTTAG}"
$XYMONHOME/server/bin/xymongrep "${HOSTTAG}" | while read L
do

     set "$L"

     HOSTIP="$1"
     MACHINEDOTS="$2"

Try running this exact xymongrep command manually, after setting HOSTTAG and XYMONHOME, like:

$ HOSTTAG="tagname"
$ XYMONHOME=~xymon
$ $XYMONHOME/server/bin/xymongrep "${HOSTTAG}"

I suspect you'll get no output because xymongrep can't do what it needs because environment.

Then do the same but within a xymoncmd shell.

     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.

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.

Running your script under xymoncmd will setup these two variables for you.

On Thu, Jun 30, 2016 at 2:10 AM, Jeremy Laidman <jlaidman at rebel-it.com.au<mailto:jlaidman at rebel-it.com.au>> wrote:

Can you show the exact errors? Also, show the whole script?

On Thu, 30 Jun 2016, 01:16 Joshua Hunt <joshuasocrates at gmail.com<mailto:joshuasocrates at gmail.com>> wrote:
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.

HOSTTAG="tag"
COLUMN="$HOSTTAG"

# Here is where I get my first error. Directory apparently does not exist. However, later in the script
I source from a similar location and all works fine. I have manually checked, this location does exist.
$XYMONHOME/server/bin/xymongrep "$HOSTTAG" | while read L
do

_______________________________________________
Xymon mailing list
Xymon at xymon.com<mailto:Xymon at xymon.com>
http://lists.xymon.com/mailman/listinfo/xymon<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=>



This message is intended only for the individual or entity to which it is addressed.  It may contain privileged, confidential 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 us immediately by e-mail or by telephone at the above number. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20160706/f241d093/attachment.html>


More information about the Xymon mailing list