Xymon Mailing List Archive search

xymon-rclient

7 messages in this thread

list Jeremy Laidman · Wed, 6 Aug 2014 20:40:10 +1000 ·
Hi

No, it only works through a shell running on the target device.

It sounds like what you want is prolly available with the http or post
content check built into Xymon. If the XML is sent via a post message then
you can define a "post" tag in hosts.cfg. Check out the "HTTP Tests"
section in the man page.
https://www.xymon.com/help/manpages/man5/hosts.cfg.5.html.

Or if you need more control over the content being sent (eg custom headers)
you can define your own protocol in protocols.cfg.
https://www.xymon.com/help/manpages/man5/protocols.cfg.5.html

Or for maximum flexibility, create an ext script to run on the Xymon server.

J
 On 06/08/2014 8:17 PM, "Rod Simioni" <user-bd98b55d9c4e@xymon.invalid> wrote:
Hi,

Can I use the xymon-rclient to send xml to the remote client -- actually a
virtual IP?

I don't need to login into the remote client, I just need to send xml via
http to the remote client and if the return data is good, then it is green,
if it is bad, it will be red.

Can it do this? Thanks in advance.

Rod
list Jeremy Laidman · Wed, 6 Aug 2014 22:16:33 +1000 ·
Firstly, please cc the mailing list. Secondly, best to upgrade to Xymon if
that's possible.

On 06/08/2014 9:54 PM, "Rod Simioni" <user-bd98b55d9c4e@xymon.invalid> wrote:
I'll need more flexiability because this xml requires custom headers,
etc. I've created a custom script -- I placed it in the /server/ext dir and
populated my :hobbitlaunch.cfg with
[foo]
   ENVFILE $BBTHOME/etc/hobbitserver.cfg
   CMD $BB/ext/myscript.sh
   LOGFILE $BB/logs/myscript.log
   INTERVAL 5m
I can't tell what your script does so I'm guessing that it has the target
server name hard coded.
I've placed 'foo' in the bb-hosts file for the bb server
This is not needed. Generally, test names in bb-hosts are used only by the
"network" tests (xymonnet or bbnet). Everything else uses their own
configurations, typically in-script variables or separate configuration
files. It's possible for a script to fetch it's configuration elements from
bb-hosts, but that's not very common, and requires the script to do some
extra work to get it. Again this is something I can't tell because I don't
know what your script is doing.
but I want to monitor the client-less vips. If I placed 'foo' next to my
client-less vips, it does nothing, do you have a clue?
The only place you need to define your test name is on the script that
sends the status message. Everything else is incidental or superfluous.
Even the [foo] in hobbitlaunch.cfg is arbitrary, and as long as its unique,
it can be any alphanumeric string of reasonable length.

There's no reason to list the test name in the bb-hosts file. Your script
needs to know the host name(s) it's going to test.

Can you show the script?

Have you user-27a96bc0cab9@xymon.invalid?

J
list Rod Simioni · Wed, 6 Aug 2014 09:30:03 -0400 ·
​Thanks for the reply and I will cc the group for now on. Let me tell you
my objective and if you still need to look at my script/log file, I will
fetch them.

This is basically what I want to do. For each ip address in my VIPs section
of the bb-host:
subpage vips VIPS
10.218.160.150   server1 #foo
10.218.160.150   server2 #foo

I want to send xml through this call:

wget --post-file=SentinelCompReport.xml --header="Content-Type: text/xml"
--header="SOAPAction: \"http://xxx.com/ComprehensivePersonSearch\""; -O -
http://VIP/BobService.asmx

and if the data returns as expected, then it is green.

How should I implement this?

Thanks in advance, sir.

Rod
​


On Wed, Aug 6, 2014 at 8:16 AM, Jeremy Laidman <user-71895fb2e44c@xymon.invalid>
quoted from Jeremy Laidman
wrote:
Firstly, please cc the mailing list. Secondly, best to upgrade to Xymon if
that's possible.

On 06/08/2014 9:54 PM, "Rod Simioni" <user-bd98b55d9c4e@xymon.invalid> wrote:
I'll need more flexiability because this xml requires custom headers,
etc. I've created a custom script -- I placed it in the /server/ext dir and
populated my :hobbitlaunch.cfg with
[foo]
   ENVFILE $BBTHOME/etc/hobbitserver.cfg
   CMD $BB/ext/myscript.sh
   LOGFILE $BB/logs/myscript.log
   INTERVAL 5m
I can't tell what your script does so I'm guessing that it has the target
server name hard coded.
I've placed 'foo' in the bb-hosts file for the bb server
This is not needed. Generally, test names in bb-hosts are used only by the
"network" tests (xymonnet or bbnet). Everything else uses their own
configurations, typically in-script variables or separate configuration
files. It's possible for a script to fetch it's configuration elements from
bb-hosts, but that's not very common, and requires the script to do some
extra work to get it. Again this is something I can't tell because I don't
know what your script is doing.
but I want to monitor the client-less vips. If I placed 'foo' next to my
client-less vips, it does nothing, do you have a clue?
The only place you need to define your test name is on the script that
sends the status message. Everything else is incidental or superfluous.
Even the [foo] in hobbitlaunch.cfg is arbitrary, and as long as its unique,
it can be any alphanumeric string of reasonable length.

