1 |
tdb |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
require CGI; |
4 |
|
|
|
5 |
|
|
my $query = new CGI; |
6 |
|
|
|
7 |
|
|
my ($grep) = $query->param('grep'); |
8 |
|
|
|
9 |
|
|
unless (defined $grep) { |
10 |
|
|
$grep = ""; |
11 |
|
|
} |
12 |
|
|
|
13 |
|
|
print "Content-type: text/html\n\n"; |
14 |
|
|
|
15 |
|
|
print <<"END"; |
16 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
17 |
|
|
|
18 |
|
|
<html> |
19 |
|
|
|
20 |
|
|
<head> |
21 |
|
|
<title>The i-scream Project Logfile Viewer</title> |
22 |
|
|
<meta name="description" content="The i-scream Project is a central |
23 |
|
|
monitoring system for Unix, Linux and NT servers."> |
24 |
|
|
<meta name="keywords" content="i-scream, project, central monitoring |
25 |
|
|
system, unix, linux, nt, server, alert"> |
26 |
|
|
<meta name="generator" content="notepad on acid, aye."> |
27 |
|
|
</head> |
28 |
|
|
|
29 |
|
|
<body bgcolor="#ffffff" link="#0000ff" alink="#3333cc" vlink="#3333cc" |
30 |
|
|
text="#000066"> |
31 |
|
|
|
32 |
tdb |
1.3 |
<a href="http://www.i-scream.org"><img border="0" src="/i-scream.gif"></a> |
33 |
tdb |
1.1 |
|
34 |
|
|
<form action="log.cgi" method="GET"> |
35 |
|
|
Complete listing of the server logfile. grep <input type="text" size="20" value="$grep" name="grep"> |
36 |
|
|
</form> |
37 |
|
|
<hr> |
38 |
|
|
<pre> |
39 |
|
|
END |
40 |
|
|
|
41 |
|
|
print_file("../www/server.log", $grep); |
42 |
|
|
|
43 |
|
|
print <<"END"; |
44 |
|
|
</pre> |
45 |
|
|
</body> |
46 |
|
|
|
47 |
|
|
</html> |
48 |
|
|
END |
49 |
|
|
|
50 |
|
|
exit 0; |
51 |
|
|
|
52 |
|
|
|
53 |
|
|
sub print_file ($$) { |
54 |
|
|
my ($filename, $grep) = @_; |
55 |
|
|
open(FILE, $filename) or die "Cannot open $filename: $!\n"; |
56 |
|
|
# Use $_ implicitly throughout. |
57 |
|
|
while (<FILE>) { |
58 |
|
|
# Must do the next line first! |
59 |
|
|
s/&/&/g; |
60 |
|
|
s/"/"/g; |
61 |
|
|
s/</</g; |
62 |
|
|
s/>/>/g; |
63 |
|
|
next unless (/$grep/); |
64 |
|
|
s/^(.{0})(.*core\.loggers\..*: started)$/<hr size=10 color=blue>$2/; |
65 |
tdb |
1.2 |
s/(.*)] (.*)}:(.*)/$1] <i>$2}<\/i>:<b>$3<\/b>/; |
66 |
tdb |
1.1 |
print; |
67 |
|
|
} |
68 |
|
|
} |
69 |
|
|
|