Attached is a diff/patch of changes made to make the Monitorus plugin
work with the new system at mon.itor.us. I trimmed unused code (for the
most part).
-jeff
--- Monitorus-old.pm 2010-07-09 06:01:59.000000000 -0400
+++ Monitorus-new.pm 2011-03-29 16:20:02.000000000 -0400
@@ -52,43 +52,17 @@
my $site = 'http://mon.itor.us';
my $username = '[email protected]';
- my $target = $site.'/user/api/'.$username.'/secretpassword';
+ my $key = 'API_KEY_FROM_MONITORUS';
+ my $target = $site.'/api?apikey='.$key.'&output=xml&action=testsLastValues&locationIds=3';
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => "$target");
$req->header('Accept' => 'text/html'); #Accept HTML Page
- my $key;
- my $res = $ua->get($target);
- if ($res->is_success) {# Success....all content of page has been received
- $res->content() =~ m/\[CDATA\[(.*)\]\]/;
- $key = $1;
- } else {
- INFO("monitorus: Error in retrieving login page.");
- }
-
- $target = $site.'/test/api/'.$key.'/testNames';
- my $testid;
- $res = $ua->get($target);
- if ($res->is_success) {# Success....all content of page has been received
- $res->content() =~ m/<test id='(.*)'><!\[CDATA\[sitetest_http\]\]/;
- $testid = $1;
- } else {
- INFO("monitorus: Error in retrieving testNames page.");
- }
-
- #$target = $site.'/test/api/'.$key.'/testinfo/'.$testid.'/-240';
- #$target = $site.'/test/api/'.$key.'/test/'.$testid.'/27/5/2009/1/3/-240';
- $target = $site.'/test/api/'.$key.'/testsLastValues/1/3';
-
- my $result;
my $value;
- $res = $ua->get($target);
+ my $res = $ua->get($target);
if ($res->is_success) {# Success....all content of page has been received
- $res->content() =~ m/\<\/row\>\s*(\<row\>.*?sitetest_http.*?\<\/row\>)/s;
- $result = $1;
- $result =~ s/\<cell\>.*?CDATA.*?\<\/cell\>//g;
- $result =~ m|\<cell\>([0-9]*)\<\/cell\>|;
+ $res->content() =~ m/<name><!\[CDATA\[sitetest_http\]\]><\/name>\s*<performance>([^<]*)<\/performance>/s;
$value = $1;
} else {
INFO("monitorus: Error in retrieving testsLastValues page.");
_______________________________________________
collectd mailing list
[email protected]
http://mailman.verplant.org/listinfo/collectd