use strict; use warnings; use Test::More tests => 31; use Parse::Apache::ServerStatus; my $status_auto = < Apache Status

Apache Server Status for localhost

Server Version: Apache/1.3.34 (Ubuntu)
Server Built: Mar 8 2007 00:01:35

Current Time: Monday, 27-Oct-2008 16:57:03 CET
Restart Time: Monday, 27-Oct-2008 16:56:55 CET
Parent Server Generation: 1
Server uptime: 8 seconds
1 requests currently being processed, 5 idle servers
W_____..........................................................
................................................................
................................................................
EOT my $status1e = < Server Built: Mar 8 2007 00:01:35

Current Time: Saturday, 13-Oct-2007 20:41:00 CEST
Restart Time: Saturday, 13-Oct-2007 20:30:09 CEST
Parent Server Generation: 0
Server uptime: 10 minutes 51 seconds
Total accesses: 239409 - Total Traffic: 1.7 MB
CPU Usage: u.32 s.21 cu0 cs0 - .0814% CPU load
368 requests/sec - 7.3 MB/second - 6.3 kB/request
1 requests currently being processed, 32 idle servers
___________W____........._________________......................
................................................................
................................................................
Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"L" Logging, "G" Gracefully finishing, "." Open slot with no current process

EOT my $status2 = < Apache Status

Apache Server Status for www.bloonix.de

Server Version: Apache/2.2.3 (Debian) mod_fastcgi/2.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c
Server Built: Mar 22 2008 09:29:10

Current Time: Monday, 27-Oct-2008 16:07:52 CET
Restart Time: Monday, 27-Oct-2008 16:07:46 CET
Parent Server Generation: 0
Server uptime: 6 seconds
1 requests currently being processed, 9 idle workers
W_________......................................................
................................................................
................................................................
................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

EOT my $status2e = < Apache Status

Apache Server Status for www.bloonix.de

Server Version: Apache/2.2.3 (Debian) mod_fastcgi/2.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c
Server Built: Mar 22 2008 09:29:10

Current Time: Monday, 27-Oct-2008 16:06:15 CET
Restart Time: Monday, 27-Oct-2008 15:34:41 CET
Parent Server Generation: 0
Server uptime: 31 minutes 33 seconds
Total accesses: 27 - Total Traffic: 3.8 mB
CPU Usage: u0 s0 cu0 cs0
.0143 requests/sec - 7.3 MB/second - 6.7 kB/request
1 requests currently being processed, 9 idle workers
W_________________..............................................
................................................................
................................................................
................................................................

Scoreboard Key:
"_" Waiting for Connection, "S" Starting up, "R" Reading Request,
"W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
"C" Closing connection, "L" Logging, "G" Gracefully finishing,
"I" Idle cleanup of worker, "." Open slot with no current process

EOT my $prs = Parse::Apache::ServerStatus->new(); my $ret = (); # testing apache auto $ret = $prs->parse($status_auto) or die $prs->errstr; ok($ret->{ta} == 0, "total accesses apache auto"); ok($ret->{r} == 2, "requests apache auto"); ok($ret->{i} == 10, "idles apache auto"); ok($ret->{W} == 2, "rest apache auto"); # testing apache auto extended $ret = $prs->parse($status_auto_e) or die $prs->errstr; ok($ret->{ta} == 5, "total accesses apache auto extended"); ok($ret->{r} == 2, "requests apache auto extended"); ok($ret->{i} == 10, "idles apache auto extended"); ok($ret->{W} == 2, "rest apache auto extended"); # testing apache v1 $ret = $prs->parse($status1) or die $prs->errstr; ok($ret->{ta} == 0, "total accesses apache"); ok($ret->{r} == 1, "requests apache"); ok($ret->{i} == 5, "idles apache"); ok($ret->{W} == 1, "rest apache"); # testing apache v1 extended $ret = $prs->parse($status1e) or die $prs->errstr; ok($ret->{ta} == 239409, "total accesses apache extended"); ok($ret->{tt} eq '1.7 MB', "total traffic apache extended"); ok($ret->{bs} eq '7654604.8', "bytes per second apache extended"); ok($ret->{br} eq '6451.2', "bytes per request apache extended"); ok($ret->{r} == 1, "requests apache extended"); ok($ret->{i} == 32, "idles apache extended"); ok($ret->{W} == 1, "rest apache extended"); # testing apache v2 $ret = $prs->parse($status2) or die $prs->errstr; ok($ret->{ta} == 0, "total accesses apache2"); ok($ret->{r} == 1, "requests apache2"); ok($ret->{i} == 9, "idles apache2"); ok($ret->{W} == 1, "rest apache2"); # testing apache v2 extended $ret = $prs->parse($status2e) or die $prs->errstr; ok($ret->{ta} == 27, "total accesses apache2 extended"); ok($ret->{tt} eq '3.8 mB', "total traffic apache2 extended"); ok($ret->{rs} eq '.0143', "requests per second apache2 extended"); ok($ret->{bs} eq '7654604.8', "bytes per second apache2 extended"); ok($ret->{br} eq '6860.8', "bytes per request apache2 extended"); ok($ret->{r} == 1, "requests apache2 extended"); ok($ret->{i} == 9, "idles apache2 extended"); ok($ret->{W} == 1, "rest apache2 extended");