[Xymon] Server Script

Joshua Hunt joshuasocrates at gmail.com
Wed Jul 6 17:56:34 CEST 2016


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>
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> wrote:
>
>>  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>
>> 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> 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
>>>> http://lists.xymon.com/mailman/listinfo/xymon
>>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20160706/7b2cbbdd/attachment.html>


More information about the Xymon mailing list