| 1 | package Parse::Apache::ServerStatus::Extended; | ||
| 2 | |||
| 3 | use warnings; | ||
| 4 | use strict; | ||
| 5 | use Web::Scraper; | ||
| 6 | use base qw( Parse::Apache::ServerStatus ); | ||
| 7 | |||
| 8 | our $VERSION = '0.02'; | ||
| 9 | use 5.8.1; | ||
| 10 | |||
| 11 | sub parse { | ||
| 12 | my $self = shift; | ||
| 13 | my $content = $_[0] ? shift : $self->{content}; | ||
| 14 | return $self->_raise_error('no content received') unless $content; | ||
| 15 | |||
| 16 | my $table = scraper { | ||
| 17 | process 'table[border="0"] tr', | ||
| 18 | 'rows[]' => scraper { | ||
| 19 | process 'td', | ||
| 20 | 'values[]' => 'TEXT'; | ||
| 21 | } | ||
| 22 | }; | ||
| 23 | |||
| 24 | my @scraped; | ||
| 25 | for ( @{ $table->scrape($content)->{rows} } ) { | ||
| 26 | next unless $_->{values}; | ||
| 27 | my $stat = $_->{values}; | ||
| 28 | push @scraped, { | ||
| 29 | srv => $stat->[0], | ||
| 30 | pid => $stat->[1], | ||
| 31 | acc => $stat->[2], | ||
| 32 | m => $stat->[3], | ||
| 33 | cpu => $stat->[4], | ||
| 34 | ss => $stat->[5], | ||
| 35 | req => $stat->[6], | ||
| 36 | conn => $stat->[7], | ||
| 37 | child => $stat->[8], | ||
| 38 | slot => $stat->[9], | ||
| 39 | client => $stat->[10], | ||
| 40 | vhost => $stat->[11], | ||
| 41 | request => $stat->[12], | ||
| 42 | }; | ||
| 43 | } | ||
| 44 | |||
| 45 | return \@scraped; | ||
| 46 | } | ||
| 47 | |||
| 48 | 1; | ||
| 49 | __END__ |