applications/luci-statistics: make it work under uhttpd
This commit is contained in:
parent
8016c9649f
commit
4fa474cf2b
2 changed files with 18 additions and 6 deletions
|
@ -161,16 +161,28 @@ function statistics_render()
|
||||||
local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
|
local span = vars.timespan or uci:get( "luci_statistics", "rrdtool", "default_timespan" ) or spans[1]
|
||||||
local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
|
local graph = luci.statistics.rrdtool.Graph( luci.util.parse_units( span ) )
|
||||||
|
|
||||||
|
-- deliver image
|
||||||
|
if vars.img then
|
||||||
|
local l12 = require "luci.ltn12"
|
||||||
|
local png = io.open(graph.opts.imgpath .. "/" .. vars.img:gsub("%.+", "."), "r")
|
||||||
|
if png then
|
||||||
|
luci.http.prepare_content("image/png")
|
||||||
|
l12.pump.all(l12.source.file(png), luci.http.write)
|
||||||
|
png:close()
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
local plugin, instances
|
local plugin, instances
|
||||||
local images = { }
|
local images = { }
|
||||||
|
|
||||||
-- find requested plugin and instance
|
-- find requested plugin and instance
|
||||||
for i, p in ipairs( luci.dispatcher.context.path ) do
|
for i, p in ipairs( luci.dispatcher.context.path ) do
|
||||||
if luci.dispatcher.context.path[i] == "graph" then
|
if luci.dispatcher.context.path[i] == "graph" then
|
||||||
plugin = luci.dispatcher.context.path[i+1]
|
plugin = luci.dispatcher.context.path[i+1]
|
||||||
instances = { luci.dispatcher.context.path[i+2] }
|
instances = { luci.dispatcher.context.path[i+2] }
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- no instance requested, find all instances
|
-- no instance requested, find all instances
|
||||||
if #instances == 0 then
|
if #instances == 0 then
|
||||||
|
|
|
@ -31,7 +31,7 @@ $Id$
|
||||||
|
|
||||||
<div style="text-align: center">
|
<div style="text-align: center">
|
||||||
<% for i, img in ipairs(images) do %>
|
<% for i, img in ipairs(images) do %>
|
||||||
<img src="/rrdimg/<%=img%>" />
|
<img src="<%=REQUEST_URI%>?img=<%=img%>" />
|
||||||
<br />
|
<br />
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue