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
|
<% local form, viewlibrary, page_info = ...
require("viewfunctions")
%>
<style type="text/css">
#content table { border-collapse: collapse; width: 100%; }
#content table td { white-space: normal; padding-right:20px; border-bottom:1px solid #999; }
#content table tr.mark { background: #E9E9E9; }
</style>
<% if form.value.result then %>
<H1><%= html.html_escape(form.value.result.label) %></H1>
<% if #form.value.result.value == 0 then %>
<p>No results, try adjusting query</p>
<% else %>
<TABLE>
<TR style="font-weight:bold;">
<% names = {}
for name,val in pairs(form.value.result.value[1]) do
names[#names+1] = name %>
<TD class="header"><%= html.html_escape(name) %></TD>
<% end %>
</TR>
<% for i,row in ipairs(form.value.result.value) do
local a,b = math.modf((i/2))
local mark = ''
if (b == 0) then mark=' class="mark"' end %>
<TR<%= mark %>>
<% for j,name in ipairs(names) do %>
<TD><%= html.html_escape(row[name]) %></TD>
<% end %>
</TR>
<% end %>
</TABLE>
<form action="/cgi-bin/acf/weblog/weblog/downloadadhocquery" method="POST">
<input class="hidden" type="hidden" name="query" value="<%= html.html_escape(form.value.query.value) %>" >
<DL>
<DT>Download query result</DT><DD><input class="submit" type="submit" name="Download" value="Download"></DD>
</DL>
</FORM>
<% end %>
<% end %>
<H1><%= html.html_escape(form.label) %></H1>
<% displayformstart(form, page_info) %>
This form accepts a Postgresql SELECT statement and displays the results. Examples:
<ul>
<li>This statement will return the total bytes transferred by each user for the entire weblog history<pre>SELECT clientuserid, sum(bytes) AS total FROM pubweblog GROUP BY clientuserid ORDER BY total DESC</pre>
<li>This statement limits the above statement to a specific range of dates (just yesterday)<pre>SELECT clientuserid, sum(bytes) AS total FROM pubweblog WHERE logdatetime >= 'yesterday' and logdatetime < 'today' GROUP BY clientuserid ORDER BY total DESC</pre>
<li>This statement will return the number of requests and blocks by hour over the course of the entire usage history<pre>SELECT extract(hour from date) AS hour, sum(numrequest) AS numrequest, sum(numblock) AS numblock FROM usagestat GROUP BY extract(hour from date) ORDER BY hour</pre>
</ul>
The available database tables and descriptions are listed below.
<% displayformitem(form.value.query, "query") %>
<% displayformend(form) %>
<H2>Available Database Tables</H2>
<H3>PubWeblog and PubBlocklog</H3>
<DL>
These tables contain the combined squid access log and dansguardian log for every access and blocked access respectively. The definition of the table is as follows:
<pre>
(
sourcename character varying(40),
clientip inet NOT NULL,
clientuserid character varying(64) NOT NULL,
logdatetime timestamp(3) without time zone NOT NULL,
uri text NOT NULL,
bytes integer NOT NULL,
reason text,
score integer,
shortreason text
)
</pre></DL>
<H3>dbHistLog</H3>
<DL>
This table contains the database history, including such information as which log files were loaded and how many entries they contained. The definition of the table is as follows:
<pre>
(
logdatetime timestamp(3) without time zone NOT NULL,
msgtext text
)
</pre></DL>
<H3>Source</H3>
<DL>
This table contains the list of log file sources. The definition of the table is as follows:
<pre>
(
sourcename character varying(40) NOT NULL,
method character varying(100) NOT NULL,
userid character varying(32),
passwd character varying(255),
source character varying(255) NOT NULL,
tzislocal boolean,
enabled boolean
)
</pre></DL>
<H3>Usagestat</H3>
<DL>
This table contains a historical record of pages requested and blocked by hour. The definition of the table is as follows:
<pre>
(
sourcename character varying(40) NOT NULL,
date timestamp(0) without time zone NOT NULL,
numrequest integer,
numblock integer
)
</pre></DL>
|