blob: 318611a9d69028cec610f4bc9733fadc629a84b9 (
plain)
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
|
<%#
This is free software, licensed under the Apache License, Version 2.0
-%>
<%-
local util = require "luci.util"
local json = require "luci.jsonc"
local ifaces = {}
local data = util.exec("vnstat --json f 1 2>/dev/null")
local content = json.parse(data)
if type(content) == "table" then
for _, iface in pairs(content["interfaces"]) do
table.insert(ifaces, iface["name"])
end
end
local function render_section(style, title)
%><div class="cbi-section" data-tab="<%=style%>" data-tab-title="<%=title%>"><%
for _, iface in ipairs(ifaces) do
%><p><img src="<%=url("admin/status/vnstat2/graph")%>?iface=<%=iface%>&style=<%=style%>" alt="" style="max-width:100%" /></p><%
end
%></div><%
end
-%>
<%+header%>
<h2 name="content"><%:vnStat Graphs%></h2>
<div>
<%
if #ifaces == 0 then
%><p><em><%:No monitored interfaces have been found. Go to the configuration to enable monitoring for one or more interfaces.%></em></p><%
else
render_section("s", translate("Summary"))
render_section("t", translate("Top"))
render_section("5", translate("5 Minute"))
render_section("h", translate("Hourly"))
render_section("d", translate("Daily"))
render_section("m", translate("Monthly"))
render_section("y", translate("Yearly"))
end
%>
</div>
<%+footer%>
|