Help to dispaly slow log output

#!/usr/bin/php
<?php

$lrFpIn = fopen("php://stdin", 'r');

$lcDomain = '';
$laCount = $laTime = array();
while ($lcLine = trim(fgets($lrFpIn))) {
    $la = explode(' ', $lcLine);
    if ($lcDomain != $la[0]) {
        if ($lcDomain) {
            finish($lcDomain, $laCount, $laTime);
        }
        $lcDomain = $la[0];
        $laCount = $laTime = array();
    }
    $laCount[$la[1]]++;
    $laTime[$la[1]] += round($la[2]);
}
finish($lcDomain, $laCount, $laTime);

fclose($lrFpIn);

exit;

function finish($pcDomain , &$paCount, &$paTime) {
    arsort($paTime);
    reset($paTime);
    foreach ($paTime as $lcURL => $lnTime) {
        echo "$pcDomain ".$paCount[$lcURL]." $lnTime\n";
    }
}

?>



http://code.google.com/p/modlogslow/

 
Logged in as: Oszkár Kmetti
usefull/slowlog_helper.txt · Last modified: 2009.04.10 17:39 by oszi
 
Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki