bird: Rename to bird1 and bump to v1.6.4
[feed/routing.git] / bird1-openwrt / bird1-ipv4-openwrt / src / view / log.htm
1 <%-
2 -- Only populate textarea through XHR.poll
3 -- "refresh" is present in the URL (.../log?refresh=1)
4 if luci.http.formvalue("refresh") then
5
6 -- Force HTTP Contents to be "text/plain"
7 luci.http.prepare_content("text/plain")
8
9 local sys = require("luci.sys")
10 local uci = require "luci.model.uci".cursor()
11
12 -- Get Log File from Bird's configuration or leave it empty.
13 local log_file = uci:get("bird4", "global", "log_file") or ""
14 local log_size = ""
15 if log_file then
16 log_size = sys.exec("du -h " .. log_file .. " | awk '{print $1}'")
17 -- Gathering last 30 lines of the Log File.
18 lf = sys.exec("tail -n30 " .. log_file):gsub("\r\n?", "\n")
19 end
20
21 -- Write File used and its contents.
22 luci.http.write("Using Log File: " .. log_file .. " - File Size: " .. log_size .. "\n" .. lf)
23
24 -- Avoid printing the rest of the page (return only text log data)
25 return
26 end
27 -%>
28
29 <%+header%>
30 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
31 <script type="text/javascript">//<![CDATA[
32 // Refresh page each second. Use "refresh=1" as trigger.
33 XHR.poll(1, '<%=url('admin/network/bird4/log')%>', { refresh: 1 }, function(xhrInstance) {
34 var area = document.getElementById('log')
35 area.value = xhrInstance.responseText;
36 });
37 //]]></script>
38
39
40 <textarea readonly="readonly" style="width: 100%" wrap="on" rows="32" id="log"><%=lf:pcdata()%></textarea>
41 <%+footer%>