[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [cobalt-users] Re: Real time log monitoring script



That's great thanks!

Laszlo

-----Original Message-----
From: cobalt-users-admin@xxxxxxxxxxxxxxx
[mailto:cobalt-users-admin@xxxxxxxxxxxxxxx]On Behalf Of
BSmith@xxxxxxxxxxx
Sent: Wednesday, September 24, 2003 4:24 PM
To: cobalt-users@xxxxxxxxxxxxxxx
Subject: RE: [cobalt-users] Re: Real time log monitoring script


Here is a Start in PHP ... just need to change the file to 'read' for the
world though (limitation of PHP, as it runs as 'httpd').  If you change
"$filename", you can watch any log file, via the web, real time ... Easy to
change around to make it do whatever you want it to do.

<?php
ini_set("max_execution_time",3000000);
$filename = "/var/log/maillog";

$file_size = filesize($filename);

$fh = fopen($filename, 'r');
$myOutput = fread($fh, $file_size); 
$myOutput = str_replace("\n", "<br>\n", $myOutput); 
# Uncomment this line, if you want to see previous 
# output as well.
#print $myOutput;

# I used $c for debugging ... just keeps it 1=1, for 
# a continuous loop.
$c = 1;
while ( $c == 1 )
{
        clearstatcache();
        $tmpSize = filesize($filename);
        if ( $tmpSize  <> $file_size )
        {
                print "ok";
                $readBytes = $tmpSize - $file_size;
                $file_size = $tmpSize;
                $myOutput = fread($fh, $readBytes);
                print $myOutput;
                echo str_pad(" ", 256) . "<br>";
                flush();
                $c=1;
        }
} 
?>

That will print like a "tail -f" ... Developed by ME.  It works too.

_____________________________________
cobalt-users mailing list
cobalt-users@xxxxxxxxxxxxxxx
To subscribe/unsubscribe, or to SEARCH THE ARCHIVES, go to:
http://list.cobalt.com/mailman/listinfo/cobalt-users