There's no reason to list the test name in the bb-hosts file. Your script
needs to know the host name(s) it's going to test.

Can you show the script?

Have you user-27a96bc0cab9@xymon.invalid?

J
list Jeremy Laidman · Thu, 7 Aug 2014 00:39:11 +1000 ·
OK, so this is what I'd do.
subpage vips VIPS
10.218.160.150   server1 #foo
10.218.160.150   server2 #foo
The "foo" would not normally be needed, but let's assume that you want your
script to work out what hosts to probe. So we'll leave it in.
quoted from Rod Simioni
I want to send xml through this call:

wget --post-file=SentinelCompReport.xml --header="Content-Type: text/xml"
--header="SOAPAction: \"http://xxx.com/ComprehensivePersonSearch\""; -O -
http://VIP/BobService.asmx

I'd put this in a script like so:

#!/bin/sh

TESTNAME="foo"
REGEX="some regex"

do_fetch() {
    wget ... --header="SOAPAction: \"http://$1/ComprehensivePersonSearch\";
-O - http://$2/BobService.asmx
}

$BBHOME/bin/bbhostgrep foo | while read IP HOSTNAME OTHER; do
    if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then
        COL=green
        MSG="Test for $TESTNAME is OK"
    else
        COL=red
        MSG="Test for $TESTNAME failed"
    fi
    $BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"
done

This is from memory and hasn't been tested, but should give you the gist.

J
list Rodney Simioni · Wed, 6 Aug 2014 19:14:23 +0000 ·
Thank you Jeremy. Allow me to clarify a few things.

I'm not a good sh script guy so I might need you to hold my hand on a few things.

The actual wget call is:
 wget --post-file=SentinelCompReport.xml --header="Content-Type: text/xml" --header="SOAPAction: \"http://tlo.com/ComprehensivePersonSearch\""; -O - http://<some vip>/BobService.asmx

On the previous email, I put 'xxx.com' instead of tlo.com in the wget call because I didn't want to broadcast my domain name to the world but I don't mind anymore -- so every wget call with have "http://tlo.com/ComprehensivePersonSearch";
but on the last http url call it should have the vip of where I'm sending this xml to; for example "http://vip from bb-host file/BobServices.asmx"

So, If had this in my bb-host file:
10.218.160.150   server1 #foo
10.218.160.151   server2 #foo

The first wget call should look like:
 wget --post-file=SentinelCompReport.xml --header="Content-Type: text/xml" --header="SOAPAction: \"http://tlo.com/ComprehensivePersonSearch\""; -O - http://10.218.160.150/BobService.asmx

From your script, it said "wget ... --header="SOAPAction: \"http://$1/ComprehensivePersonSearch\"; -O - http://$2/BobService.asmx"; But I'm guessing since we don't need to change the url for "http://tlo.com/ComprehensivePersonSearch\";
we don't need the $1, correct?

Also, your script indicated "$BBHOME/bin/bbhostgrep foo | while read IP HOSTNAME OTHER; do" but HOSTNAME is not what I have defined in bb-hosts, I'm using aliases; for example, 10.218.160.150 is mapped to alias called server1 so I can't use
the alias for HOSTNAME because this command won't work "$BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG", am I correct to assume this?

So, if my assumptions are correct, how should I correct this script you wrote to reflect my environment. Thanks again, sir.

Rod
quoted from Jeremy Laidman


From: Xymon [xymon-bounces at xymon.com] on behalf of Jeremy Laidman [user-71895fb2e44c@xymon.invalid]
Sent: Wednesday, August 06, 2014 9:39 AM
To: Rod Simioni
Cc: xymon at xymon.com
Subject: Re: [Xymon] xymon-rclient


OK, so this is what I'd do.
subpage vips VIPS
10.218.160.150   server1 #foo
10.218.160.150   server2 #foo
The "foo" would not normally be needed, but let's assume that you want your script to work out what hosts to probe. So we'll leave it in.
I want to send xml through this call:

wget --post-file=SentinelCompReport.xml --header="Content-Type: text/xml" --header="SOAPAction: \"http://xxx.com/ComprehensivePersonSearch\""; -O - http://VIP/BobService.asmx
I'd put this in a script like so:

#!/bin/sh

TESTNAME="foo"
REGEX="some regex"

do_fetch() {
    wget ... --header="SOAPAction: \"http://$1/ComprehensivePersonSearch\"; -O - http://$2/BobService.asmx
}

$BBHOME/bin/bbhostgrep foo | while read IP HOSTNAME OTHER; do
    if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then
        COL=green
        MSG="Test for $TESTNAME is OK"
    else
        COL=red
        MSG="Test for $TESTNAME failed"
    fi
    $BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"
