##
Sample HTML to use is as follows:
Profile
Function Name Calls Total Time Avg. Time
some.function 0 0 0
Cache Status
0 items cached, 0 cache hits, 0 cache misses (0.0%)
####
$htmlcontent =~ s/ //g; #remove tabs
$htmlcontent =~ s/<[^>]*>/,/g; #convert html tags into commas
$htmlcontent =~ s/,,/,/g; #Convert double commas to single
$htmlcontent =~ s/,\n,/\n/g; #remove leading and trailing commas around newlines
$htmlcontent =~ s/,Function Name,Calls,Total Time,Avg\. Time/Function Name,Calls,Total Time,Avg\. Time/g; #Clean up column headers
$htmlcontent =~ s/,Cache Status,\n//; #nuke the cache status line
$htmlcontent =~ s/Profile\n//; #nuke the profile line
$htmlcontent =~ s/\n+/\n/g; #delete blank lines
$htmlcontent =~ s/,\n//g; #nuke lines with a comma followed by a new line
$htmlcontent =~ s/^(?:.*\n){0,1}//; #remove first line
$htmlcontent =~ s/,$//g; #nuke that pesky last line
####
my $stats = $htmlcontent;
@rows = split(/\n/,$stats);
#Debug Line - prints the cleaned up data after dumping it to an array
#foreach (@rows) {
# print "ROW DATA : $_\n";
#}
#Make sure 'good' data is pulled
if ( $rows[0] !~ m/Function Name/ ) {
$np->nagios_exit("UNKNOWN", "Can't find csv header!\n");
exit $ERRORS{"UNKNOWN"}
}
my (undef,undef,@fields) = split(/\,/,shift @rows);
my %stats = ();
for my $r(@rows){
my ($pxname,$svname,@values) = split /\,/,$r;
for my $f(@fields){
$stats{$pxname}{$svname}{$f} = shift @values;
}
}