[mrtg] Parsing HTML GUI
Mick
michaelkintzios at gmail.com
Fri Sep 5 00:29:01 CEST 2008
On Tuesday 02 September 2008, Mick wrote:
> On Tuesday 02 September 2008, McDonald, Dan wrote:
> > # OK, let's convert everything into an array, split on </td> boundaries
This is the regex part which now works as intended:
=====================================
if ($req->is_success) {
# print $req->content;
# OK, let's convert everything into an array, split on </td> boundaries
my @data = split(qw(</td>),$req->content);
# Then see if we can parse this into something somewhat usable
my ($index, at header,%content);
$index=0;
foreach my $datum (@data) {
if ( $datum =~ /columnheaderborder/) {
my ($head) = ($datum =~ />(.+?)$/);
push @header,$head;
next;
}
if ($datum =~ /nowrap="nowrap"/) {
my ($value) = ($datum =~ />(.+?)$/);
$content{$header[$index]} = $value;
$index++;
}
}
# assuming there weren't any extraneous headers,
# we should now have a hash indexed by the headers:
print "$content{'Max1'}\n$content{'Max2'}\n\n\n";
print "$content{'Mgn1'}\n$content{'Mgn2'}\n\n\n";
}
else {
die $response->status_line, "\n";
}
=====================================
and captures initial and current sync speeds and initial and current SNRM:
7520 7360 6.0 4.0
At the same time I would like to capture Time and CRCs and FECs, not to graph,
but tabulate on the MRTG page.
Time Line Rate Max1 Max2 Max3 Mgn1 Mgn2 Attn Pwr CRCs FECs
+003 days 15:45:48 1 7520 7520 7360 7264 6.0 4.0 38.0 20.2 17532 6041807
How should I do this?
--
Regards,
Mick
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://lists.oetiker.ch/pipermail/mrtg/attachments/20080904/00c41cd5/attachment.bin
More information about the mrtg
mailing list