xymondboard - can I get an exact match? (and writing xymon ACK script and opening tickets)
I'm trying to write a local ack script and hitting a small snag with xymondboard
The basic idea is to query the board to get the cookie like so: ~/server/bin/xymon localhost 'xymondboard test=disk host=foo.example.com fields=cookie'
and then I can call a custom script from alerts.cfg that will open a ticket, and then ack the alert like so:
~xymon/server/bin/xymon --debug --response localhost "xymondack 488277 1440 this is a test ack"
One problem I'm having - not insurmountable but annoying - is that "test" does a substring match, so if I have two tests with similar names I get both:
[xymon at xymon1 ~]$ ~/server/bin/xymon localhost 'xymondboard test=disk host=foo.example.com fields=hostname,line1'
foo.example.com|hp_disk|green Tue Nov 13 21:03:11 EST 2012 foo.example.com|disk|yellow Tue Nov 13 21:03:07 EST 2012 - Filesystems NOT ok
In the above example I have a "disk" and an "hp_disk" test and I only want the disk test.
In this case I could also filter to only grab the yellow:
~/server/bin/xymon localhost 'xymondboard test=disk color=yellow host=foo.example.com fields=hostname,testname,line1' foo.example.com|disk|yellow Tue Nov 13 21:03:07 EST 2012 - Filesystems NOT ok
but that's not always going to work.
I can code around this but if there's a way to get the exact test, it'd be handy
thanks Betsy
On 14 November 2012 13:17, Betsy Schwartz <betsy.schwartz at gmail.com> wrote:
One problem I'm having - not insurmountable but annoying - is that "test" does a substring match, so if I have two tests with similar names I get both:
Try this:
~/server/bin/xymon localhost 'xymondboard test=\bdisk\b host= foo.example.com fields=cookie'
J
Regular expressions work:
~/server/bin/xymon localhost 'xymondboard test=^disk$ host=foo.example.com fields=cookie'
~David
-----Original Message----- From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Betsy Schwartz Sent: Tuesday, November 13, 2012 21:18 To: xymon at xymon.com Subject: [Xymon] xymondboard - can I get an exact match? (and writing xymon ACK script and opening tickets)
I'm trying to write a local ack script and hitting a small snag with xymondboard
The basic idea is to query the board to get the cookie like so: ~/server/bin/xymon localhost 'xymondboard test=disk host=foo.example.com fields=cookie'
and then I can call a custom script from alerts.cfg that will open a ticket, and then ack the alert like so:
~xymon/server/bin/xymon --debug --response localhost "xymondack 488277 1440 this is a test ack"
One problem I'm having - not insurmountable but annoying - is that "test" does a substring match, so if I have two tests with similar names I get both:
[xymon at xymon1 ~]$ ~/server/bin/xymon localhost 'xymondboard test=disk host=foo.example.com fields=hostname,line1'
foo.example.com|hp_disk|green Tue Nov 13 21:03:11 EST 2012 foo.example.com|disk|yellow Tue Nov 13 21:03:07 EST 2012 - Filesystems NOT ok
In the above example I have a "disk" and an "hp_disk" test and I only want the disk test.
In this case I could also filter to only grab the yellow:
~/server/bin/xymon localhost 'xymondboard test=disk color=yellow host=foo.example.com fields=hostname,testname,line1' foo.example.com|disk|yellow Tue Nov 13 21:03:07 EST 2012 - Filesystems NOT ok
but that's not always going to work.
I can code around this but if there's a way to get the exact test, it'd be handy
thanks Betsy
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
On 15 November 2012 01:36, Gore, David W (David) <david.gore at verizon.com>wrote:
Regular expressions work:
~/server/bin/xymon localhost 'xymondboard test=^disk$ host=foo.example.comfields=cookie'
Yeah, I would have thought so too, but this doesn't actually work (for me). When I use "test=ntp$" I get a match on both "ntp" and "ntpsync" tests. I'm guessing that the "test" keyword uses the pcre library with an option like PCRE_NOTEOL - because it does work (excludes "ntpsync") if I use "test=ntp\z" - but I can't find where in the code this is set. The same happens when I use a "host=" regular expression.
Cheers Jeremy
Sorry for the top posting, that is dictated by the company.
If it helps, using regular expressions in the Xymon command works fine under the latest version of Xymon 4.3.10 running on RedHat 5.8 32-bit with bash being the shell, pcre version is 6.6.
Here is a sample that works:
~/server/bin/xymon localhost 'xymondboard test=s$ host=(abc|xyz)myhost01'
Which shows all the tests that end with the letter 's' for the hosts abcmyhost01 and xyzmyhost01. Jeremy, may be you have an older version of Xymon? Seems odd
From: Jeremy Laidman [mailto:jlaidman at rebel-it.com.au] Sent: Wednesday, November 14, 2012 18:02 To: Gore, David W (David) Cc: betsy.schwartz at gmail.com; xymon at xymon.com Subject: Re: [Xymon] xymondboard - can I get an exact match? (and writing xymon ACK script and opening tickets)
On 15 November 2012 01:36, Gore, David W (David) <david.gore at verizon.com<mailto:david.gore at verizon.com>> wrote: Regular expressions work:
~/server/bin/xymon localhost 'xymondboard test=^disk$ host=foo.example.com<http://foo.example.com> fields=cookie'
Yeah, I would have thought so too, but this doesn't actually work (for me). When I use "test=ntp$" I get a match on both "ntp" and "ntpsync" tests. I'm guessing that the "test" keyword uses the pcre library with an option like PCRE_NOTEOL - because it does work (excludes "ntpsync") if I use "test=ntp\z" - but I can't find where in the code this is set. The same happens when I use a "host=" regular expression.
Cheers Jeremy
On 16 November 2012 02:30, Gore, David W (David) <david.gore at verizon.com>wrote:
Sorry for the top posting, that is dictated by the company.
and now seems to be the default on the interwebs. :-(
Here is a sample that works:
~/server/bin/xymon localhost 'xymondboard test=s$ host=(abc|xyz)myhost01'
Seems odd indeed! I'm also running version 4.3.10. Regular expressions (PCRE) aren't generally broken for me, but seems to be just this one thing. I can tie to the start of a string with a caret (^) but not to the end of a string with a dollar ($) - and this applies to both hostname and testname. I'm on SLESv10, 64 bit, using PCRE v6.4. Oddly, pcregrep doesn't have the same symptoms.
Here's an example, matching tests that ends with 's', much like yours:
~$ xymoncmd xymon localhost 'xymondboard test=s$ fields=testname'|head 2012-11-16 10:25:34 xgetenv: Cannot find value for variable 2012-11-16 10:25:34 Using default environment file /usr/lib/xymon/server/etc/xymonserver.cfg trends ntpsync files msgs ports procs disk ssh dns trends
This is obviously broken: it is matching an "s" anywhere, as if the "$" is missing. Yet pcregrep works with the same search string:
$ printf "trends\nntpsync\nfiles\ncpu\n" | pcregrep 's$' trends files
Using "\z" instead of "$" works.
Matching start of test/host with "^" works correctly.
I'm willing to accept that my build is somehow broken, but have no idea what to look for. It's not actually affecting me, and if it did, using "\z" is a perfectly acceptable work-around.
Regardless of my difficulties, Betsy, I'm hoping you managed to get the output you were looking for?
J
Top post here :)
Is it matching an 's', or is it just matching all tests defined in the config?
2012-11-16 10:25:34 xgetenv: Cannot find value for variable <<<<
2012-11-16 10:25:34 Using default environment file /usr/lib/xymon/server/etc/xymonserver.cfg trends ntpsync files msgs ports procs disk ssh dns trends
From: xymon-bounces at xymon.com [xymon-bounces at xymon.com] on behalf of Jeremy Laidman [jlaidman at rebel-it.com.au] Sent: Thursday, November 15, 2012 4:29 PM To: Gore, David W (David) Cc: xymon at xymon.com Subject: Re: [Xymon] xymondboard - can I get an exact match? (and writing xymon ACK script and opening tickets)
On 16 November 2012 02:30, Gore, David W (David) <david.gore at verizon.com<mailto:david.gore at verizon.com>> wrote: Sorry for the top posting, that is dictated by the company.
and now seems to be the default on the interwebs. :-(
Here is a sample that works:
~/server/bin/xymon localhost 'xymondboard test=s$ host=(abc|xyz)myhost01'
Seems odd indeed! I'm also running version 4.3.10. Regular expressions (PCRE) aren't generally broken for me, but seems to be just this one thing. I can tie to the start of a string with a caret (^) but not to the end of a string with a dollar ($) - and this applies to both hostname and testname. I'm on SLESv10, 64 bit, using PCRE v6.4. Oddly, pcregrep doesn't have the same symptoms.
Here's an example, matching tests that ends with 's', much like yours:
~$ xymoncmd xymon localhost 'xymondboard test=s$ fields=testname'|head 2012-11-16 10:25:34 xgetenv: Cannot find value for variable 2012-11-16 10:25:34 Using default environment file /usr/lib/xymon/server/etc/xymonserver.cfg trends ntpsync files msgs ports procs disk ssh dns trends
This is obviously broken: it is matching an "s" anywhere, as if the "$" is missing. Yet pcregrep works with the same search string:
$ printf "trends\nntpsync\nfiles\ncpu\n" | pcregrep 's$' trends files
Using "\z" instead of "$" works.
Matching start of test/host with "^" works correctly.
I'm willing to accept that my build is somehow broken, but have no idea what to look for. It's not actually affecting me, and if it did, using "\z" is a perfectly acceptable work-around.
Regardless of my difficulties, Betsy, I'm hoping you managed to get the output you were looking for?
J
On 16 November 2012 12:01, Tim McCloskey <tm at freedom.com> wrote:
Top post here :)
Is it matching an 's', or is it just matching all tests defined in the config?
Plenty of other tests on these hosts that are not shown, such as "cpu" and "conn". If I change the "s" to a "." then I get everything including cpu and conn.
J
Sort of figured as much, right after I clicked SEND. Still, there is a message about not being able to match the variable, but you already knew it did not match properly. I'm going back into my cave now :)
From: Jeremy Laidman [jlaidman at rebel-it.com.au] Sent: Thursday, November 15, 2012 5:24 PM To: Tim McCloskey Cc: Gore, David W (David); xymon at xymon.com Subject: Re: [Xymon] xymondboard - can I get an exact match? (and writing xymon ACK script and opening tickets)
On 16 November 2012 12:01, Tim McCloskey <tm at freedom.com<mailto:tm at freedom.com>> wrote: Top post here :)
Is it matching an 's', or is it just matching all tests defined in the config?
Plenty of other tests on these hosts that are not shown, such as "cpu" and "conn". If I change the "s" to a "." then I get everything including cpu and conn.
J
On 16 November 2012 12:01, Tim McCloskey <tm at freedom.com> wrote:
Top post here :)
2012-11-16 10:25:34 xgetenv: Cannot find value for variable <<<<
...and that's the answer. The "$" is being interpreted by xymoncmd as part of a non-existent variable, and so I end up with just "test=s". I don't think I can escape the dollar sign in xymoncmd.
It all works as advertised if I simply run the command without xymoncmd like so:
$ xymon localhost 'xymondboard test=s$ fields=testname'|head trends files msgs ports procs dns trends files msgs ports
Yay! mystery solved!
participants (4)
-
betsy.schwartz@gmail.com
-
david.gore@verizon.com
-
jlaidman@rebel-it.com.au
-
tm@freedom.com