23 November 2007

Content on log files via browser

I’ve a client that runs special program on about 100 servers. This program writes a log on central server every 3 minutes. So, when I checked main server, I found a directory Logs (C:\Logs). Log’s directory contains many log files (each log for each server). On this server installed and runs a web server, Apache ;). So, I’d like to show a small AppsRuns.php file, which stored on web server. If we go to the http://server1/AppsRuns.php we will see a content of each log file on one web page. This web page refreshing every 10 sec. Here is a content of AppsRuns.php file:

    $refresh_time = 10; // seconds
$path = "C:\LOGS";

header("Content-Type: text/plain");
header("Refresh: $refresh_time");


if($handle = opendir($path)) {
while (false !== ($file = readdir($handle))) {
$pi = pathinfo($path . '/' . $file);
if($pi['extension'] === 'txt') {
include($path . '/' . $file);
}
}
}
?>


Bookmark and Share ITStuff.ca

No comments:

Post a Comment