/usr/share/netdisco/html/log.html is in netdisco-frontend 1.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 | <h1 class="pagehead">Log Entries</h1>
<FORM ACTION="<%$r->uri%>" METHOD="get">
<DIV>
<TABLE CLASS="log-ent">
<TR>
<TH>Class</TH>
<TH>Entry</TH>
<TH>View Log</TH>
<TH>Time Stamp</TH>
</TR>
<%perl>
my $odd = 0;
foreach my $class (sort keys %log_sort){
next unless grep(/^$class$/,@classes);
foreach my $l (sort {$b->{timestamp} <=> $a->{timestamp} }
@{$log_sort{$class}}
) {
my $uri = $r->uri;
my $time = localtime($l->{timestamp});
my $entry = $l->{entry};
my $logfile = defined $l->{logfile} ? 1 : 0;
# Make each nocdp log entry into links to device_search
if ($class =~ /(nocdp|timeout)/){
my @ret;
foreach my $nocdp (split / /, $entry){
push (@ret, "<A HREF=\"device.html?ip=$nocdp\">$nocdp</A>");
}
$entry = join(' ',@ret);
} elsif ($class =~ /(nosnmp)/){
my @ret;
foreach my $nosnmp (split / /, $entry){
push (@ret, "<A HREF=\"node.html?node=$nosnmp\">$nosnmp</A>");
}
$entry = join(' ',@ret);
}
my $details = $logfiles->{$l->{id}};
$odd++;
</%perl>
<TR>
<TD CLASS="match-<%$odd%2%>"><SPAN STYLE="white-space:nowrap"><% $l->{class} %></SPAN></TD>
<TD CLASS="match-<%$odd%2%>"><% $entry %></TD>
<TD CLASS="match-<%$odd%2%>">
<A CLASS="navbutton" HREF="<%$r->uri%>?log=<%$l->{id}%>&<%$r->args%>">X</A>
</TD>
<TD CLASS="match-<%$odd%2%>"><SPAN STYLE="white-space:nowrap"><% $time |h %></span></TD>
</TR>
% if ($details){
<TR>
<TD CLASS="match-<%$odd%2%>"> </TD>
<TD CLASS="entry-<%$odd%2%>" COLSPAN=3><PRE><%$details |h%></PRE></TD>
</TR>
% }
% }
%}
</TABLE>
<h2 class="subheader">Entry Types to Show</h2>
<TABLE class="log-key">
<TR>
<TD>
% foreach my $c (keys %$db_classes){
<%$c%>:<INPUT TYPE="checkbox" NAME="classes" VALUE="<%$c%>" <% grep(/^$c$/,@classes) ? 'CHECKED': ''%>>
%}
</TD>
</TR>
<TR>
<TD>Number of Entries per category:
<SELECT NAME="number">
% foreach my $num (1,5,10,20,30,40,50,60) {
<OPTION VALUE="<%$num%>" <% $number eq $num ? 'SELECTED' : '' %>><%$num%>
%}
</SELECT>
</TD>
</TR>
<TR>
<TD><INPUT TYPE="submit" CLASS="navbutton" VALUE="Show Entries"></TD>
</TR>
</TABLE>
</DIV>
</FORM>
<%args>
@classes => qw/arp discover mac netbios/
$number => 1
@log => ()
</%args>
<%shared>
my $logfiles = {};
</%shared>
<%init>
# Check for stuffing of non-numerics
$number = 5 unless $number =~ /^\d+$/;
my $db_classes = sql_column('log',['distinct(class)','true']);
my $log = [];
# Get the log entries we want
foreach my $class (@classes){
# Check for non existant
next unless defined $db_classes->{$class};
my $logs = sql_rows('log',
['id','extract(epoch from creation) as timestamp','class','entry','logfile'],
{'class' => $class},undef,
"order by timestamp desc limit $number");
push (@$log,@$logs);
}
# Get the Log Files if requested
foreach my $l (@log){
my $db_entry = sql_hash('log',['id','logfile'],{'id'=>$l});
unless (defined $db_entry){
$logfiles->{$l} = 'Not found in Database';
next;
}
my $file = $db_entry->{logfile};
# Uncompressed Log Files
if (-r $file){
$logfiles->{$l} = '';
my $ok = open (LOG, "<$file");
unless ($ok){
$logfiles->{$l} = "Couldn't open $file. $!\n";
next;
}
while (<LOG>){
$logfiles->{$l} .= $_;
}
close LOG;
# Gzipped Log Files
} elsif (-r "$file.gz"){
eval {
use Compress::Zlib;
};
if ($@){
$logfiles->{$l} = 'Log File is Gzipped. Please install Perl module Compress::Zlib';
next;
}
my $gz = gzopen("$file.gz", "rb");
unless (defined $gz){
$logfiles->{$l} = "Problem with gzcat. $gzerrno\n";
next;
}
my $buffer;
$logfiles->{$l} .= $buffer while $gz->gzread($buffer) > 0;
$gz->gzclose();
# Unknown / Permission files.
} else {
my $t1 = -r $file; $t1 = $!;
my $t2 = -r "$file.gz"; $t2 = $!;
$logfiles->{$l} = "I can't read/find $file ($t1) or $file.gz ($t2).\n";
}
}
# Split them up by class into separate arrays stored in this hash
my %log_sort;
foreach my $l (@$log){
my $class = $l->{class};
push (@{$log_sort{$class}},$l);
}
</%init>
%#
%# title()
%#
<%method title>
- Log \
</%method>
%# $Id: log.html,v 1.11 2007/12/18 01:26:04 maxbaker Exp $
%# vim:syntax=mason
|