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" <rod.simioni at gmail.com> 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 looked at myscript.log?
J
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 <jlaidman at rebel-it.com.au> 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" <rod.simioni at gmail.com> 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 looked at myscript.log?
J
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
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
From: Xymon [xymon-bounces at xymon.com] on behalf of Jeremy Laidman [jlaidman at rebel-it.com.au] 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
On 07/08/2014 5:14 AM, "Simioni, Rodney" <rsimion at transunion.com> 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. ;-)
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.
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
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.
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
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" doneThis 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
participants (4)
-
jlaidman@rebel-it.com.au
-
mailinglists@websitemanagers.com.au
-
rod.simioni@gmail.com
-
rsimion@transunion.com