done

This is from memory and hasn't been tested, but should give you the gist.

J
list Jeremy Laidman · Thu, 7 Aug 2014 06:18:51 +1000 ·
quoted from Rodney Simioni
On 07/08/2014 5:14 AM, "Simioni, Rodney" <user-3ffedc1f4d0c@xymon.invalid> wrote:
The actual wget call is:
 wget --post-file=SentinelCompReport.xml --header="Content-Type:
text/xml" --header="SOAPAction: \"http://tlo.com/ComprehensivePersonSearch\"";
-O - http://<some vip>/BobService.asmx
On the previous email, I put 'xxx.com' instead of tlo.com in the wget
call because I didn't want to broadcast my domain name to the world
Sorry, I didn't mean to "out" you. ;-)
quoted from Rodney Simioni
but I don't mind anymore -- so every wget call with have "
http://tlo.com/ComprehensivePersonSearch";
but on the last http url call it should have the vip of where I'm sending
this xml to; for example "http://vip from bb-host file/BobServices.asmx"
Ah, I see.
quoted from Rodney Simioni
From your script, it said "wget ... --header="SOAPAction: \"http://$1/ComprehensivePersonSearch\";
-O - http://$2/BobService.asmx"; But I'm guessing since we don't need to
change the url for "http://tlo.com/ComprehensivePersonSearch\";
we don't need the $1, correct?
Correct.
Also, your script indicated "$BBHOME/bin/bbhostgrep foo | while read IP
HOSTNAME OTHER; do"

The labels "IP", "HOSTNAME" and "OTHER" are labels used by the "read"
command.  What "read" will do is to read one line from stdin and split it
on whitespace into 3 variables. (The output from the bbhostgrep command is
piped as stdin to the while loop to appear, one line at a time, as input to
"read".)  The 3 variables are dynamically created as per the names (ie $IP,
$HOSTNAME and $OTHER). We use OTHER to catch the rest of each line.

To understand a bit better, try this:

echo "a b c d e" | while read X Y Z; do echo "[$X][$Y][$Z]"; done

Then this:

cat /etc/hosts | while read X Y Z; do echo "[$X][$Y][$Z]"; done
quoted from Rodney Simioni
but HOSTNAME is not what I have defined in bb-hosts, I'm using aliases;
for example, 10.218.160.150 is mapped to alias called server1 so I can't use
the alias for HOSTNAME because this command won't work "$BB $BBDISP
"status $HOSTNAME.$TESTNAME $COL `date` $MSG", am I correct to assume this?

The value of $HOSTNAME will get the second word in the bb-hosts file. I
could have used X, Y, Z instead of IP, HOSTNAME, OTHER, but the code
wouldn't have been as readable.
quoted from Rodney Simioni
So, if my assumptions are correct, how should I correct this script you
wrote to reflect my environment.
I think you would just change the $1 to the domain in your URL. Something
like

    wget --post-file=SentinelCompReport.xml --header="Content-Type:
text/xml" --header="SOAPAction: \"http://tlo.com/ComprehensivePersonSearch\"";
-O - http://$2/BobService.asmx

J
list Adam Goryachev · Thu, 07 Aug 2014 09:34:19 +1000 ·
quoted from Jeremy Laidman
On 07/08/14 00:39, Jeremy Laidman wrote:
I'd put this in a script like so:

#!/bin/sh

TESTNAME="foo"
REGEX="some regex"

do_fetch() {
    wget ... --header="SOAPAction: 
\"http://$1/ComprehensivePersonSearch\"; -O - http://$2/BobService.asmx
}

$BBHOME/bin/bbhostgrep foo | while read IP HOSTNAME OTHER; do
    if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then
        COL=green
        MSG="Test for $TESTNAME is OK"
    else
        COL=red
        MSG="Test for $TESTNAME failed"
    fi
    $BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"
done

This is from memory and hasn't been tested, but should give you the gist.
Just a thought, couldn't this have used the cont check?

In any case, to explain the script to the OP, this line:
     $BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"

The HOSTNAME value is taken from the xymon hosts file, and used to tell 
xymon where to place the colored dot with this result.

Also, perhaps the following changes would be helpful:

     if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then

result=`do_fetch $HOSTNAME $IP`
if `echo "$result" | grep -q "$REGEX"`; then
         COL=green
         MSG="Test for $TESTNAME is OK

$result"
     else
         COL=red
         MSG="Test for $TESTNAME failed

$result"
fi

This may be useful to know what the actual value was when you got an 
error, or even what the actual value was when it changed from non-green 
to green. Of course, if $result is a large amount of data, then you may 
not want to display the full value, you can pass it through grep or 
other tools to reduce it down to a smaller/more useful amount of data.

Note, the above hasn't been tested at all, so watch for syntax or other 
errors, but hopefully it will be useful.

Regards,
Adam

-- 
Adam Goryachev Website Managers www.websitemanagers.com.au