NCV RRD graphing for JSON values
I was hoping that Xymon's NCV parsing would understand JSON as the tutorial @ http://www.xymon.com/xymon/help/howtograph.html does not specify that the NCVs need to be on seperate lines (although I subsequently found that "man xymond_rrd" does). It's a shame because a lot of data is presented as JSON these days. For example, I have this test, which returns this: http://URLremoved/ - Testing URL <http://192.168.4.135:8080/tracker/co.do> yields:
{ u:1391595, rc:3517, asc:1628, usc:2154} I am using SPLITNCV and it just creates a testname,_u.rrd file.
I doubt it would involve a huge diff to get /xymond/rrd/do_ncv.c to understand this format. I also doubt that it is currently within my level of C programming proficiency though unfortunately.
Kind regards,
SebA
SebA,
You could get around around this problem by writing a simple script that calls the test and parses the result and splits it into lines to be sent to Xymon. For example, a basic Perl example:
Begin Script
my $result = test_that_returns_data;
($u, $rc, $asc, $usc) = split(',' $result);
$msg = "U : $u\n"; $msg .= "RC : $rc\n"; $msg .= "ASC: $asc\n"; $msg .= "USC: $usc";
xymon 127.0.0.1 \"status host.mytest green $msg\n\";
#End Script
In other words use the script to call the test (instead of Xymon) split the results on the comma and then build a new string with newline characters inserted. Your result reported to Xymon would be:
U : 1391595 RC : 3517 ASC: 1628 USC: 2154
... and easily read by Xymon's NCV.
Alternatly, you can also look at the section in the Xymon_RRD man page that discusses "Custom RRD Data Via Scripts". This would spell out how to do what you like. With that said, I have never tried it this route as it seems (from the man page) that it is more taxing than the method I showed above.
Michael Beatty Sherwin-Williams IT Analyst/Developer michael.beatty at sherwin.com 216-515-7374
On 01/22/2013 05:55 AM, SebA wrote:
I was hoping that Xymon's NCV parsing would understand JSON as the tutorial @ http://www.xymon.com/xymon/help/howtograph.html does not specify that the NCVs need to be on seperate lines (although I subsequently found that "man xymond_rrd" does). It's a shame because a lot of data is presented as JSON these days. For example, I have this test, which returns this: http://URLremoved/ - TestingURL <http://192.168.4.135:8080/tracker/co.do> yields: { u:1391595, rc:3517, asc:1628, usc:2154} I am using SPLITNCV and it just creates a testname,_u.rrd file. I doubt it would involve a huge diff to get /xymond/rrd/do_ncv.c to understand this format. I also doubt that it is currently within my level of C programming proficiency though unfortunately.
Kind regards,
SebA
Xymon mailing list Xymon at xymon.com http://lists.xymon.com/mailman/listinfo/xymon
Hi Michael,
Thanks for your suggestion and the example code. The problem is that the current test is a nopost test. So in order to use your script, I would also need to convert that and do something like [or perl equivalents]: call curl with the --data option, and then use grep to search for the strings I want to make sure are not in the result, and derive the colour for the status message from that. I presume your script below is a server-side Xymon script? I haven't written one before so I was a little reluctant to try and create one now. Ideally, I would want the regular expressions to remain in hosts.cfg (or analysis.cfg if/when tests get moved there in 5.0).
However, in this case, I have asked the developer to put some carriage returns into his JSON HTML display, so that looks like it will solve it, although the first rrd file is being created as _u instead of u. That's not too important. It looks like the rrd files are getting the correct data anyway now, so it is just the graphing to do. The example I found didn't work for me. This did:
DEF:p at RRDIDX@=@RRDFN@:lambda:AVERAGE LINE2:p at RRDIDX@#@COLOR@:@RRDPARAM@ GPRINT:p at RRDIDX@:LAST:@RRDPARAM@ \: %5.1lf%s (cur) GPRINT:p at RRDIDX@:MAX: \: %5.1lf%s (max) GPRINT:p at RRDIDX@:MIN: \: %5.1lf%s (min) GPRINT:p at RRDIDX@:AVERAGE: \: %5.1lf%s (avg)\n
I had to replace @RRDMETA@ with @RRDPARAM@ based on an old post.
Kind regards,
SebA
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of Michael Beatty Sent: 22 January 2013 13:19 To: xymon at xymon.com Subject: Re: [Xymon] NCV RRD graphing for JSON values
SebA,
You could get around around this problem by writing a simple script that calls the test and parses the result and splits it into lines to be sent to Xymon. For example, a basic Perl example:
Begin Script
my $result = test_that_returns_data;
($u, $rc, $asc, $usc) = split(',' $result);
$msg = "U : $u\n"; $msg .= "RC : $rc\n"; $msg .= "ASC: $asc\n"; $msg .= "USC: $usc";
xymon 127.0.0.1 \"status host.mytest green $msg\n\";
#End Script
In other words use the script to call the test (instead of Xymon) split the results on the comma and then build a new string with newline characters inserted. Your result reported to Xymon would be:
U : 1391595 RC : 3517 ASC: 1628 USC: 2154
... and easily read by Xymon's NCV.
Alternatly, you can also look at the section in the Xymon_RRD man page that discusses "Custom RRD Data Via Scripts". This would spell out how to do what you like. With that said, I have never tried it this route as it seems (from the man page) that it is more taxing than the method I showed above.
Michael Beatty
Sherwin-Williams
IT Analyst/Developer
michael.beatty at sherwin.com
216-515-7374 On 01/22/2013 05:55 AM, SebA wrote:
I was hoping that Xymon's NCV parsing would understand JSON as the tutorial @ http://www.xymon.com/xymon/help/howtograph.html does not specify that the NCVs need to be on seperate lines (although I subsequently found that "man xymond_rrd" does). It's a shame because a lot of data is presented as JSON these days. For example, I have this test, which returns this:
http://URLremoved/ - Testing URL <http://192.168.4.135:8080/tracker/co.do> yields:
{ u:1391595, rc:3517, asc:1628, usc:2154} I am using SPLITNCV and it just creates a testname,_u.rrd file.
I doubt it would involve a huge diff to get /xymond/rrd/do_ncv.c to understand this format. I also doubt that it is currently within my level of C programming proficiency though unfortunately.
Kind regards,
SebA
Xymon mailing list
Xymon at xymon.com
The only problem I have with my graph code below is that I can't alias the variable names to display something more informative in the graph legend. Is there a solution for this, or is this just a feature of SPLITNCV that one has to live with? I tried replacing the @variables@ with explicit values (one set of the lines below for each NCV variable), but the graph would not display...
Kind regards,
SebA
From: xymon-bounces at xymon.com [mailto:xymon-bounces at xymon.com] On Behalf Of SebA Sent: 22 January 2013 14:49 To: 'Michael Beatty'; xymon at xymon.com Subject: Re: [Xymon] NCV RRD graphing for JSON values
<snip>
However, in this case, I have asked the developer to put some carriage returns into his JSON HTML display, so that looks like it will solve it, although the first rrd file is being created as _u instead of u. That's not too important. It looks like the rrd files are getting the correct data anyway now, so it is just the graphing to do. The example I found didn't work for me. This did:
DEF:p at RRDIDX@=@RRDFN@:lambda:AVERAGE LINE2:p at RRDIDX@#@COLOR@:@RRDPARAM@ GPRINT:p at RRDIDX@:LAST:@RRDPARAM@ \: %5.1lf%s (cur) GPRINT:p at RRDIDX@:MAX: \: %5.1lf%s (max) GPRINT:p at RRDIDX@:MIN: \: %5.1lf%s (min) GPRINT:p at RRDIDX@:AVERAGE: \: %5.1lf%s (avg)\n
I had to replace @RRDMETA@ with @RRDPARAM@ based on an old post.
Kind regards,
SebA
<snip>
On 01/22/2013 05:55 AM, SebA wrote:
I was hoping that Xymon's NCV parsing would understand JSON as the tutorial @ http://www.xymon.com/xymon/help/howtograph.html does not specify that the NCVs need to be on seperate lines (although I subsequently found that "man xymond_rrd" does). It's a shame because a lot of data is presented as JSON these days. For example, I have this test, which returns this:
http://URLremoved/ - Testing URL <http://192.168.4.135:8080/tracker/co.do> yields:
{ u:1391595, rc:3517, asc:1628, usc:2154} I am using SPLITNCV and it just creates a testname,_u.rrd file.
I doubt it would involve a huge diff to get /xymond/rrd/do_ncv.c to understand this format. I also doubt that it is currently within my level of C programming proficiency though unfortunately.
Kind regards,
SebA
participants (2)
-
Michael.Beatty@sherwin.com
-
spah@syntec.co.uk