From 1bb4822dca6113f73e3bc89e2acf15935e6f8e92 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 3 Dec 2014 15:17:05 +0100 Subject: Rework LuCI build system * Rename subdirectories to their repective OpenWrt package names * Make each LuCI module its own standalone package * Deploy a shared luci.mk which is used by each module Makefile Signed-off-by: Jo-Philipp Wich --- .../luci-app-vnstat/luasrc/view/vnstat.htm | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 applications/luci-app-vnstat/luasrc/view/vnstat.htm (limited to 'applications/luci-app-vnstat/luasrc/view') diff --git a/applications/luci-app-vnstat/luasrc/view/vnstat.htm b/applications/luci-app-vnstat/luasrc/view/vnstat.htm new file mode 100644 index 000000000..d67f9b3be --- /dev/null +++ b/applications/luci-app-vnstat/luasrc/view/vnstat.htm @@ -0,0 +1,108 @@ +<%# +LuCI - Lua Configuration Interface +Copyright 2010 Jo-Philipp Wich + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +-%> + +<%- + +local fs = require "nixio.fs" +local sys = require "luci.sys" +local utl = require "luci.util" + +local param = luci.http.formvalue + +local iface = param("iface") +local style = param("style") + +style = (style and #style > 0) and style or "s" + + +-- +-- render image +-- +if iface then + style = style:gsub("[^%w]", "") + iface = iface:gsub("[^%w%.%-]", "") + + luci.http.prepare_content("image/png") + + local png = io.popen("vnstati -i '%s' '-%s' -o -" % { iface, style }) + luci.http.write(png:read("*a")) + png:close() + + return + +-- +-- update database +-- +else + sys.call("vnstat -u >/dev/null 2>/dev/null") +end + + +-- +-- find databases +-- +local dbdir, line + +for line in io.lines("/etc/vnstat.conf") do + dbdir = line:match("^%s*DatabaseDir%s+[\"'](%S-)[\"']") + if dbdir then break end +end + +dbdir = dbdir or "/var/lib/vnstat" + +-%> + +<%+header%> + +

<%:VnStat Graphs%>

+ +
+ + + + + +
+ +


+ +
+<% + empty = true + ifdir = fs.dir(dbdir) + + if ifdir then + for iface in ifdir do + if iface:sub(1,1) ~= "." then + empty = false +%> + +

+<% + end + end + end +%> + +<% if empty then %> +

<%:No database has been set up yet. Go to the VnStat configuration and enable monitoring for one or more interfaces.%>

+<% end %> + +
+ +<%+footer%> -- cgit v1.2.3