From: Steven Barth Date: Tue, 27 May 2008 12:23:39 +0000 (+0000) Subject: commit 4f6198094cf4134179d1f9c9fa8f79759a27c87e X-Git-Tag: 0.8.0~979 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=d35a620e9f5665a94967f4bd02c93581a1dd7e00;ds=sidebyside commit 4f6198094cf4134179d1f9c9fa8f79759a27c87e Author: Felix Fietkau Date: Tue May 27 13:56:12 2008 +0200 rename src/ to luasrc/ --- diff --git a/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua b/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua new file mode 100644 index 000000000..4f2390b37 --- /dev/null +++ b/applications/luci-ffwizard-leipzig/luasrc/controller/luci_ffwizard_leipzig/wizard.lua @@ -0,0 +1,243 @@ +module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall) + +function index() + entry({"admin", "index", "wizard"}, action_wizard, "Freifunkassistent", 20) +end + + +function action_wizard() + if luci.http.formvalue("ip") then + return configure_freifunk() + end + + local ifaces = {} + local wldevs = luci.model.uci.sections("wireless") + + if wldevs then + for k, v in pairs(wldevs) do + if v[".type"] == "wifi-device" then + table.insert(ifaces, k) + end + end + end + + luci.template.render("freifunk/wizard", {ifaces=ifaces}) +end + +function configure_freifunk() + local ip = luci.http.formvalue("ip") + local uci = luci.model.uci.Session() + + -- Load UCI + uci:t_load("network") + uci:t_load("dhcp") + uci:t_load("freifunk") + uci:t_load("luci_splash") + uci:t_load("olsr") + uci:t_load("wireless") + uci:t_load("luci_fw") + + + -- Configure FF-Interface + uci:t_del("network", "ff") + uci:t_del("network", "ffdhcp") + + uci:t_set("network", "ff", nil, "interface") + uci:t_set("network", "ff", "type", "bridge") + uci:t_set("network", "ff", "proto", "static") + uci:t_set("network", "ff", "ipaddr", ip) + uci:t_set("network", "ff", "netmask", uci:t_get("freifunk", "community", "mask")) + uci:t_set("network", "ff", "dns", uci:t_get("freifunk", "community", "dns")) + + -- Reset Routing + local routing = uci:t_sections("luci_fw") + if routing then + for k, v in pairs(routing) do + if v[".type"] == "routing" and (v.iface == "ff" or v.oface == "ff") then + uci:t_del("luci_fw", k) + end + end + + local int = uci:t_add("luci_fw", "routing") + uci:t_set("luci_fw", int, "iface", "ff") + uci:t_set("luci_fw", int, "oface", "ff") + uci:t_set("luci_fw", int, "fwd", "1") + end + + -- Routing from Internal + local iface = luci.http.formvalue("frominternal") + if iface and iface ~= "" then + local routing = uci:t_sections("luci_fw") + if routing then + for k, v in pairs(routing) do + if v[".type"] == "routing" and (v.iface == iface and v.oface == "ff") then + uci:t_del("luci_fw", k) + end + end + + local int = uci:t_add("luci_fw", "routing") + uci:t_set("luci_fw", int, "iface", iface) + uci:t_set("luci_fw", int, "oface", "ff") + uci:t_set("luci_fw", int, "fwd", "1") + uci:t_set("luci_fw", int, "nat", "1") + end + end + + -- Routing to External + local iface = luci.http.formvalue("toexternal") + if iface and iface ~= "" then + local routing = uci:t_sections("luci_fw") + if routing then + for k, v in pairs(routing) do + if v[".type"] == "routing" and (v.oface == iface and v.iface == "ff") then + uci:t_del("luci_fw", k) + end + end + + local int = uci:t_add("luci_fw", "routing") + uci:t_set("luci_fw", int, "iface", "ff") + uci:t_set("luci_fw", int, "oface", iface) + uci:t_set("luci_fw", int, "fwd", "1") + uci:t_set("luci_fw", int, "nat", "1") + end + end + + -- Configure DHCP + if luci.http.formvalue("dhcp") then + local dhcpnet = uci:t_get("freifunk", "community", "dhcp"):match("^([0-9]+)") + local dhcpip = ip:gsub("^[0-9]+", dhcpnet) + + uci:t_set("network", "ffdhcp", nil, "interface") + uci:t_set("network", "ffdhcp", "proto", "static") + uci:t_set("network", "ffdhcp", "ifname", "br-ff:dhcp") + uci:t_set("network", "ffdhcp", "ipaddr", dhcpip) + uci:t_set("network", "ffdhcp", "netmask", uci:t_get("freifunk", "community", "dhcpmask")) + + local dhcp = uci:t_sections("dhcp") + if dhcp then + for k, v in pairs(dhcp) do + if v[".type"] == "dhcp" and v.interface == "ffdhcp" then + uci:t_del("dhcp", k) + end + end + + local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4 + + local sk = uci:t_add("dhcp", "dhcp") + uci:t_set("dhcp", sk, "interface", "ffdhcp") + uci:t_set("dhcp", sk, "start", dhcpbeg) + uci:t_set("dhcp", sk, "limit", (dhcpbeg < 252) and 3 or 2) + uci:t_set("dhcp", sk, "leasetime", "30m") + end + + local splash = uci:t_sections("luci_splash") + if splash then + for k, v in pairs(splash) do + if v[".type"] == "iface" then + uci:t_del("luci_splash", k) + end + end + + local sk = uci:t_add("luci_splash", "iface") + uci:t_set("luci_splash", sk, "network", "ffdhcp") + end + + local routing = uci:t_sections("luci_fw") + if routing then + for k, v in pairs(routing) do + if v[".type"] == "routing" and (v.iface == "ffdhcp" or v.oface == "ffdhcp") then + uci:t_del("luci_fw", k) + end + end + + local int = uci:t_add("luci_fw", "routing") + uci:t_set("luci_fw", int, "iface", "ffdhcp") + uci:t_set("luci_fw", int, "oface", "ff") + uci:t_set("luci_fw", int, "nat", "1") + + local iface = luci.http.formvalue("toexternal") + if iface and iface ~= "" then + local int = uci:t_add("luci_fw", "routing") + uci:t_set("luci_fw", int, "iface", "ffdhcp") + uci:t_set("luci_fw", int, "oface", iface) + uci:t_set("luci_fw", int, "nat", "1") + end + end + end + + -- Configure OLSR + if luci.http.formvalue("olsr") and uci:t_sections("olsr") then + for k, v in pairs(uci:t_sections("olsr")) do + if v[".type"] == "Interface" or v[".type"] == "LoadPlugin" then + uci:t_del("olsr", k) + end + end + + if luci.http.formvalue("shareinet") then + uci:t_set("olsr", "dyn_gw", nil, "LoadPlugin") + uci:t_set("olsr", "dyn_gw", "Library", "olsrd_dyn_gw.so.0.4") + end + + uci:t_set("olsr", "nameservice", nil, "LoadPlugin") + uci:t_set("olsr", "nameservice", "Library", "olsrd_nameservice.so.0.3") + uci:t_set("olsr", "nameservice", "name", ip:gsub("%.", "-")) + uci:t_set("olsr", "nameservice", "hosts_file", "/var/etc/hosts") + uci:t_set("olsr", "nameservice", "suffix", ".olsr") + uci:t_set("olsr", "nameservice", "latlon_infile", "/tmp/latlon.txt") + + uci:t_set("olsr", "txtinfo", nil, "LoadPlugin") + uci:t_set("olsr", "txtinfo", "Library", "olsrd_txtinfo.so.0.1") + uci:t_set("olsr", "txtinfo", "Accept", "127.0.0.1") + + local oif = uci:t_add("olsr", "Interface") + uci:t_set("olsr", oif, "Interface", "ff") + uci:t_set("olsr", oif, "HelloInterval", "6.0") + uci:t_set("olsr", oif, "HelloValidityTime", "108.0") + uci:t_set("olsr", oif, "TcInterval", "4.0") + uci:t_set("olsr", oif, "TcValidityTime", "324.0") + uci:t_set("olsr", oif, "MidInterval", "18.0") + uci:t_set("olsr", oif, "MidValidityTime", "324.0") + uci:t_set("olsr", oif, "HnaInterval", "18.0") + uci:t_set("olsr", oif, "HnaValidityTime", "108.0") + end + + -- Configure Wifi + local wcfg = uci:t_sections("wireless") + if wcfg then + for iface, v in pairs(wcfg) do + if v[".type"] == "wifi-device" and luci.http.formvalue("wifi."..iface) then + -- Cleanup + for k, j in pairs(wcfg) do + if j[".type"] == "wifi-iface" and j.device == iface then + uci:t_del("wireless", k) + end + end + + uci:t_set("wireless", iface, "disabled", "0") + uci:t_set("wireless", iface, "mode", "11g") + uci:t_set("wireless", iface, "txantenna", 1) + uci:t_set("wireless", iface, "rxantenna", 1) + uci:t_set("wireless", iface, "channel", uci:t_get("freifunk", "community", "channel")) + + local wif = uci:t_add("wireless", "wifi-iface") + uci:t_set("wireless", wif, "device", iface) + uci:t_set("wireless", wif, "network", "ff") + uci:t_set("wireless", wif, "mode", "adhoc") + uci:t_set("wireless", wif, "ssid", uci:t_get("freifunk", "community", "essid")) + uci:t_set("wireless", wif, "bssid", uci:t_get("freifunk", "community", "bssid")) + uci:t_set("wireless", wif, "txpower", 13) + end + end + end + + -- Save UCI + uci:t_save("network") + uci:t_save("dhcp") + uci:t_save("freifunk") + uci:t_save("luci_splash") + uci:t_save("olsr") + uci:t_save("wireless") + uci:t_save("luci_fw") + + luci.http.redirect(luci.dispatcher.build_url("admin", "uci", "changes")) +end \ No newline at end of file diff --git a/applications/luci-ffwizard-leipzig/luasrc/view/freifunk/wizard.htm b/applications/luci-ffwizard-leipzig/luasrc/view/freifunk/wizard.htm new file mode 100644 index 000000000..e3d6cb4c0 --- /dev/null +++ b/applications/luci-ffwizard-leipzig/luasrc/view/freifunk/wizard.htm @@ -0,0 +1,58 @@ +<%+header%> +

<%:ffwizard Freifunkassistent%>

+

<%:ffwizard1 Dieser Assistent konfiguriert den Router für die Benutzung im Freifunknetz%>

+
+
+
+
+
<%:ip IP-Adresse%>:  +
+
+ <% for i, k in ipairs(ifaces) do %> +
+
<%:wificfg Drahtlosgerät einrichten%>: <%=k%>
+
+
+ <% end %> +
+
<%:cfgolsr OLSR konfigurieren%>
+
+
+
+
<%:cfgdhcp Drahtlos DHCP konfigurieren%>
+
+
+
+
<%:cfginternal Erlaube Zugriff von internem Netzwerk%>:
+
+
+
+
<%:cfgexternal Erlaube Zugriff auf externes Netzwerk%>:
+
+
+
+
<%:shareinet Internetzugang ankündigen%>
+
+
+
+
+
+ + +
+
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-ffwizard-leipzig/src/controller/luci_ffwizard_leipzig/wizard.lua b/applications/luci-ffwizard-leipzig/src/controller/luci_ffwizard_leipzig/wizard.lua deleted file mode 100644 index 4f2390b37..000000000 --- a/applications/luci-ffwizard-leipzig/src/controller/luci_ffwizard_leipzig/wizard.lua +++ /dev/null @@ -1,243 +0,0 @@ -module("luci.controller.luci_ffwizard_leipzig.wizard", package.seeall) - -function index() - entry({"admin", "index", "wizard"}, action_wizard, "Freifunkassistent", 20) -end - - -function action_wizard() - if luci.http.formvalue("ip") then - return configure_freifunk() - end - - local ifaces = {} - local wldevs = luci.model.uci.sections("wireless") - - if wldevs then - for k, v in pairs(wldevs) do - if v[".type"] == "wifi-device" then - table.insert(ifaces, k) - end - end - end - - luci.template.render("freifunk/wizard", {ifaces=ifaces}) -end - -function configure_freifunk() - local ip = luci.http.formvalue("ip") - local uci = luci.model.uci.Session() - - -- Load UCI - uci:t_load("network") - uci:t_load("dhcp") - uci:t_load("freifunk") - uci:t_load("luci_splash") - uci:t_load("olsr") - uci:t_load("wireless") - uci:t_load("luci_fw") - - - -- Configure FF-Interface - uci:t_del("network", "ff") - uci:t_del("network", "ffdhcp") - - uci:t_set("network", "ff", nil, "interface") - uci:t_set("network", "ff", "type", "bridge") - uci:t_set("network", "ff", "proto", "static") - uci:t_set("network", "ff", "ipaddr", ip) - uci:t_set("network", "ff", "netmask", uci:t_get("freifunk", "community", "mask")) - uci:t_set("network", "ff", "dns", uci:t_get("freifunk", "community", "dns")) - - -- Reset Routing - local routing = uci:t_sections("luci_fw") - if routing then - for k, v in pairs(routing) do - if v[".type"] == "routing" and (v.iface == "ff" or v.oface == "ff") then - uci:t_del("luci_fw", k) - end - end - - local int = uci:t_add("luci_fw", "routing") - uci:t_set("luci_fw", int, "iface", "ff") - uci:t_set("luci_fw", int, "oface", "ff") - uci:t_set("luci_fw", int, "fwd", "1") - end - - -- Routing from Internal - local iface = luci.http.formvalue("frominternal") - if iface and iface ~= "" then - local routing = uci:t_sections("luci_fw") - if routing then - for k, v in pairs(routing) do - if v[".type"] == "routing" and (v.iface == iface and v.oface == "ff") then - uci:t_del("luci_fw", k) - end - end - - local int = uci:t_add("luci_fw", "routing") - uci:t_set("luci_fw", int, "iface", iface) - uci:t_set("luci_fw", int, "oface", "ff") - uci:t_set("luci_fw", int, "fwd", "1") - uci:t_set("luci_fw", int, "nat", "1") - end - end - - -- Routing to External - local iface = luci.http.formvalue("toexternal") - if iface and iface ~= "" then - local routing = uci:t_sections("luci_fw") - if routing then - for k, v in pairs(routing) do - if v[".type"] == "routing" and (v.oface == iface and v.iface == "ff") then - uci:t_del("luci_fw", k) - end - end - - local int = uci:t_add("luci_fw", "routing") - uci:t_set("luci_fw", int, "iface", "ff") - uci:t_set("luci_fw", int, "oface", iface) - uci:t_set("luci_fw", int, "fwd", "1") - uci:t_set("luci_fw", int, "nat", "1") - end - end - - -- Configure DHCP - if luci.http.formvalue("dhcp") then - local dhcpnet = uci:t_get("freifunk", "community", "dhcp"):match("^([0-9]+)") - local dhcpip = ip:gsub("^[0-9]+", dhcpnet) - - uci:t_set("network", "ffdhcp", nil, "interface") - uci:t_set("network", "ffdhcp", "proto", "static") - uci:t_set("network", "ffdhcp", "ifname", "br-ff:dhcp") - uci:t_set("network", "ffdhcp", "ipaddr", dhcpip) - uci:t_set("network", "ffdhcp", "netmask", uci:t_get("freifunk", "community", "dhcpmask")) - - local dhcp = uci:t_sections("dhcp") - if dhcp then - for k, v in pairs(dhcp) do - if v[".type"] == "dhcp" and v.interface == "ffdhcp" then - uci:t_del("dhcp", k) - end - end - - local dhcpbeg = 48 + tonumber(ip:match("[0-9]+$")) * 4 - - local sk = uci:t_add("dhcp", "dhcp") - uci:t_set("dhcp", sk, "interface", "ffdhcp") - uci:t_set("dhcp", sk, "start", dhcpbeg) - uci:t_set("dhcp", sk, "limit", (dhcpbeg < 252) and 3 or 2) - uci:t_set("dhcp", sk, "leasetime", "30m") - end - - local splash = uci:t_sections("luci_splash") - if splash then - for k, v in pairs(splash) do - if v[".type"] == "iface" then - uci:t_del("luci_splash", k) - end - end - - local sk = uci:t_add("luci_splash", "iface") - uci:t_set("luci_splash", sk, "network", "ffdhcp") - end - - local routing = uci:t_sections("luci_fw") - if routing then - for k, v in pairs(routing) do - if v[".type"] == "routing" and (v.iface == "ffdhcp" or v.oface == "ffdhcp") then - uci:t_del("luci_fw", k) - end - end - - local int = uci:t_add("luci_fw", "routing") - uci:t_set("luci_fw", int, "iface", "ffdhcp") - uci:t_set("luci_fw", int, "oface", "ff") - uci:t_set("luci_fw", int, "nat", "1") - - local iface = luci.http.formvalue("toexternal") - if iface and iface ~= "" then - local int = uci:t_add("luci_fw", "routing") - uci:t_set("luci_fw", int, "iface", "ffdhcp") - uci:t_set("luci_fw", int, "oface", iface) - uci:t_set("luci_fw", int, "nat", "1") - end - end - end - - -- Configure OLSR - if luci.http.formvalue("olsr") and uci:t_sections("olsr") then - for k, v in pairs(uci:t_sections("olsr")) do - if v[".type"] == "Interface" or v[".type"] == "LoadPlugin" then - uci:t_del("olsr", k) - end - end - - if luci.http.formvalue("shareinet") then - uci:t_set("olsr", "dyn_gw", nil, "LoadPlugin") - uci:t_set("olsr", "dyn_gw", "Library", "olsrd_dyn_gw.so.0.4") - end - - uci:t_set("olsr", "nameservice", nil, "LoadPlugin") - uci:t_set("olsr", "nameservice", "Library", "olsrd_nameservice.so.0.3") - uci:t_set("olsr", "nameservice", "name", ip:gsub("%.", "-")) - uci:t_set("olsr", "nameservice", "hosts_file", "/var/etc/hosts") - uci:t_set("olsr", "nameservice", "suffix", ".olsr") - uci:t_set("olsr", "nameservice", "latlon_infile", "/tmp/latlon.txt") - - uci:t_set("olsr", "txtinfo", nil, "LoadPlugin") - uci:t_set("olsr", "txtinfo", "Library", "olsrd_txtinfo.so.0.1") - uci:t_set("olsr", "txtinfo", "Accept", "127.0.0.1") - - local oif = uci:t_add("olsr", "Interface") - uci:t_set("olsr", oif, "Interface", "ff") - uci:t_set("olsr", oif, "HelloInterval", "6.0") - uci:t_set("olsr", oif, "HelloValidityTime", "108.0") - uci:t_set("olsr", oif, "TcInterval", "4.0") - uci:t_set("olsr", oif, "TcValidityTime", "324.0") - uci:t_set("olsr", oif, "MidInterval", "18.0") - uci:t_set("olsr", oif, "MidValidityTime", "324.0") - uci:t_set("olsr", oif, "HnaInterval", "18.0") - uci:t_set("olsr", oif, "HnaValidityTime", "108.0") - end - - -- Configure Wifi - local wcfg = uci:t_sections("wireless") - if wcfg then - for iface, v in pairs(wcfg) do - if v[".type"] == "wifi-device" and luci.http.formvalue("wifi."..iface) then - -- Cleanup - for k, j in pairs(wcfg) do - if j[".type"] == "wifi-iface" and j.device == iface then - uci:t_del("wireless", k) - end - end - - uci:t_set("wireless", iface, "disabled", "0") - uci:t_set("wireless", iface, "mode", "11g") - uci:t_set("wireless", iface, "txantenna", 1) - uci:t_set("wireless", iface, "rxantenna", 1) - uci:t_set("wireless", iface, "channel", uci:t_get("freifunk", "community", "channel")) - - local wif = uci:t_add("wireless", "wifi-iface") - uci:t_set("wireless", wif, "device", iface) - uci:t_set("wireless", wif, "network", "ff") - uci:t_set("wireless", wif, "mode", "adhoc") - uci:t_set("wireless", wif, "ssid", uci:t_get("freifunk", "community", "essid")) - uci:t_set("wireless", wif, "bssid", uci:t_get("freifunk", "community", "bssid")) - uci:t_set("wireless", wif, "txpower", 13) - end - end - end - - -- Save UCI - uci:t_save("network") - uci:t_save("dhcp") - uci:t_save("freifunk") - uci:t_save("luci_splash") - uci:t_save("olsr") - uci:t_save("wireless") - uci:t_save("luci_fw") - - luci.http.redirect(luci.dispatcher.build_url("admin", "uci", "changes")) -end \ No newline at end of file diff --git a/applications/luci-ffwizard-leipzig/src/view/freifunk/wizard.htm b/applications/luci-ffwizard-leipzig/src/view/freifunk/wizard.htm deleted file mode 100644 index e3d6cb4c0..000000000 --- a/applications/luci-ffwizard-leipzig/src/view/freifunk/wizard.htm +++ /dev/null @@ -1,58 +0,0 @@ -<%+header%> -

<%:ffwizard Freifunkassistent%>

-

<%:ffwizard1 Dieser Assistent konfiguriert den Router für die Benutzung im Freifunknetz%>

-
-
-
-
-
<%:ip IP-Adresse%>:  -
-
- <% for i, k in ipairs(ifaces) do %> -
-
<%:wificfg Drahtlosgerät einrichten%>: <%=k%>
-
-
- <% end %> -
-
<%:cfgolsr OLSR konfigurieren%>
-
-
-
-
<%:cfgdhcp Drahtlos DHCP konfigurieren%>
-
-
-
-
<%:cfginternal Erlaube Zugriff von internem Netzwerk%>:
-
-
-
-
<%:cfgexternal Erlaube Zugriff auf externes Netzwerk%>:
-
-
-
-
<%:shareinet Internetzugang ankündigen%>
-
-
-
-
-
- - -
-
-<%+footer%> \ No newline at end of file diff --git a/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua b/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua new file mode 100644 index 000000000..419097066 --- /dev/null +++ b/applications/luci-fw/luasrc/controller/luci_fw/luci_fw.lua @@ -0,0 +1,7 @@ +module("luci.controller.luci_fw.luci_fw", package.seeall) + +function index() + entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), "Portweiterleitung", 70) + entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), "Routing", 72) + entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), "Firewall", 74) +end \ No newline at end of file diff --git a/applications/luci-fw/luasrc/model/cbi/luci_fw/firewall.lua b/applications/luci-fw/luasrc/model/cbi/luci_fw/firewall.lua new file mode 100644 index 000000000..f58f74c2b --- /dev/null +++ b/applications/luci-fw/luasrc/model/cbi/luci_fw/firewall.lua @@ -0,0 +1,73 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("luci_fw", "Firewall", [[Mit Hilfe der Firewall können Zugriffe auf das Netzwerk +erlaubt, verboten oder umgeleitet werden.]]) + +s = m:section(TypedSection, "rule") +s.addremove = true +s.anonymous = true + +chain = s:option(ListValue, "chain", "Kette") +chain:value("forward", "Forward") +chain:value("input", "Input") +chain:value("output", "Output") +chain:value("prerouting", "Prerouting") +chain:value("postrouting", "Postrouting") + +iface = s:option(ListValue, "iface", "Eingangsschnittstelle") +iface.optional = true + +oface = s:option(ListValue, "oface", "Ausgangsschnittstelle") +oface.optional = true + +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + oface:value(k) + end +end + +proto = s:option(ListValue, "proto", "Protokoll") +proto.optional = true +proto:value("") +proto:value("tcp", "TCP") +proto:value("udp", "UDP") + +s:option(Value, "source", "Quelladresse").optional = true +s:option(Value, "destination", "Zieladresse").optional = true +s:option(Value, "mac", "MAC-Adresse").optional = true + +sport = s:option(Value, "sport", "Quellport") +sport.optional = true +sport:depends("proto", "tcp") +sport:depends("proto", "udp") + +dport = s:option(Value, "dport", "Zielport") +dport.optional = true +dport:depends("proto", "tcp") +dport:depends("proto", "udp") + +tosrc = s:option(Value, "tosrc", "Neue Quelladresse [SNAT]") +tosrc.optional = true +tosrc:depends("jump", "SNAT") + +tosrc = s:option(Value, "todest", "Neue Zieladresse [DNAT]") +tosrc.optional = true +tosrc:depends("jump", "DNAT") + +jump = s:option(ListValue, "jump", "Aktion") +jump.rmempty = true +jump:value("", "") +jump:value("ACCEPT", "annehmen (ACCEPT)") +jump:value("REJECT", "zurückweisen (REJECT)") +jump:value("DROP", "verwerfen (DROP)") +jump:value("LOG", "protokollieren (LOG)") +jump:value("DNAT", "Ziel umschreiben (DNAT) [nur Prerouting]") +jump:value("MASQUERADE", "maskieren (MASQUERADE) [nur Postrouting]") +jump:value("SNAT", "Quelle umschreiben (SNAT) [nur Postrouting]") + + +add = s:option(Value, "command", "Eigener Befehl") +add.size = 50 +add.rmempty = true + +return m diff --git a/applications/luci-fw/luasrc/model/cbi/luci_fw/portfw.lua b/applications/luci-fw/luasrc/model/cbi/luci_fw/portfw.lua new file mode 100644 index 000000000..e4f4fa2ac --- /dev/null +++ b/applications/luci-fw/luasrc/model/cbi/luci_fw/portfw.lua @@ -0,0 +1,28 @@ +-- ToDo: Translate, Add descriptions and help texts +require("luci.sys") +m = Map("luci_fw", "Portweiterleitung", [[Portweiterleitungen ermöglichen es interne +Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]]) + +s = m:section(TypedSection, "portfw") +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true + +iface = s:option(ListValue, "iface", "Schnittstelle", "Externe Schnittstelle") +iface.default = "wan" +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + end +end + +proto = s:option(ListValue, "proto", "Protokoll") +proto:value("tcp", "TCP") +proto:value("udp", "UDP") +proto:value("tcpudp", "TCP + UDP") + +dport = s:option(Value, "dport", "Externer Port", "Port[:Endport]") + +to = s:option(Value, "to", "Interne Adresse", "IP-Adresse[:Zielport[-Zielendport]]") + +return m diff --git a/applications/luci-fw/luasrc/model/cbi/luci_fw/routing.lua b/applications/luci-fw/luasrc/model/cbi/luci_fw/routing.lua new file mode 100644 index 000000000..364e69f62 --- /dev/null +++ b/applications/luci-fw/luasrc/model/cbi/luci_fw/routing.lua @@ -0,0 +1,28 @@ +-- ToDo: Translate, Add descriptions and help texts +require("luci.sys") +m = Map("luci_fw", "Routing", [[An dieser Stelle wird festlegt, welcher Netzverkehr zwischen einzelnen +Schnittstellen erlaubt werden soll. Es werden jeweils nur neue Verbindungen +betrachtet, d.h. Pakete von aufgebauten oder zugehörigen Verbindungen werden automatisch in beide Richtungen +akzeptiert, auch wenn das Feld "beide Richtungen" nicht explizit gesetzt ist. +NAT ermöglicht Adressübersetzung.]]) + +s = m:section(TypedSection, "routing") +s.template = "cbi/tblsection" +s.addremove = true +s.anonymous = true + +iface = s:option(ListValue, "iface", "Eingang", "Eingangsschnittstelle") +oface = s:option(ListValue, "oface", "Ausgang", "Ausgangsschnittstelle") + +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + oface:value(k) + end +end + +s:option(Flag, "fwd", "FWD", "weiterleiten").rmempty = true +s:option(Flag, "nat", "NAT", "übersetzen").rmempty = true +s:option(Flag, "bidi", "<->", "beide Richtungen").rmempty = true + +return m diff --git a/applications/luci-fw/src/controller/luci_fw/luci_fw.lua b/applications/luci-fw/src/controller/luci_fw/luci_fw.lua deleted file mode 100644 index 419097066..000000000 --- a/applications/luci-fw/src/controller/luci_fw/luci_fw.lua +++ /dev/null @@ -1,7 +0,0 @@ -module("luci.controller.luci_fw.luci_fw", package.seeall) - -function index() - entry({"admin", "network", "portfw"}, cbi("luci_fw/portfw"), "Portweiterleitung", 70) - entry({"admin", "network", "routing"}, cbi("luci_fw/routing"), "Routing", 72) - entry({"admin", "network", "firewall"}, cbi("luci_fw/firewall"), "Firewall", 74) -end \ No newline at end of file diff --git a/applications/luci-fw/src/model/cbi/luci_fw/firewall.lua b/applications/luci-fw/src/model/cbi/luci_fw/firewall.lua deleted file mode 100644 index f58f74c2b..000000000 --- a/applications/luci-fw/src/model/cbi/luci_fw/firewall.lua +++ /dev/null @@ -1,73 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("luci_fw", "Firewall", [[Mit Hilfe der Firewall können Zugriffe auf das Netzwerk -erlaubt, verboten oder umgeleitet werden.]]) - -s = m:section(TypedSection, "rule") -s.addremove = true -s.anonymous = true - -chain = s:option(ListValue, "chain", "Kette") -chain:value("forward", "Forward") -chain:value("input", "Input") -chain:value("output", "Output") -chain:value("prerouting", "Prerouting") -chain:value("postrouting", "Postrouting") - -iface = s:option(ListValue, "iface", "Eingangsschnittstelle") -iface.optional = true - -oface = s:option(ListValue, "oface", "Ausgangsschnittstelle") -oface.optional = true - -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - oface:value(k) - end -end - -proto = s:option(ListValue, "proto", "Protokoll") -proto.optional = true -proto:value("") -proto:value("tcp", "TCP") -proto:value("udp", "UDP") - -s:option(Value, "source", "Quelladresse").optional = true -s:option(Value, "destination", "Zieladresse").optional = true -s:option(Value, "mac", "MAC-Adresse").optional = true - -sport = s:option(Value, "sport", "Quellport") -sport.optional = true -sport:depends("proto", "tcp") -sport:depends("proto", "udp") - -dport = s:option(Value, "dport", "Zielport") -dport.optional = true -dport:depends("proto", "tcp") -dport:depends("proto", "udp") - -tosrc = s:option(Value, "tosrc", "Neue Quelladresse [SNAT]") -tosrc.optional = true -tosrc:depends("jump", "SNAT") - -tosrc = s:option(Value, "todest", "Neue Zieladresse [DNAT]") -tosrc.optional = true -tosrc:depends("jump", "DNAT") - -jump = s:option(ListValue, "jump", "Aktion") -jump.rmempty = true -jump:value("", "") -jump:value("ACCEPT", "annehmen (ACCEPT)") -jump:value("REJECT", "zurückweisen (REJECT)") -jump:value("DROP", "verwerfen (DROP)") -jump:value("LOG", "protokollieren (LOG)") -jump:value("DNAT", "Ziel umschreiben (DNAT) [nur Prerouting]") -jump:value("MASQUERADE", "maskieren (MASQUERADE) [nur Postrouting]") -jump:value("SNAT", "Quelle umschreiben (SNAT) [nur Postrouting]") - - -add = s:option(Value, "command", "Eigener Befehl") -add.size = 50 -add.rmempty = true - -return m diff --git a/applications/luci-fw/src/model/cbi/luci_fw/portfw.lua b/applications/luci-fw/src/model/cbi/luci_fw/portfw.lua deleted file mode 100644 index e4f4fa2ac..000000000 --- a/applications/luci-fw/src/model/cbi/luci_fw/portfw.lua +++ /dev/null @@ -1,28 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -require("luci.sys") -m = Map("luci_fw", "Portweiterleitung", [[Portweiterleitungen ermöglichen es interne -Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]]) - -s = m:section(TypedSection, "portfw") -s.template = "cbi/tblsection" -s.addremove = true -s.anonymous = true - -iface = s:option(ListValue, "iface", "Schnittstelle", "Externe Schnittstelle") -iface.default = "wan" -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - end -end - -proto = s:option(ListValue, "proto", "Protokoll") -proto:value("tcp", "TCP") -proto:value("udp", "UDP") -proto:value("tcpudp", "TCP + UDP") - -dport = s:option(Value, "dport", "Externer Port", "Port[:Endport]") - -to = s:option(Value, "to", "Interne Adresse", "IP-Adresse[:Zielport[-Zielendport]]") - -return m diff --git a/applications/luci-fw/src/model/cbi/luci_fw/routing.lua b/applications/luci-fw/src/model/cbi/luci_fw/routing.lua deleted file mode 100644 index 364e69f62..000000000 --- a/applications/luci-fw/src/model/cbi/luci_fw/routing.lua +++ /dev/null @@ -1,28 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -require("luci.sys") -m = Map("luci_fw", "Routing", [[An dieser Stelle wird festlegt, welcher Netzverkehr zwischen einzelnen -Schnittstellen erlaubt werden soll. Es werden jeweils nur neue Verbindungen -betrachtet, d.h. Pakete von aufgebauten oder zugehörigen Verbindungen werden automatisch in beide Richtungen -akzeptiert, auch wenn das Feld "beide Richtungen" nicht explizit gesetzt ist. -NAT ermöglicht Adressübersetzung.]]) - -s = m:section(TypedSection, "routing") -s.template = "cbi/tblsection" -s.addremove = true -s.anonymous = true - -iface = s:option(ListValue, "iface", "Eingang", "Eingangsschnittstelle") -oface = s:option(ListValue, "oface", "Ausgang", "Ausgangsschnittstelle") - -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - oface:value(k) - end -end - -s:option(Flag, "fwd", "FWD", "weiterleiten").rmempty = true -s:option(Flag, "nat", "NAT", "übersetzen").rmempty = true -s:option(Flag, "bidi", "<->", "beide Richtungen").rmempty = true - -return m diff --git a/applications/luci-splash/luasrc/controller/splash/splash.lua b/applications/luci-splash/luasrc/controller/splash/splash.lua new file mode 100644 index 000000000..544f1e89e --- /dev/null +++ b/applications/luci-splash/luasrc/controller/splash/splash.lua @@ -0,0 +1,30 @@ +module("luci.controller.splash.splash", package.seeall) + +function index() + local page = node("admin", "services", "splash") + page.target = cbi("splash/splash") + page.title = "Client-Splash" + + node("splash", "splash", "activate").target = action_activate + node("splash", "splash", "allowed").target = action_allowed + node("splash", "splash", "unknown").target = action_unknown + node("splash", "splash", "splash").target = template("splash_splash/splash") +end + +function action_activate() + local mac = luci.sys.net.ip4mac(luci.http.env.REMOTE_ADDR) + if mac and luci.http.formvalue("accept") then + os.execute("luci-splash add "..mac.." >/dev/null 2>&1") + luci.http.redirect(luci.model.uci.get("freifunk", "community", "homepage")) + else + luci.http.redirect(luci.dispatcher.build_url()) + end +end + +function action_allowed() + luci.http.redirect(luci.dispatcher.build_url()) +end + +function action_unknown() + luci.http.redirect(luci.dispatcher.build_url()) +end \ No newline at end of file diff --git a/applications/luci-splash/luasrc/model/cbi/splash/splash.lua b/applications/luci-splash/luasrc/model/cbi/splash/splash.lua new file mode 100644 index 000000000..6050ac8a0 --- /dev/null +++ b/applications/luci-splash/luasrc/model/cbi/splash/splash.lua @@ -0,0 +1,30 @@ +-- ToDo: Translate, Add descriptions and help texts +require("luci.model.uci") + +m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]]) + +s = m:section(NamedSection, "general", "core", "Allgemein") +s:option(Value, "leasetime", "Freigabezeit", "h") + +s = m:section(TypedSection, "iface", "Schnittstellen") +s.addremove = true +s.anonymous = true + +iface = s:option(ListValue, "network", "Schnittstelle") +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + end +end + +s = m:section(TypedSection, "whitelist", "Automatische Freigabe") +s.addremove = true +s.anonymous = true +s:option(Value, "mac", "MAC-Adresse") + +s = m:section(TypedSection, "blacklist", "Automatische Sperrung") +s.addremove = true +s.anonymous = true +s:option(Value, "mac", "MAC-Adresse") + +return m \ No newline at end of file diff --git a/applications/luci-splash/luasrc/view/splash/splash.htm b/applications/luci-splash/luasrc/view/splash/splash.htm new file mode 100644 index 000000000..22631e08f --- /dev/null +++ b/applications/luci-splash/luasrc/view/splash/splash.htm @@ -0,0 +1,34 @@ +<% +local c = luci.model.uci.sections("freifunk").community + +

<%:welcome Willkommen%>!

+

+Du bist jetzt mit dem freien Funknetz +<%=c.name%> verbunden.
+Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. +

+ +

+Ein Zugang ins Internet ist trotzdem möglich, +da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. +Diese Zugänge müssen sich hier alle teilen. +Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: +

+

+ +

+Wenn Du unsere Idee gut findest, kannst Du uns unterstützen: +

+

+ +

+Mit einem Klick auf <%:accept Annehmen%> kannst du für <%=c.leasetime%> Stunden +über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. +

\ No newline at end of file diff --git a/applications/luci-splash/luasrc/view/splash_splash/index.htm b/applications/luci-splash/luasrc/view/splash_splash/index.htm new file mode 100644 index 000000000..75aa02658 --- /dev/null +++ b/applications/luci-splash/luasrc/view/splash_splash/index.htm @@ -0,0 +1,2 @@ +<%+header%> +<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/luasrc/view/splash_splash/splash.htm b/applications/luci-splash/luasrc/view/splash_splash/splash.htm new file mode 100644 index 000000000..9c165802f --- /dev/null +++ b/applications/luci-splash/luasrc/view/splash_splash/splash.htm @@ -0,0 +1,7 @@ +<%+header%> +<%+splash/splash%> +
+ + +
+<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/src/controller/splash/splash.lua b/applications/luci-splash/src/controller/splash/splash.lua deleted file mode 100644 index 544f1e89e..000000000 --- a/applications/luci-splash/src/controller/splash/splash.lua +++ /dev/null @@ -1,30 +0,0 @@ -module("luci.controller.splash.splash", package.seeall) - -function index() - local page = node("admin", "services", "splash") - page.target = cbi("splash/splash") - page.title = "Client-Splash" - - node("splash", "splash", "activate").target = action_activate - node("splash", "splash", "allowed").target = action_allowed - node("splash", "splash", "unknown").target = action_unknown - node("splash", "splash", "splash").target = template("splash_splash/splash") -end - -function action_activate() - local mac = luci.sys.net.ip4mac(luci.http.env.REMOTE_ADDR) - if mac and luci.http.formvalue("accept") then - os.execute("luci-splash add "..mac.." >/dev/null 2>&1") - luci.http.redirect(luci.model.uci.get("freifunk", "community", "homepage")) - else - luci.http.redirect(luci.dispatcher.build_url()) - end -end - -function action_allowed() - luci.http.redirect(luci.dispatcher.build_url()) -end - -function action_unknown() - luci.http.redirect(luci.dispatcher.build_url()) -end \ No newline at end of file diff --git a/applications/luci-splash/src/model/cbi/splash/splash.lua b/applications/luci-splash/src/model/cbi/splash/splash.lua deleted file mode 100644 index 6050ac8a0..000000000 --- a/applications/luci-splash/src/model/cbi/splash/splash.lua +++ /dev/null @@ -1,30 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -require("luci.model.uci") - -m = Map("luci_splash", "Client-Splash", [[Client-Splash ist das Freifunk Hotspot-Authentifizierungs-System.]]) - -s = m:section(NamedSection, "general", "core", "Allgemein") -s:option(Value, "leasetime", "Freigabezeit", "h") - -s = m:section(TypedSection, "iface", "Schnittstellen") -s.addremove = true -s.anonymous = true - -iface = s:option(ListValue, "network", "Schnittstelle") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - end -end - -s = m:section(TypedSection, "whitelist", "Automatische Freigabe") -s.addremove = true -s.anonymous = true -s:option(Value, "mac", "MAC-Adresse") - -s = m:section(TypedSection, "blacklist", "Automatische Sperrung") -s.addremove = true -s.anonymous = true -s:option(Value, "mac", "MAC-Adresse") - -return m \ No newline at end of file diff --git a/applications/luci-splash/src/view/splash/splash.htm b/applications/luci-splash/src/view/splash/splash.htm deleted file mode 100644 index 22631e08f..000000000 --- a/applications/luci-splash/src/view/splash/splash.htm +++ /dev/null @@ -1,34 +0,0 @@ -<% -local c = luci.model.uci.sections("freifunk").community - -

<%:welcome Willkommen%>!

-

-Du bist jetzt mit dem freien Funknetz -<%=c.name%> verbunden.
-Wir sind ein experimentelles Gemeinschaftsnetzwerk, aber kein Internetanbieter. -

- -

-Ein Zugang ins Internet ist trotzdem möglich, -da einige Freifunker ihre privaten Internetzugänge zur Verfügung stellen. -Diese Zugänge müssen sich hier alle teilen. -Bitte sei Dir dessen bewusst und verhalte Dich dementsprechend: -

-

- -

-Wenn Du unsere Idee gut findest, kannst Du uns unterstützen: -

-

- -

-Mit einem Klick auf <%:accept Annehmen%> kannst du für <%=c.leasetime%> Stunden -über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren. -

\ No newline at end of file diff --git a/applications/luci-splash/src/view/splash_splash/index.htm b/applications/luci-splash/src/view/splash_splash/index.htm deleted file mode 100644 index 75aa02658..000000000 --- a/applications/luci-splash/src/view/splash_splash/index.htm +++ /dev/null @@ -1,2 +0,0 @@ -<%+header%> -<%+footer%> \ No newline at end of file diff --git a/applications/luci-splash/src/view/splash_splash/splash.htm b/applications/luci-splash/src/view/splash_splash/splash.htm deleted file mode 100644 index 9c165802f..000000000 --- a/applications/luci-splash/src/view/splash_splash/splash.htm +++ /dev/null @@ -1,7 +0,0 @@ -<%+header%> -<%+splash/splash%> -
- - -
-<%+footer%> \ No newline at end of file diff --git a/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua new file mode 100644 index 000000000..df262a115 --- /dev/null +++ b/applications/luci-statistics/luasrc/controller/luci_statistics/luci_statistics.lua @@ -0,0 +1,107 @@ +module("luci.controller.luci_statistics.luci_statistics", package.seeall) + +local fs = require("luci.fs") +local tpl = require("luci.template") +local rrd = require("luci.statistics.rrdtool") +local data = require("luci.statistics.datatree").Instance() + + +function _entry( path, ... ) + local file = path[4] or path[3] + if fs.isfile( "/usr/lib/collectd/" .. file .. ".so" ) then + entry( path, ... ) + end +end + + +function index() + entry({"admin", "statistics"}, statistics_index, "Statistiken", 80) + entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), "Collectd", 10) + + entry({"admin", "statistics", "output"}, statistics_outputplugins, "Ausgabeplugins", 20) + _entry({"admin", "statistics", "output", "rrdtool"}, cbi("luci_statistics/rrdtool"), "RRDTool", 10) + _entry({"admin", "statistics", "output", "network"}, cbi("luci_statistics/network"), "Netzwerk", 20) + _entry({"admin", "statistics", "output", "unixsock"}, cbi("luci_statistics/unixsock"), "Unix Socket", 30) + _entry({"admin", "statistics", "output", "csv"}, cbi("luci_statistics/csv"), "CSV", 40) + + entry({"admin", "statistics", "system"}, statistics_systemplugins, "Systemplugins", 30) + _entry({"admin", "statistics", "system", "exec"}, cbi("luci_statistics/exec"), "Exec", 10) + _entry({"admin", "statistics", "system", "email"}, cbi("luci_statistics/email"), "E-Mail", 20) + _entry({"admin", "statistics", "system", "cpu"}, cbi("luci_statistics/cpu"), "Prozessor", 30) + _entry({"admin", "statistics", "system", "df"}, cbi("luci_statistics/df"), "Speicherplatz", 40) + _entry({"admin", "statistics", "system", "disk"}, cbi("luci_statistics/disk"), "Datenträger", 50) + _entry({"admin", "statistics", "system", "irq"}, cbi("luci_statistics/irq"), "Interrupts", 60) + _entry({"admin", "statistics", "system", "processes"}, cbi("luci_statistics/processes"), "Prozesse", 70) + + entry({"admin", "statistics", "network"}, statistics_networkplugins, "Netzwerkplugins", 40) + _entry({"admin", "statistics", "network", "interface"}, cbi("luci_statistics/interface"), "Schnittstellen", 10) + _entry({"admin", "statistics", "network", "netlink"}, cbi("luci_statistics/netlink"), "Netlink", 20) + _entry({"admin", "statistics", "network", "iptables"}, cbi("luci_statistics/iptables"), "Firewall", 30) + _entry({"admin", "statistics", "network", "tcpconns"}, cbi("luci_statistics/tcpconns"), "Verbindungen", 40) + _entry({"admin", "statistics", "network", "ping"}, cbi("luci_statistics/ping"), "Ping", 50) + _entry({"admin", "statistics", "network", "dns"}, cbi("luci_statistics/dns"), "DNS", 60) + + + -- public views + entry({"freifunk", "statistics"}, statistics_index, "Statistiken", 80) + + for i, plugin in ipairs( data:plugins() ) do + _entry({"freifunk", "statistics", plugin}, statistics_render, plugin, i) + end +end + + +function statistics_index() + tpl.render("admin_statistics/index") +end + +function statistics_outputplugins() + plugins = { + rrdtool="RRDTool", + network="Netzwerk", + unixsock="Unix Socket", + csv="CSV" + } + + tpl.render("admin_statistics/outputplugins", {plugins=plugins}) +end + +function statistics_systemplugins() + plugins = { + exec="Exec", + email="E-Mail", + disk="Datenträger", + irq="Interrupts", + processes="Prozesse" + } + + tpl.render("admin_statistics/systemplugins", {plugins=plugins}) +end + +function statistics_networkplugins() + plugins = { + interface="Schnittstellen", + netlink="Netlink", + iptables="Firewall", + tcpconns="Verbindungen", + ping="Ping", + dns="DNS" + } + + tpl.render("admin_statistics/networkplugins", {plugins=plugins}) +end + + +function statistics_render() + local plugin = luci.dispatcher.request[3] + local images = { } + + for i, inst in ipairs( data:plugin_instances( plugin ) ) do + local graph = rrd.Graph() + for i, img in ipairs( graph:render( "OpenWrt", plugin, inst ) ) do + table.insert( images, img ) + end + end + + tpl.render("public_statistics/graph", { images=images, plugin=plugin } ) +end diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/collectd.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/collectd.lua new file mode 100644 index 000000000..e09a11df1 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/collectd.lua @@ -0,0 +1,71 @@ +--[[ + +Luci configuration model for statistics - general collectd configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +require("luci.sys") + + +m = Map("luci_statistics", "Collector Daemon", +[[Collectd ist ein kleiner und flexibler Dienst zum Sammeln und Abfragen von Daten +aus verschieden Quellen. Zur weiteren Verarbeitung werden die Daten in RRD Datenbanken +gespeichert oder per Multicast Relaying über das Netzwerk versendet.]]) + +-- general config section +s = m:section( NamedSection, "general", "luci_statistics", "Allgemeine Einstellungen" ) + +-- general.basedir (BaseDir) +basedir = s:option( Value, "BaseDir", "Basisverzeichnis" ) +basedir.default = "/var/run/collectd" + +-- general.include (Include) +include = s:option( Value, "Include", "Verzeichnis für Unterkonfigurationen" ) +include.default = "/etc/collectd/conf.d/*.conf" + +-- general.pidfile (PIDFile) +pidfile = s:option( Value, "PIDFile", "PID-Datei für den Collector Dienst" ) +pidfile.default = "/var/run/collectd.pid" + +-- general.plugindir (PluginDir) +plugindir = s:option( Value, "PluginDir", "Verzeichnis für die Collector-Plugins" ) +plugindir.default = "/usr/lib/collectd/" + +-- general.typesdb (TypesDB) +typesdb = s:option( Value, "TypesDB", "Datenbank mit den Datenset-Beschreibungen" ) +typesdb.default = "/etc/collectd/types.db" + +-- general.interval (Interval) +interval = s:option( Value, "Interval", "Abfrageintervall für die Datenerfassung", "Sekunden" ) +interval.default = 60 +interval.isnumber = true + +-- general.readthreads (ReadThreads) +readthreads = s:option( Value, "ReadThreads", "Anzahl paralleler Prozesse für die Datenabfrage" ) +readthreads.default = 5 +readthreads.isnumber = true + +-- general.hostname (Hostname) +hostname = s:option( Value, "Hostname", "Hostname zur Identifikation des Collector Dienstes (leer lassen um den Namen automatisch zu bestimmen)" ) +hostname.default = luci.sys.hostname() +hostname.optional = true + +-- general.fqdnlookup (FQDNLookup) +fqdnlookup = s:option( Flag, "FQDNLookup", "Versuchen den vollen Hostnamen dieser Installation herauszufinden" ) +fqdnlookup.enabled = "true" +fqdnlookup.disabled = "false" +fqdnlookup.default = "false" +fqdnlookup.optional = true +fqdnlookup:depends( "Hostname", "" ) + + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/csv.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/csv.lua new file mode 100644 index 000000000..e1f2c351d --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/csv.lua @@ -0,0 +1,39 @@ +--[[ + +Luci configuration model for statistics - collectd csv plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "CSV Plugin", +[[Das CSV-Plugin schreibt in regelmäßigen Abständen die gesammelten Daten als +CSV-Dateien in das angegebene Verzeichnis. Der Speicherbedarf wächst dabei +kontinuierlich!]]) + +-- collectd_csv config section +s = m:section( NamedSection, "collectd_csv", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_csv.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_csv.datadir (DataDir) +datadir = s:option( Value, "DataDir", "Ablageverzeichnis für die CSV-Dateien" ) +datadir.default = "127.0.0.1" +datadir:depends( "enable", 1 ) + +-- collectd_csv.storerates (StoreRates) +storerates = s:option( Flag, "StoreRates", "Werte nicht absolut, sondern als Raten speichern" ) +storerates.default = 0 +storerates:depends( "enable", 1 ) + +return m + diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/df.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/df.lua new file mode 100644 index 000000000..6e35afcb3 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/df.lua @@ -0,0 +1,50 @@ +--[[ + +Luci configuration model for statistics - collectd df plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "DF Plugin", +[[Das DF-Plugin sammelt Informationen über den belegten und verfügbaren Speicherplatz auf den +angegebenen Geräten, Mountpunkten oder Dateisystemtypen.]]) + +-- collectd_df config section +s = m:section( NamedSection, "collectd_df", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_df.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_df.devices (Device) +devices = s:option( Value, "Devices", "Gerätedateien", "Einträge mit Leerzeichen trennen" ) +devices.default = "/dev/mtdblock/4" +devices.rmempty = true +devices:depends( "enable", 1 ) + +-- collectd_df.mountpoints (MountPoint) +mountpoints = s:option( Value, "MountPoints", "Mountpunkte", "Einträge mit Leerzeichen trennen" ) +mountpoints.default = "/jffs" +mountpoints.rmempty = true +mountpoints:depends( "enable", 1 ) + +-- collectd_df.fstypes (FSType) +fstypes = s:option( Value, "FSTypes", "Dateisystemtypen", "Einträge mit Leerzeichen trennen" ) +fstypes.default = "tmpfs" +fstypes.rmempty = true +fstypes:depends( "enable", 1 ) + +-- collectd_df.ignoreselected (IgnoreSelected) +ignoreselected = s:option( Flag, "IgnoreSelected", "Logik umkehren und alle Datenträger überwachen die nicht auf die obigen Kriterien zutreffen" ) +ignoreselected.default = 0 +ignoreselected:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/disk.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/disk.lua new file mode 100644 index 000000000..587091fbd --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/disk.lua @@ -0,0 +1,37 @@ +--[[ + +Luci configuration model for statistics - collectd disk plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Disk Plugin", +[[Das Disk-Plugin sammelt Informationen über Augewählte Fesplatten.]]) + +-- collectd_disk config section +s = m:section( NamedSection, "collectd_disk", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_disk.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_disk.disks (Disk) +devices = s:option( Value, "Disks", "Fesplatten oder Partitionen", "Einträge mit Leerzeichen trennen" ) +devices.default = "hda1 hdb" +devices.rmempty = true +devices:depends( "enable", 1 ) + +-- collectd_disk.ignoreselected (IgnoreSelected) +ignoreselected = s:option( Flag, "IgnoreSelected", "Logik umkehren und alle Datenträger und Partitionen überwachen die nicht auf die obigen Kriterien zutreffen" ) +ignoreselected.default = 0 +ignoreselected:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/dns.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/dns.lua new file mode 100644 index 000000000..dc7f57d68 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/dns.lua @@ -0,0 +1,42 @@ +--[[ + +Luci configuration model for statistics - collectd dns plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +require("luci.sys") + + +m = Map("luci_statistics", "DNS Plugin", +[[Das DNS-Plugin nutzt die pcap Bibliothek um DNS-Verkehr zu analysieren.]]) + +-- collectd_dns config section +s = m:section( NamedSection, "collectd_dns", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_dns.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_dns.interfaces (Interface) +interfaces = s:option( ListValue, "Interface", "Folgende Schnittstelle überwachen:" ) +interfaces:depends( "enable", 1 ) +interfaces:value("any") +for k, v in pairs(luci.sys.net.devices()) do + interfaces:value(v) +end + +-- collectd_dns.ignoresources (IgnoreSource) +ignoresources = s:option( Value, "IgnoreSources", "Verkehr von folgenden IP Adressen ignorieren:", "mehrere Einträge mit Leerzeichen trennen" ) +ignoresources.default = "127.0.0.1" +ignoresources:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/email.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/email.lua new file mode 100644 index 000000000..7b259e829 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/email.lua @@ -0,0 +1,55 @@ +--[[ + +Luci configuration model for statistics - collectd email plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "E-Mail Plugin", +[[Das E-Mail-Plugin öffnet einen Unix-Socket über welchen E-Mail Statistiken an collectd +übergeben werden können. Dieses Plugin ist primär für die Verwendung mit +Mail::SpamAssassin::Plugin::Collectd gedacht, lässt sich aber auch anderweitig einsetzen.]]) + +-- collectd_email config section +s = m:section( NamedSection, "collectd_email", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_email.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_email.socketfile (SocketFile) +socketfile = s:option( Value, "SocketFile", "Pfad für den Unix-Socket" ) +socketfile.default = "/var/run/collect-email.sock" +socketfile:depends( "enable", 1 ) + +-- collectd_email.socketgroup (SocketGroup) +socketgroup = s:option( Value, "SocketGroup", "Dateibesitzergruppe für den Unix-Socket ändern" ) +socketgroup.default = "nobody" +socketgroup.rmempty = true +socketgroup.optional = true +socketgroup:depends( "enable", 1 ) + +-- collectd_email.socketperms (SocketPerms) +socketperms = s:option( Value, "SocketPerms", "Dateiberechtigungen für den Unix-Socket ändern" ) +socketperms.default = "0770" +socketperms.rmempty = true +socketperms.optional = true +socketperms:depends( "enable", 1 ) + +-- collectd_email.maxconns (MaxConns) +maxconns = s:option( Value, "MaxConns", "Maximale Anzahl paralleler Verbindungen", "Werte von 1 bis 16384" ) +maxconns.default = 5 +maxconns.isinteger = true +maxconns.rmempty = true +maxconns.optional = true +maxconns:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/exec.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/exec.lua new file mode 100644 index 000000000..d1fe0f0db --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/exec.lua @@ -0,0 +1,77 @@ +--[[ + +Luci configuration model for statistics - collectd exec plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Exec Plugin", +[[Das Exec-Plugin ermöglicht das Ausführen von externen Programmen um Werte einzulesen +oder Aktionen beim Eintreten bestimmter Ereignisse anzustoßen.]]) + +-- collectd_exec config section +s = m:section( NamedSection, "collectd_exec", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_exec.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + + +-- collectd_exec_input config section (Exec directives) +exec = m:section( TypedSection, "collectd_exec_input", "Befehl zum Einlesen von Daten hinzufügen", +[[Hier können externe Kommandos definiert werden welche durch collectd gestartet werden um bestimmte +Daten zu sammeln. Die Werte werden dabei von der Standardausgabe des Programmes gelesen.]]) +exec.addremove = true +exec.anonymous = true + +-- collectd_exec_input.cmdline +exec_cmdline = exec:option( Value, "cmdline", "Kommandozeile" ) +exec_cmdline.default = "/usr/bin/stat-dhcpusers" + +-- collectd_exec_input.cmdline +exec_cmduser = exec:option( Value, "cmduser", "Als anderer Benutzer ausführen" ) +exec_cmduser.default = "nobody" +exec_cmduser.rmempty = true +exec_cmduser.optional = true + +-- collectd_exec_input.cmdline +exec_cmdgroup = exec:option( Value, "cmdgroup", "Als andere Gruppe ausführen" ) +exec_cmdgroup.default = "nogroup" +exec_cmdgroup.rmempty = true +exec_cmdgroup.optional = true + + +-- collectd_exec_notify config section (NotifyExec directives) +notify = m:section( TypedSection, "collectd_exec_notify", "Befehl zum Ausgeben von Daten hinzufügen", +[[Hier können externe Kommandos definiert werden welche zur Ausführung kommen sobald bestimmte +Ereignise eintreten. Die Daten werden dabei an die Standardeingabe des aufgerufenen Programmes gesendet. +Siehe dazu auch die Sektion "Limits".]]) +notify.addremove = true +notify.anonymous = true + +-- collectd_notify_input.cmdline +notify_cmdline = notify:option( Value, "cmdline", "Kommandozeile" ) +notify_cmdline.default = "/usr/bin/stat-dhcpusers" + +-- collectd_notify_input.cmdline +notify_cmduser = notify:option( Value, "cmduser", "Als anderer Benutzer ausführen" ) +notify_cmduser.default = "nobody" +notify_cmduser.rmempty = true +notify_cmduser.optional = true + +-- collectd_notify_input.cmdline +notify_cmdgroup = notify:option( Value, "cmdgroup", "Als andere Gruppe ausführen" ) +notify_cmdgroup.default = "nogroup" +notify_cmdgroup.rmempty = true +notify_cmdgroup.optional = true + + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/interface.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/interface.lua new file mode 100644 index 000000000..3cd71a15d --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/interface.lua @@ -0,0 +1,42 @@ +--[[ + +Luci configuration model for statistics - collectd interface plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +require("luci.sys") + + +m = Map("luci_statistics", "Interface Plugin", +[[Das Interface-Plugin sammelt Informationen zum Netzwerkverkehr auf den einzelnen Schnittstellen.]]) + +-- collectd_interface config section +s = m:section( NamedSection, "collectd_interface", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_interface.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_interface.interfaces (Interface) +interfaces = s:option( MultiValue, "Interfaces", "Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) +interfaces.widget = "select" +interfaces:depends( "enable", 1 ) +for k, v in pairs(luci.sys.net.devices()) do + interfaces:value(v) +end + +-- collectd_interface.ignoreselected (IgnoreSelected) +ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Schnittstellen außer ausgewählte überwachen" ) +ignoreselected.default = 0 +ignoreselected:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/iptables.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/iptables.lua new file mode 100644 index 000000000..4b6d9dbf4 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/iptables.lua @@ -0,0 +1,121 @@ +--[[ + +Luci configuration model for statistics - collectd iptables plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +require("luci.sys.iptparser") + +ip = luci.sys.iptparser.IptParser() +chains = { } +targets = { } + +for i, rule in ipairs( ip:find() ) do + chains[rule.chain] = true + targets[rule.target] = true +end + + +m = Map("luci_statistics", "Iptables Plugin", +[[Das Iptables-Plugin ermöglicht die Überwachung bestimmter Firewallregeln um +Werte wie die Anzahl der verarbeiteten Pakete oder die insgesamt erfasste Datenmenge +zu speichern.]]) + +-- collectd_iptables config section +s = m:section( NamedSection, "collectd_iptables", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_iptables.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + + +-- collectd_iptables_match config section (Chain directives) +rule = m:section( TypedSection, "collectd_iptables_match", "Regel hinzufügen", +[[Hier werden die Kriterien festgelegt, nach welchen die Firewall-Regeln zur Überwachung +ausgewählt werden.]]) +rule.addremove = true +rule.anonymous = true + + +-- collectd_iptables_match.name +rule_table = rule:option( Value, "name", "Name der Regel", "wird im Diagram verwendet" ) + +-- collectd_iptables_match.table +rule_table = rule:option( ListValue, "table", "Firewall-Tabelle" ) +rule_table.default = "filter" +rule_table.rmempty = true +rule_table.optional = true +rule_table:value("") +rule_table:value("filter") +rule_table:value("nat") +rule_table:value("mangle") + + +-- collectd_iptables_match.chain +rule_chain = rule:option( ListValue, "chain", "Firewall-Kette (Chain)" ) +rule_chain.rmempty = true +rule_chain.optional = true +rule_chain:value("") + +for chain, void in pairs( chains ) do + rule_chain:value( chain ) +end + + +-- collectd_iptables_match.target +rule_target = rule:option( ListValue, "target", "Firewall-Aktion (Target)" ) +rule_target.rmempty = true +rule_target.optional = true +rule_target:value("") + +for target, void in pairs( targets ) do + rule_target:value( target ) +end + + +-- collectd_iptables_match.protocol +rule_protocol = rule:option( ListValue, "protocol", "Netzwerkprotokoll" ) +rule_protocol.rmempty = true +rule_protocol.optional = true +rule_protocol:value("") +rule_protocol:value("tcp") +rule_protocol:value("udp") +rule_protocol:value("icmp") + +-- collectd_iptables_match.source +rule_source = rule:option( Value, "source", "Quell-IP-Bereich", "Bereich in CIDR Notation" ) +rule_source.default = "0.0.0.0/0" +rule_source.rmempty = true +rule_source.optional = true + +-- collectd_iptables_match.destination +rule_destination = rule:option( Value, "destination", "Ziel-IP-Bereich", "Bereich in CIDR Notation" ) +rule_destination.default = "0.0.0.0/0" +rule_destination.rmempty = true +rule_destination.optional = true + +-- collectd_iptables_match.inputif +rule_inputif = rule:option( Value, "inputif", "eingehende Schnittstelle", "z.B. eth0.0" ) +rule_inputif.rmempty = true +rule_inputif.optional = true + +-- collectd_iptables_match.outputif +rule_outputif = rule:option( Value, "outputif", "ausgehende Schnittstelle", "z.B. eth0.1" ) +rule_outputif.rmempty = true +rule_outputif.optional = true + +-- collectd_iptables_match.options +rule_options = rule:option( Value, "options", "Optionen", "z.B. reject-with tcp-reset" ) +rule_options.rmempty = true +rule_options.optional = true + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/irq.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/irq.lua new file mode 100644 index 000000000..2d15e5232 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/irq.lua @@ -0,0 +1,39 @@ +--[[ + +Luci configuration model for statistics - collectd irq plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "IRQ Plugin", +[[Das IRQ-Plugin sammelt Informationen zur Auslastung einzelner Interrupts. +Werden keine Interrupts angegeben, überwacht das Plugin alle vorhanden IRQs im System. +]]) + +-- collectd_irq config section +s = m:section( NamedSection, "collectd_irq", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_irq.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_irq.irqs (Irq) +irqs = s:option( Value, "Irqs", "Überwachte Interrupts", "mehrere mit Leerzeichen trennen" ) +irqs.optional = true +irqs:depends( "enable", 1 ) + +-- collectd_irq.ignoreselected (IgnoreSelected) +ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Interrupts außer ausgewählte überwachen" ) +ignoreselected.default = 0 +ignoreselected.optional = "true" +ignoreselected:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/netlink.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/netlink.lua new file mode 100644 index 000000000..a27def8eb --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/netlink.lua @@ -0,0 +1,84 @@ +--[[ + +Luci configuration model for statistics - collectd netlink plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +require("luci.sys") + + +m = Map("luci_statistics", "Interface Plugin", +[[Das Netlink-Plugin sammelt erweiterte Informationen wie Qdisc-, Class- und Filter-Werten auf einzelnen Schnittstellen.]]) + +-- collectd_netlink config section +s = m:section( NamedSection, "collectd_netlink", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_netlink.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_netlink.interfaces (Interface) +interfaces = s:option( MultiValue, "Interfaces", "einfach Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) +interfaces.widget = "select" +interfaces.optional = true +interfaces:depends( "enable", 1 ) +interfaces:value("") +for i, v in ipairs(luci.sys.net.devices()) do + interfaces:value(v) +end + +-- collectd_netlink.verboseinterfaces (VerboseInterface) +verboseinterfaces = s:option( MultiValue, "VerboseInterfaces", "detailliert Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) +verboseinterfaces.widget = "select" +verboseinterfaces.optional = true +verboseinterfaces:depends( "enable", 1 ) +verboseinterfaces:value("") +for i, v in ipairs(luci.sys.net.devices()) do + verboseinterfaces:value(v) +end + +-- collectd_netlink.qdiscs (QDisc) +qdiscs = s:option( MultiValue, "QDiscs", "Queue Discipline auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) +qdiscs.widget = "select" +qdiscs.optional = true +qdiscs:depends( "enable", 1 ) +qdiscs:value("") +for i, v in ipairs(luci.sys.net.devices()) do + qdiscs:value(v) +end + +-- collectd_netlink.classes (Class) +classs = s:option( MultiValue, "Classes", "Shapingklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) +classs.widget = "select" +classs.optional = true +classs:depends( "enable", 1 ) +classs:value("") +for i, v in ipairs(luci.sys.net.devices()) do + classs:value(v) +end + +-- collectd_netlink.filters (Filter) +filters = s:option( MultiValue, "Filters", "Filterklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) +filters.widget = "select" +filters.optional = true +filters:depends( "enable", 1 ) +filters:value("") +for i, v in ipairs(luci.sys.net.devices()) do + filters:value(v) +end + +-- collectd_netlink.ignoreselected (IgnoreSelected) +ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Schnittstellen außer ausgewählte überwachen" ) +ignoreselected.default = 0 +ignoreselected:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/network.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/network.lua new file mode 100644 index 000000000..ab3c6303c --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/network.lua @@ -0,0 +1,84 @@ +--[[ + +Luci configuration model for statistics - collectd network plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + + +m = Map("luci_statistics", "Network Plugin", +[[Das Network-Plugin ermöglicht den netzwerkgestützen Austausch von Statistikdaten.]]) + +-- collectd_network config section +s = m:section( NamedSection, "collectd_network", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_network.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + + +-- collectd_network_listen config section (Listen) +listen = m:section( TypedSection, "collectd_network_listen", "Schnittstellen für eingehende Verbindungen", +[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd auf eingehende Verbindungen wartet.]]) +listen.addremove = true +listen.anonymous = true + + +-- collectd_network_listen.host +listen_host = listen:option( Value, "host", "Listen-Host", "Host-, IP- oder IPv6-Adresse" ) +listen_host.default = "0.0.0.0" + +-- collectd_network_listen.port +listen_port = listen:option( Value, "port", "Listen-Port", "Partnummer 0 - 65535" ) +listen_port.default = 25826 +listen_port.isinteger = true +listen_port.optional = true + + +-- collectd_network_server config section (Server) +server = m:section( TypedSection, "collectd_network_server", "Schnittstellen für ausgehende Verbindungen", +[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd als Server agiert.]]) +server.addremove = true +server.anonymous = true + + +-- collectd_network_server.host +server_host = server:option( Value, "host", "Server-Host", "Host-, IP- oder IPv6-Adresse" ) +server_host.default = "0.0.0.0" + +-- collectd_network_server.port +server_port = server:option( Value, "port", "Server-Port", "Partnummer 0 - 65535" ) +server_port.default = 25826 +server_port.isinteger = true +server_port.optional = true + +-- collectd_network.timetolive (TimeToLive) +ttl = s:option( Value, "TimeToLive", "Time-to-Live für die Pakete", "Werte 0 bis 255" ) +ttl.default = 128 +ttl.isinteger = true +ttl.optional = true +ttl:depends( "enable", 1 ) + +-- collectd_network.forward (Forward) +forward = s:option( Flag, "Forward", "Weiterleitung zwischen verschiedenen Listen- und Server-Adressen" ) +forward.default = 0 +forward.optional = true +forward:depends( "enable", 1 ) + +-- collectd_network.forward (CacheFlush) +forward = s:option( Value, "CacheFlush", "Löschintervall für temporäre Daten", "in Sekunden" ) +forward.default = 86400 +forward.isinteger = true +forward.optional = true +forward:depends( "enable", 1 ) + + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/ping.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/ping.lua new file mode 100644 index 000000000..334a0300d --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/ping.lua @@ -0,0 +1,38 @@ +--[[ + +Luci configuration model for statistics - collectd ping plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Ping Plugin", +[[Das Ping-Plugin veranlasst periodische ICMP-Requests an die angegebenen Adressen und zeichnet +Parameter wie Verfügbarkeit und Antwortzeiten auf.]]) + +-- collectd_ping config section +s = m:section( NamedSection, "collectd_ping", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_ping.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_ping.hosts (Host) +hosts = s:option( Value, "Hosts", "Zieladressen", "Einträge durch Leerzeichen trennen" ) +hosts.default = "127.0.0.1" +hosts:depends( "enable", 1 ) + +-- collectd_ping.ttl (TTL) +ttl = s:option( Value, "TTL", "Time-to-Live für die ICMP-Pakete (Werte 0 bis 255)" ) +ttl.isinteger = true +ttl.default = 128 +ttl:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/processes.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/processes.lua new file mode 100644 index 000000000..354cecaf1 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/processes.lua @@ -0,0 +1,31 @@ +--[[ + +Luci configuration model for statistics - collectd processes plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Processes Plugin", +[[Das Processes-Plugin sammelt Informationen über ausgewählte Prozesse auf diesem Gerät.]]) + +-- collectd_processes config section +s = m:section( NamedSection, "collectd_processes", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_processes.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_processes.processes (Process) +processes = s:option( Value, "Processes", "Überwachte Prozesse", "mehrere mit Leerzeichen trennen" ) +processes.default = "olsrd bmxd httpd dnsmasq dropbear tinc" +processes:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua new file mode 100644 index 000000000..89adf52a7 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/rrdtool.lua @@ -0,0 +1,99 @@ +--[[ + +Luci configuration model for statistics - collectd rrdtool plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "RRDTool Plugin", +[[Das RRDTool-Plugin schreibt die gesammelten Werte in sogenannte RRD Datenbanken, welche die +Grundlage für die Statistik-Diagramme bilden.

+Die Einstellungen auf dieser Seite sollten nur in Ausnahmefällen geändert werden, +falsche Einstellungen führen zu einem sehr hohem Platzverbrauch im Temp-Verzeichnis und das +Gerät kann nur noch im Failsafe-Modus repariert werden!]]) + +-- collectd_rrdtool config section +s = m:section( NamedSection, "collectd_rrdtool", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_rrdtool.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 1 + +-- collectd_rrdtool.datadir (DataDir) +datadir = s:option( Value, "DataDir", "Speicherort für die RRD Datenbanken" ) +datadir.default = "/tmp" +datadir.rmempty = true +datadir.optional = true +datadir:depends( "enable", 1 ) + +-- collectd_rrdtool.stepsize (StepSize) +stepsize = s:option( Value, "StepSize", "Schritt-Interval", "in Sekunden" ) +stepsize.default = 30 +stepsize.isinteger = true +stepsize.rmempty = true +stepsize.optional = true +stepsize:depends( "enable", 1 ) + +-- collectd_rrdtool.heartbeat (HeartBeat) +heartbeat = s:option( Value, "HeartBeat", "Heart-Beat-Interval", "in Sekunden" ) +heartbeat.default = 60 +heartbeat.isinteger = true +heartbeat.rmempty = true +heartbeat.optional = true +heartbeat:depends( "enable", 1 ) + +-- collectd_rrdtool.rrasingle (RRASingle) +rrasingle = s:option( Flag, "RRASingle", 'Jeweils nur ein RRA anlegen', "reduziert die Größe der RRDs" ) +rrasingle.default = true +rrasingle.rmempty = true +rrasingle.optional = true +rrasingle:depends( "enable", 1 ) + +-- collectd_rrdtool.rratimespans (RRATimespan) +rratimespans = s:option( Value, "RRATimespans", "Gespeicherte Zeitspannen", "in Sekunden; mehrere mit Leerzeichen trennen" ) +rratimespans.default = "600 86400 604800 2678400 31622400" +rratimespans.rmempty = true +rratimespans.optional = true +rratimespans:depends( "enable", 1 ) + +-- collectd_rrdtool.rrarows (RRARows) +rrarows = s:option( Value, "RRARows", "Anzahl der Datenpunkte pro Zeitspanne" ) +rrarows.isinteger = true +rrarows.default = 100 +rrarows.rmempty = true +rrarows.optional = true +rrarows:depends( "enable", 1 ) + +-- collectd_rrdtool.xff (XFF) +xff = s:option( Value, "XFF", "RRD XFiles Faktor" ) +xff.default = 0.1 +xff.isnumber = true +xff.rmempty = true +xff.optional = true +xff:depends( "enable", 1 ) + +-- collectd_rrdtool.cachetimeout (CacheTimeout) +cachetimeout = s:option( Value, "CacheTimeout", "Daten für Zeitspanne cachen", "in Sekunden" ) +cachetimeout.isinteger = true +cachetimeout.default = 100 +cachetimeout.rmempty = true +cachetimeout.optional = true +cachetimeout:depends( "enable", 1 ) + +-- collectd_rrdtool.cacheflush (CacheFlush) +cacheflush = s:option( Value, "CacheFlush", "Cache nach Zeitspanne leeren", "in Sekunden" ) +cacheflush.isinteger = true +cacheflush.default = 100 +cacheflush.rmempty = true +cacheflush.optional = true +cacheflush:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/tcpconns.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/tcpconns.lua new file mode 100644 index 000000000..079befac5 --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/tcpconns.lua @@ -0,0 +1,41 @@ +--[[ + +Luci configuration model for statistics - collectd tcpconns plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Tcpconns Plugin", +[[Das Tcpconns-Plugin zählt TCP-Verbindungen auf einzelnen Ports.]]) + +-- collectd_tcpconns config section +s = m:section( NamedSection, "collectd_tcpconns", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_tcpconns.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_tcpconns.listeningports (ListeningPorts) +listeningports = s:option( Flag, "ListeningPorts", "Alle von lokalen Diensten genutzen Ports überwachen" ) +listeningports.default = 1 +listeningports:depends( "enable", 1 ) + +-- collectd_tcpconns.localports (LocalPort) +localports = s:option( Value, "LocalPorts", "Lokale Ports", "mit Leerzeichen trennen" ) +localports.optional = true +localports:depends( "enable", 1 ) + +-- collectd_tcpconns.remoteports (RemotePort) +remoteports = s:option( Value, "RemotePorts", "Entfernte Ports", "mit Leerzeichen trennen" ) +remoteports.optional = true +remoteports:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/model/cbi/luci_statistics/unixsock.lua b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/unixsock.lua new file mode 100644 index 000000000..dcedd381b --- /dev/null +++ b/applications/luci-statistics/luasrc/model/cbi/luci_statistics/unixsock.lua @@ -0,0 +1,46 @@ +--[[ + +Luci configuration model for statistics - collectd unixsock plugin configuration +(c) 2008 Freifunk Leipzig / 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 + +$Id$ + +]]-- + +m = Map("luci_statistics", "Unixsock Plugin", +[[Das Unixsock-Plugin öffnet einen Socket über welchen die gesammelten Werte des +laufenden collectd Prozesses abgefragt werden können.]]) + +-- collectd_unixsock config section +s = m:section( NamedSection, "collectd_unixsock", "luci_statistics", "Pluginkonfiguration" ) + +-- collectd_unixsock.enable +enable = s:option( Flag, "enable", "Plugin aktivieren" ) +enable.default = 0 + +-- collectd_unixsock.socketfile (SocketFile) +socketfile = s:option( Value, "SocketFile", "Pfad für den Unix-Socket" ) +socketfile.default = "/var/run/collect-query.socket" +socketfile:depends( "enable", 1 ) + +-- collectd_unixsock.socketgroup (SocketGroup) +socketgroup = s:option( Value, "SocketGroup", "Dateibesitzergruppe für den Unix-Socket ändern" ) +socketgroup.default = "nobody" +socketgroup.rmempty = true +socketgroup.optional = true +socketgroup:depends( "enable", 1 ) + +-- collectd_unixsock.socketperms (SocketPerms) +socketperms = s:option( Value, "SocketPerms", "Dateiberechtigungen für den Unix-Socket ändern" ) +socketperms.default = "0770" +socketperms.rmempty = true +socketperms.optional = true +socketperms:depends( "enable", 1 ) + +return m diff --git a/applications/luci-statistics/luasrc/statistics/datatree.lua b/applications/luci-statistics/luasrc/statistics/datatree.lua new file mode 100644 index 000000000..957b230a9 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/datatree.lua @@ -0,0 +1,134 @@ +module("luci.statistics.datatree", package.seeall) + +local util = require("luci.util") +local sys = require("luci.sys") +local fs = require("luci.fs") +local uci = require("luci.model.uci").Session() +local sections, names = uci:sections( "luci_statistics" ) + + +Instance = util.class() + +function Instance.__init__( self, host ) + self._host = host or sections.collectd.Hostname or sys.hostname() + self._libdir = sections.collectd.PluginDir or "/usr/lib/collectd" + self._rrddir = sections.collectd_rrdtool.DataDir or "/tmp" + + self._libdir = self._libdir:gsub("/$","") + self._rrddir = self._rrddir:gsub("/$","") + self._plugins = { } + + self:_scan() +end + +function Instance._mkpath( self, plugin, pinstance ) + local dir = self._rrddir .. "/" .. self._host + + if type(plugin) == "string" and plugin:len() > 0 then + dir = dir .. "/" .. plugin + + if type(pinstance) == "string" and pinstance:len() > 0 then + dir = dir .. "-" .. pinstance + end + end + + return dir +end + +function Instance._notzero( self, table ) + for k in pairs(table) do + return true + end + + return false +end + +function Instance._scan( self ) + for i, plugin in ipairs( fs.dir( self._libdir ) ) do + if plugin:match("%w+.so") then + self._plugins[ plugin:gsub(".so", "") ] = { } + end + end + + for plugin, instances in pairs( self._plugins ) do + for i, dir in ipairs( fs.dir( self:_mkpath() ) ) do + if dir:find( plugin .. "%-" ) or dir == plugin then + local instance = "" + + if dir ~= plugin then + instance = dir:gsub( plugin .. "%-", "", 1 ) + end + + instances[instance] = { } + end + end + + for instance, data_instances in pairs( instances ) do + for i, file in ipairs( fs.dir( self:_mkpath( plugin, instance ) ) ) do + if file:find("%.rrd") then + file = file:gsub("%.rrd","") + + local data_type + local data_instance + + if file:find("%-") then + data_type = file:gsub( "%-.+","" ) + data_instance = file:gsub( "[^%-]-%-", "", 1 ) + else + data_type = file + data_instance = "" + end + + if not data_instances[data_type] then + data_instances[data_type] = { data_instance } + else + table.insert( data_instances[data_type], data_instance ) + end + end + end + end + end +end + + +function Instance.plugins( self ) + local rv = { } + + for plugin, val in pairs( self._plugins ) do + if self:_notzero( val ) then + table.insert( rv, plugin ) + end + end + + return rv +end + +function Instance.plugin_instances( self, plugin ) + local rv = { } + + for instance, val in pairs( self._plugins[plugin] ) do + table.insert( rv, instance ) + end + + return rv +end + +function Instance.data_types( self, plugin, instance ) + local rv = { } + + for type, val in pairs( self._plugins[plugin][instance] ) do + table.insert( rv, type ) + end + + return rv +end + +function Instance.data_instances( self, plugin, instance, type ) + local rv = { } + + for i, instance in ipairs( self._plugins[plugin][instance][type] ) do + table.insert( rv, instance ) + end + + return rv +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool.lua b/applications/luci-statistics/luasrc/statistics/rrdtool.lua new file mode 100644 index 000000000..b399866a8 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool.lua @@ -0,0 +1,264 @@ +module("luci.statistics.rrdtool", package.seeall) + +require("luci.statistics.datatree") +require("luci.statistics.rrdtool.colors") +require("luci.statistics.rrdtool.definitions") +require("luci.util") +require("luci.bits") +require("luci.fs") + + +Graph = luci.util.class() + +function Graph.__init__( self, timespan, opts ) + + opts = opts or { } + opts.width = opts.width or "400" + + self.colors = luci.statistics.rrdtool.colors.Instance() + self.defs = luci.statistics.rrdtool.definitions.Instance() + self.tree = luci.statistics.datatree.Instance() + + -- rrdtool defalt args + self.args = { + "-a", "PNG", + "-s", "NOW-" .. ( timespan or 900 ), + "-w", opts.width + } +end + +function Graph.mktitle( self, host, plugin, plugin_instance, dtype, dtype_instance ) + local t = host .. "/" .. plugin + if type(plugin_instance) == "string" and plugin_instance:len() > 0 then + t = t .. "-" .. plugin_instance + end + t = t .. "/" .. dtype + if type(dtype_instance) == "string" and dtype_instance:len() > 0 then + t = t .. "-" .. dtype_instance + end + return t +end + +function Graph.mkrrdpath( self, ... ) + return string.format( "/tmp/%s.rrd", self:mktitle( ... ) ) +end + +function Graph.mkpngpath( self, ... ) + return string.format( "/tmp/rrdimg/%s.png", self:mktitle( ... ) ) +end + +function Graph._push( self, elem ) + + if type(elem) == "string" then + table.insert( self.args, elem ) + else + for i, item in ipairs(elem) do + table.insert( self.args, item ) + end + end + + return( self.args ) +end + +function Graph._clearargs( self ) + for i = #self.args, 7, -1 do + table.remove( self.args, i ) + end +end + +function Graph._forcelol( self, list ) + if type(list[1]) ~= "table" then + return( { list } ) + end + return( list ) +end + +function Graph._rrdtool( self, png, rrd ) + + -- prepare directory + local dir = png:gsub("/[^/]+$","") + luci.fs.mkdir( dir, true ) + + -- construct commandline + local cmdline = "rrdtool graph " .. png + + for i, opt in ipairs(self.args) do + + opt = opt .. "" -- force string + + if rrd then + opt = opt:gsub( "{file}", rrd ) + end + + if opt:match("[^%w]") then + cmdline = cmdline .. " '" .. opt .. "'" + else + cmdline = cmdline .. " " .. opt + end + end + + -- execute rrdtool + local rrdtool = io.popen( cmdline ) + rrdtool:close() +end + +function Graph._generic( self, opts ) + + local images = { } + + -- remember images + table.insert( images, opts.image ) + + -- insert provided addition rrd options + self:_push( { "-t", opts.title or "Unknown title" } ) + self:_push( opts.rrd ) + + -- construct an array of safe instance names + local inst_names = { } + for i, source in ipairs(opts.sources) do + inst_names[i] = i .. source.name:gsub("[^A-Za-z0-9%-_]","_") + end + + -- create DEF statements for each instance, find longest instance name + local longest_name = 0 + for i, source in ipairs(opts.sources) do + if source.name:len() > longest_name then + longest_name = source.name:len() + end + + local ds = source.ds or "value" + + self:_push( "DEF:" .. inst_names[i] .. "_min=" ..source.rrd .. ":" .. ds .. ":MIN" ) + self:_push( "DEF:" .. inst_names[i] .. "_avg=" ..source.rrd .. ":" .. ds .. ":AVERAGE" ) + self:_push( "DEF:" .. inst_names[i] .. "_max=" ..source.rrd .. ":" .. ds .. ":MAX" ) + self:_push( "CDEF:" .. inst_names[i] .. "_nnl=" .. inst_names[i] .. "_avg,UN,0," .. inst_names[i] .. "_avg,IF" ) + end + + -- create CDEF statement for last instance name + self:_push( "CDEF:" .. inst_names[#inst_names] .. "_stk=" .. inst_names[#inst_names] .. "_nnl" ) + + -- create CDEF statements for each instance + for i, source in ipairs(inst_names) do + if i > 1 then + self:_push( + "CDEF:" .. + inst_names[1 + #inst_names - i] .. "_stk=" .. + inst_names[1 + #inst_names - i] .. "_nnl," .. + inst_names[2 + #inst_names - i] .. "_stk,+" + ) + end + end + + -- create LINE and GPRINT statements for each instance + for i, source in ipairs(opts.sources) do + + local legend = string.format( + "%-" .. longest_name .. "s", + source.name + ) + + local numfmt = opts.number_format or "%6.1lf" + + local line_color + local area_color + + -- find color: try source, then opts.colors; fall back to random color + if type(source.color) == "string" then + line_color = source.color + area_color = self.colors:from_string( line_color ) + elseif type(opts.colors[source.name:gsub("[^%w]","_")]) == "string" then + line_color = opts.colors[source.name:gsub("[^%w]","_")] + area_color = self.colors:from_string( line_color ) + else + area_color = self.colors:random() + line_color = self.colors:to_string( area_color ) + end + + -- derive area background color from line color + area_color = self.colors:to_string( self.colors:faded( area_color ) ) + + + self:_push( "AREA:" .. inst_names[i] .. "_stk#" .. area_color ) + self:_push( "LINE1:" .. inst_names[i] .. "_stk#" .. line_color .. ":" .. legend ) + self:_push( "GPRINT:" .. inst_names[i] .. "_min:MIN:" .. numfmt .. " Min" ) + self:_push( "GPRINT:" .. inst_names[i] .. "_avg:AVERAGE:" .. numfmt .. " Avg" ) + self:_push( "GPRINT:" .. inst_names[i] .. "_max:MAX:" .. numfmt .. " Max" ) + self:_push( "GPRINT:" .. inst_names[i] .. "_avg:LAST:" .. numfmt .. " Last\\l" ) + end + + return images +end + +function Graph.render( self, host, plugin, plugin_instance ) + + dtype_instances = dtype_instances or { "" } + local pngs = { } + + -- check for a whole graph handler + local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin + local stat, def = pcall( require, plugin_def ) + + if stat and def and type(def.rrdargs) == "function" then + for i, opts in ipairs( self:_forcelol( def.rrdargs( self, host, plugin, plugin_instance, dtype ) ) ) do + for i, png in ipairs( self:_generic( opts ) ) do + table.insert( pngs, png ) + + -- exec + self:_rrdtool( png ) + + -- clear args + self:_clearargs() + end + end + else + + -- no graph handler, iterate over data types + for i, dtype in ipairs( self.tree:data_types( plugin, plugin_instance ) ) do + + -- check for data type handler + local dtype_def = plugin_def .. "." .. dtype + local stat, def = pcall( require, dtype_def ) + + if stat and def and type(def.rrdargs) == "function" then + for i, opts in ipairs( self:_forcelol( def.rrdargs( self, host, plugin, plugin_instance, dtype ) ) ) do + for i, png in ipairs( self:_generic( opts ) ) do + table.insert( pngs, png ) + + -- exec + self:_rrdtool( png ) + + -- clear args + self:_clearargs() + end + end + else + + -- no data type handler, fall back to builtin definition + if type(self.defs.definitions[dtype]) == "table" then + + -- iterate over data type instances + for i, inst in ipairs( self.tree:data_instances( plugin, plugin_instance, dtype ) ) do + + local title = self:mktitle( host, plugin, plugin_instance, dtype, inst ) + local png = self:mkpngpath( host, plugin, plugin_instance, dtype, inst ) + local rrd = self:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + + self:_push( { "-t", title } ) + self:_push( self.defs.definitions[dtype] ) + + table.insert( pngs, png ) + + -- exec + self:_rrdtool( png, rrd ) + + -- clear args + self:_clearargs() + end + end + end + end + end + + return pngs +end + diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua new file mode 100644 index 000000000..cdd6f7105 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/colors.lua @@ -0,0 +1,59 @@ +module("luci.statistics.rrdtool.colors", package.seeall) + +require("luci.util") +require("luci.bits") + + +Instance = luci.util.class() + +function Instance.from_string( self, s ) + return { + luci.bits.Hex2Dec(s:sub(1,2)), + luci.bits.Hex2Dec(s:sub(3,4)), + luci.bits.Hex2Dec(s:sub(5,6)) + } +end + +function Instance.to_string( self, c ) + return string.format( + "%02x%02x%02x", + math.floor(c[1]), + math.floor(c[2]), + math.floor(c[3]) + ) +end + +function Instance.random( self ) + local r = math.random(255) + local g = math.random(255) + local min = 0 + local max = 255 + + if ( r + g ) < 255 then + min = 255 - r - g + else + max = 511 - r - g + end + + local b = min + math.floor( math.random() * ( max - min ) ) + + return { r, g, b } +end + +function Instance.faded( self, fg, opts ) + opts = opts or {} + opts.background = opts.background or { 255, 255, 255 } + opts.alpha = opts.alpha or 0.25 + + if type(opts.background) == "string" then + opts.background = _string_to_color(opts.background) + end + + local bg = opts.background + + return { + ( opts.alpha * fg[1] ) + ( ( 1.0 - opts.alpha ) * bg[1] ), + ( opts.alpha * fg[2] ) + ( ( 1.0 - opts.alpha ) * bg[2] ), + ( opts.alpha * fg[3] ) + ( ( 1.0 - opts.alpha ) * bg[3] ) + } +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua new file mode 100644 index 000000000..add69e4b6 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions.lua @@ -0,0 +1,3177 @@ +module("luci.statistics.rrdtool.definitions", package.seeall) + +require("luci.util") +require("luci.fs") + + +Instance = luci.util.class() + +function Instance.__init__( self, ... ) + + -- used color palette + self.palette = { + Canvas = "FFFFFF", + FullRed = "FF0000", + FullGreen = "00E000", + FullBlue = "0000FF", + FullYellow = "F0A000", + FullCyan = "00A0FF", + FullMagenta = "A000FF", + HalfRed = "F7B7B7", + HalfGreen = "B7EFB7", + HalfBlue = "B7B7F7", + HalfYellow = "F3DFB7", + HalfCyan = "B7DFF7", + HalfMagenta = "DFB7F7", + HalfBlueGreen = "89B3C9" + } + + -- plotting arguments for each defined datasource + self.definitions = { + apache_bytes = { + "DEF:min_raw={file}:count:MIN", + "DEF:avg_raw={file}:count:AVERAGE", + "DEF:max_raw={file}:count:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "CDEF:mytime=avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bit/s", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + apache_requests = { + "DEF:min={file}:count:MIN", + "DEF:avg={file}:count:AVERAGE", + "DEF:max={file}:count:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Requests/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + apache_scoreboard = { + "DEF:min={file}:count:MIN", + "DEF:avg={file}:count:AVERAGE", + "DEF:max={file}:count:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + bitrate = { + "-v", "Bits/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Average,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + charge = { + "-v", "Ah", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Charge", + "GPRINT:min:MIN:%5.1lf%sAh Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,", + "GPRINT:max:MAX:%5.1lf%sAh Max,", + "GPRINT:avg:LAST:%5.1lf%sAh Last\\l" + }, + + __cpu = { + "-v", "CPU load", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", + "GPRINT:min:MIN:%6.2lf%% Min,", + "GPRINT:avg:AVERAGE:%6.2lf%% Avg,", + "GPRINT:max:MAX:%6.2lf%% Max,", + "GPRINT:avg:LAST:%6.2lf%% Last\\l" + }, + + current = { + "-v", "Ampere", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Current", + "GPRINT:min:MIN:%5.1lf%sA Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sA Avg,", + "GPRINT:max:MAX:%5.1lf%sA Max,", + "GPRINT:avg:LAST:%5.1lf%sA Last\\l" + }, + + df = { + "-v", "Percent", "-l", "0", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:free_min={file}:free:MIN", + "DEF:free_max={file}:free:MAX", + "DEF:used_avg={file}:used:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:used_max={file}:used:MAX", + "CDEF:total=free_avg,used_avg,+", + "CDEF:free_pct=100,free_avg,*,total,/", + "CDEF:used_pct=100,used_avg,*,total,/", + "CDEF:free_acc=free_pct,used_pct,+", + "CDEF:used_acc=used_pct", + "AREA:free_acc#" .. self.palette.HalfGreen, + "AREA:used_acc#" .. self.palette.HalfRed, + "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free", + "GPRINT:free_min:MIN:%5.1lf%sB Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,", + "GPRINT:free_max:MAX:%5.1lf%sB Max,", + "GPRINT:free_avg:LAST:%5.1lf%sB Last\\l", + "LINE1:used_acc#" .. self.palette.FullRed .. ":Used", + "GPRINT:used_min:MIN:%5.1lf%sB Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,", + "GPRINT:used_max:MAX:%5.1lf%sB Max,", + "GPRINT:used_avg:LAST:%5.1lf%sB Last\\l" + }, + + disk = { + "DEF:rtime_avg={file}:rtime:AVERAGE", + "DEF:rtime_min={file}:rtime:MIN", + "DEF:rtime_max={file}:rtime:MAX", + "DEF:wtime_avg={file}:wtime:AVERAGE", + "DEF:wtime_min={file}:wtime:MIN", + "DEF:wtime_max={file}:wtime:MAX", + "CDEF:rtime_avg_ms=rtime_avg,1000,/", + "CDEF:rtime_min_ms=rtime_min,1000,/", + "CDEF:rtime_max_ms=rtime_max,1000,/", + "CDEF:wtime_avg_ms=wtime_avg,1000,/", + "CDEF:wtime_min_ms=wtime_min,1000,/", + "CDEF:wtime_max_ms=wtime_max,1000,/", + "CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+", + "CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+", + "CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+", + "AREA:total_max_ms#" .. self.palette.HalfRed, + "AREA:total_min_ms#" .. self.palette.Canvas, + "LINE1:wtime_avg_ms#" .. self.palette.FullGreen .. ":Write", + "GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n", + "LINE1:rtime_avg_ms#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n", + "LINE1:total_avg_ms#" .. self.palette.FullRed .. ":Total", + "GPRINT:total_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:total_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:total_avg_ms:LAST:%5.1lf%s Last\\l" + }, + + disk_octets = { + "-v", "Bytes/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "CDEF:mytime=out_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_max:MAX:%5.1lf%s Max,", + "GPRINT:out_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + disk_merged = { + "-v", "Merged Ops/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:out_max:MAX:%6.2lf Max,", + "GPRINT:out_avg:LAST:%6.2lf Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:inc_max:MAX:%6.2lf Max,", + "GPRINT:inc_avg:LAST:%6.2lf Last\\l" + }, + + disk_ops = { + "-v", "Ops/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:out_max:MAX:%6.2lf Max,", + "GPRINT:out_avg:LAST:%6.2lf Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:inc_max:MAX:%6.2lf Max,", + "GPRINT:inc_avg:LAST:%6.2lf Last\\l" + }, + + disk_time = { + "-v", "Seconds/s", + "DEF:out_min_raw={file}:write:MIN", + "DEF:out_avg_raw={file}:write:AVERAGE", + "DEF:out_max_raw={file}:write:MAX", + "DEF:inc_min_raw={file}:read:MIN", + "DEF:inc_avg_raw={file}:read:AVERAGE", + "DEF:inc_max_raw={file}:read:MAX", + "CDEF:out_min=out_min_raw,1000,/", + "CDEF:out_avg=out_avg_raw,1000,/", + "CDEF:out_max=out_max_raw,1000,/", + "CDEF:inc_min=inc_min_raw,1000,/", + "CDEF:inc_avg=inc_avg_raw,1000,/", + "CDEF:inc_max=inc_max_raw,1000,/", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%5.1lf%ss Avg,", + "GPRINT:out_max:MAX:%5.1lf%ss Max,", + "GPRINT:out_avg:LAST:%5.1lf%ss Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%5.1lf%ss Avg,", + "GPRINT:inc_max:MAX:%5.1lf%ss Max,", + "GPRINT:inc_avg:LAST:%5.1lf%ss Last\\l" + }, + + dns_octets = { + "DEF:rsp_min_raw={file}:responses:MIN", + "DEF:rsp_avg_raw={file}:responses:AVERAGE", + "DEF:rsp_max_raw={file}:responses:MAX", + "DEF:qry_min_raw={file}:queries:MIN", + "DEF:qry_avg_raw={file}:queries:AVERAGE", + "DEF:qry_max_raw={file}:queries:MAX", + "CDEF:rsp_min=rsp_min_raw,8,*", + "CDEF:rsp_avg=rsp_avg_raw,8,*", + "CDEF:rsp_max=rsp_max_raw,8,*", + "CDEF:qry_min=qry_min_raw,8,*", + "CDEF:qry_avg=qry_avg_raw,8,*", + "CDEF:qry_max=qry_max_raw,8,*", + "CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF", + "CDEF:mytime=rsp_avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*", + "CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+", + "CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*", + "CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+", + "AREA:rsp_avg#" .. self.palette.HalfGreen, + "AREA:qry_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:rsp_avg#" .. self.palette.FullGreen .. ":Responses", + "GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rsp_max:MAX:%5.1lf%s Max,", + "GPRINT:rsp_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:qry_avg#" .. self.palette.FullBlue .. ":Queries ", + #"GPRINT:qry_min:MIN:%5.1lf %s Min,", + "GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:qry_max:MAX:%5.1lf%s Max,", + "GPRINT:qry_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + dns_opcode = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Queries/s", + "GPRINT:min:MIN:%9.3lf Min,", + "GPRINT:avg:AVERAGE:%9.3lf Average,", + "GPRINT:max:MAX:%9.3lf Max,", + "GPRINT:avg:LAST:%9.3lf Last\\l" + }, + + email_count = { + "-v", "Mails", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + email_size = { + "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + spam_score = { + "-v", "Score", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Score ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + spam_check = { + "DEF:avg={file}:hits:AVERAGE", + "DEF:min={file}:hits:MIN", + "DEF:max={file}:hits:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + entropy = { + "-v", "Bits", + "DEF:avg={file}:entropy:AVERAGE", + "DEF:min={file}:entropy:MIN", + "DEF:max={file}:entropy:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits", + "GPRINT:min:MIN:%4.0lfbit Min,", + "GPRINT:avg:AVERAGE:%4.0lfbit Avg,", + "GPRINT:max:MAX:%4.0lfbit Max,", + "GPRINT:avg:LAST:%4.0lfbit Last\\l" + }, + + fanspeed = { + "-v", "RPM", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":RPM", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + frequency = { + "-v", "Hertz", + "DEF:avg={file}:frequency:AVERAGE", + "DEF:min={file}:frequency:MIN", + "DEF:max={file}:frequency:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Frequency [Hz]", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + frequency_offset = { + "DEF:ppm_avg={file}:ppm:AVERAGE", + "DEF:ppm_min={file}:ppm:MIN", + "DEF:ppm_max={file}:ppm:MAX", + "AREA:ppm_max#" .. self.palette.HalfBlue, + "AREA:ppm_min#" .. self.palette.Canvas, + "LINE1:ppm_avg#" .. self.palette.FullBlue .. ":{inst}", + "GPRINT:ppm_min:MIN:%5.2lf Min,", + "GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:ppm_max:MAX:%5.2lf Max,", + "GPRINT:ppm_avg:LAST:%5.2lf Last\\l" + }, + + gauge = { + "-v", "Exec value", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfBlue, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullBlue .. ":Exec value", + "GPRINT:temp_min:MIN:%6.2lf Min,", + "GPRINT:temp_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:temp_max:MAX:%6.2lf Max,", + "GPRINT:temp_avg:LAST:%6.2lf Last\\l" + }, + + hddtemp = { + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfRed, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", + "GPRINT:temp_max:MAX:%4.1lf Max,", + "GPRINT:temp_avg:LAST:%4.1lf Last\\l" + }, + + humidity = { + "-v", "Percent", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfGreen, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullGreen .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf%% Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,", + "GPRINT:temp_max:MAX:%4.1lf%% Max,", + "GPRINT:temp_avg:LAST:%4.1lf%% Last\\l" + }, + + if_errors = { + "-v", "Errors/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_collisions = { + "-v", "Collisions/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Collisions/s", + "GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + if_dropped = { + "-v", "Packets/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_packets = { + "-v", "Packets/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_rx_errors = { + "-v", "Errors/s", + "DEF:min={file}:value:MIN", + "DEF:avg={file}:value:AVERAGE", + "DEF:max={file}:value:MAX", + "CDEF:mytime=avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":Errors/s", + "GPRINT:avg:AVERAGE:%3.1lf%s Avg,", + "GPRINT:max:MAX:%3.1lf%s Max,", + "GPRINT:avg:LAST:%3.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)" + }, + + ipt_bytes = { + "-v", "Bits/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "CDEF:mytime=avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", + #"GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + ipt_packets = { + "-v", "Packets/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Packets/s", + "GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + irq = { + "-v", "Issues/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + load = { + "-v", "System load", + "DEF:s_avg={file}:shortterm:AVERAGE", + "DEF:s_min={file}:shortterm:MIN", + "DEF:s_max={file}:shortterm:MAX", + "DEF:m_avg={file}:midterm:AVERAGE", + "DEF:m_min={file}:midterm:MIN", + "DEF:m_max={file}:midterm:MAX", + "DEF:l_avg={file}:longterm:AVERAGE", + "DEF:l_min={file}:longterm:MIN", + "DEF:l_max={file}:longterm:MAX", + "AREA:s_max#" .. self.palette.HalfGreen, + "AREA:s_min#" .. self.palette.Canvas, + "LINE1:s_avg#" .. self.palette.FullGreen .. ": 1m average", + "GPRINT:s_min:MIN:%4.2lf Min,", + "GPRINT:s_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:s_max:MAX:%4.2lf Max,", + "GPRINT:s_avg:LAST:%4.2lf Last\n", + "LINE1:m_avg#" .. self.palette.FullBlue .. ": 5m average", + "GPRINT:m_min:MIN:%4.2lf Min,", + "GPRINT:m_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:m_max:MAX:%4.2lf Max,", + "GPRINT:m_avg:LAST:%4.2lf Last\n", + "LINE1:l_avg#" .. self.palette.FullRed .. ":15m average", + "GPRINT:l_min:MIN:%4.2lf Min,", + "GPRINT:l_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:l_max:MAX:%4.2lf Max,", + "GPRINT:l_avg:LAST:%4.2lf Last\\l" + }, + + load_percent = { + "DEF:avg={file}:percent:AVERAGE", + "DEF:min={file}:percent:MIN", + "DEF:max={file}:percent:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Load", + "GPRINT:min:MIN:%5.1lf%s%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", + "GPRINT:max:MAX:%5.1lf%s%% Max,", + "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" + }, + + mails = { + "DEF:rawgood={file}:good:AVERAGE", + "DEF:rawspam={file}:spam:AVERAGE", + "CDEF:good=rawgood,UN,0,rawgood,IF", + "CDEF:spam=rawspam,UN,0,rawspam,IF", + "CDEF:negspam=spam,-1,*", + "AREA:good#" .. self.palette.HalfGreen, + "LINE1:good#" .. self.palette.FullGreen .. ":Good mails", + "GPRINT:good:AVERAGE:%4.1lf Avg,", + "GPRINT:good:MAX:%4.1lf Max,", + "GPRINT:good:LAST:%4.1lf Last\n", + "AREA:negspam#" .. self.palette.HalfRed, + "LINE1:negspam#" .. self.palette.FullRed .. ":Spam mails", + "GPRINT:spam:AVERAGE:%4.1lf Avg,", + "GPRINT:spam:MAX:%4.1lf Max,", + "GPRINT:spam:LAST:%4.1lf Last\\l", + "HRULE:0#000000" + }, + + memory = { + "-b", "1024", "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Memory", + "GPRINT:min:MIN:%5.1lf%sbyte Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,", + "GPRINT:max:MAX:%5.1lf%sbyte Max,", + "GPRINT:avg:LAST:%5.1lf%sbyte Last\\l" + }, + + old_memory = { + "DEF:used_avg={file}:used:AVERAGE", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:buffers_avg={file}:buffers:AVERAGE", + "DEF:cached_avg={file}:cached:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:free_min={file}:free:MIN", + "DEF:buffers_min={file}:buffers:MIN", + "DEF:cached_min={file}:cached:MIN", + "DEF:used_max={file}:used:MAX", + "DEF:free_max={file}:free:MAX", + "DEF:buffers_max={file}:buffers:MAX", + "DEF:cached_max={file}:cached:MAX", + "CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF", + "CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF", + "CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+", + "CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+", + "CDEF:buffers_used=buffers_avg,used_avg,+", + "AREA:free_cached_buffers_used#" .. self.palette.HalfGreen, + "AREA:cached_buffers_used#" .. self.palette.HalfBlue, + "AREA:buffers_used#" .. self.palette.HalfYellow, + "AREA:used_avg#" .. self.palette.HalfRed, + "LINE1:free_cached_buffers_used#" .. self.palette.FullGreen .. ":Free ", + "GPRINT:free_min:MIN:%5.1lf%s Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:free_max:MAX:%5.1lf%s Max,", + "GPRINT:free_avg:LAST:%5.1lf%s Last\n", + "LINE1:cached_buffers_used#" .. self.palette.FullBlue .. ":Page cache ", + "GPRINT:cached_min:MIN:%5.1lf%s Min,", + "GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cached_max:MAX:%5.1lf%s Max,", + "GPRINT:cached_avg:LAST:%5.1lf%s Last\n", + "LINE1:buffers_used#" .. self.palette.FullYellow .. ":Buffer cache", + "GPRINT:buffers_min:MIN:%5.1lf%s Min,", + "GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:buffers_max:MAX:%5.1lf%s Max,", + "GPRINT:buffers_avg:LAST:%5.1lf%s Last\n", + "LINE1:used_avg#" .. self.palette.FullRed .. ":Used ", + "GPRINT:used_min:MIN:%5.1lf%s Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:used_max:MAX:%5.1lf%s Max,", + "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" + }, + + mysql_commands = { + "-v", "Issues/s", + "DEF:val_avg={file}:value:AVERAGE", + "DEF:val_min={file}:value:MIN", + "DEF:val_max={file}:value:MAX", + "AREA:val_max#" .. self.palette.HalfBlue, + "AREA:val_min#" .. self.palette.Canvas, + "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:val_min:MIN:%5.2lf Min,", + "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:val_max:MAX:%5.2lf Max,", + "GPRINT:val_avg:LAST:%5.2lf Last\\l" + }, + + mysql_handler = { + "-v", "Issues/s", + "DEF:val_avg={file}:value:AVERAGE", + "DEF:val_min={file}:value:MIN", + "DEF:val_max={file}:value:MAX", + "AREA:val_max#" .. self.palette.HalfBlue, + "AREA:val_min#" .. self.palette.Canvas, + "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:val_min:MIN:%5.2lf Min,", + "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:val_max:MAX:%5.2lf Max,", + "GPRINT:val_avg:LAST:%5.2lf Last\\l" + }, + + mysql_octets = { + "-v", "Bits/s", + "DEF:out_min={file}:tx:MIN", + "DEF:out_avg={file}:tx:AVERAGE", + "DEF:out_max={file}:tx:MAX", + "DEF:inc_min={file}:rx:MIN", + "DEF:inc_avg={file}:rx:AVERAGE", + "DEF:inc_max={file}:rx:MAX", + "CDEF:mytime=out_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "CDEF:out_bit_min=out_min,8,*", + "CDEF:out_bit_avg=out_avg,8,*", + "CDEF:out_bit_max=out_max,8,*", + "CDEF:inc_bit_min=inc_min,8,*", + "CDEF:inc_bit_avg=inc_avg,8,*", + "CDEF:inc_bit_max=inc_max,8,*", + "CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF", + "AREA:out_bit_avg#" .. self.palette.HalfGreen, + "AREA:inc_bit_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_bit_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_bit_max:MAX:%5.1lf%s Max,", + "GPRINT:out_bit_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:inc_bit_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_bit_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_bit_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + mysql_qcache = { + "-v", "Queries/s", + "DEF:hits_min={file}:hits:MIN", + "DEF:hits_avg={file}:hits:AVERAGE", + "DEF:hits_max={file}:hits:MAX", + "DEF:inserts_min={file}:inserts:MIN", + "DEF:inserts_avg={file}:inserts:AVERAGE", + "DEF:inserts_max={file}:inserts:MAX", + "DEF:not_cached_min={file}:not_cached:MIN", + "DEF:not_cached_avg={file}:not_cached:AVERAGE", + "DEF:not_cached_max={file}:not_cached:MAX", + "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN", + "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE", + "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX", + "DEF:queries_min={file}:queries_in_cache:MIN", + "DEF:queries_avg={file}:queries_in_cache:AVERAGE", + "DEF:queries_max={file}:queries_in_cache:MAX", + "CDEF:unknown=queries_avg,UNKN,+", + "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+", + "CDEF:inserts_agg=hits_avg,inserts_avg,+", + "CDEF:hits_agg=hits_avg", + "AREA:not_cached_agg#" .. self.palette.HalfYellow, + "AREA:inserts_agg#" .. self.palette.HalfBlue, + "AREA:hits_agg#" .. self.palette.HalfGreen, + "LINE1:not_cached_agg#" .. self.palette.FullYellow .. ":Not Cached ", + "GPRINT:not_cached_min:MIN:%5.2lf Min,", + "GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:not_cached_max:MAX:%5.2lf Max,", + "GPRINT:not_cached_avg:LAST:%5.2lf Last\\l", + "LINE1:inserts_agg#" .. self.palette.FullBlue .. ":Inserts ", + "GPRINT:inserts_min:MIN:%5.2lf Min,", + "GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:inserts_max:MAX:%5.2lf Max,", + "GPRINT:inserts_avg:LAST:%5.2lf Last\\l", + "LINE1:hits_agg#" .. self.palette.FullGreen .. ":Hits ", + "GPRINT:hits_min:MIN:%5.2lf Min,", + "GPRINT:hits_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:hits_max:MAX:%5.2lf Max,", + "GPRINT:hits_avg:LAST:%5.2lf Last\\l", + "LINE1:lowmem_prunes_avg#" .. self.palette.FullRed .. ":Lowmem Prunes ", + "GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,", + "GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,", + "GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\\l", + "LINE1:unknown#" .. self.palette.Canvas .. ":Queries in cache", + "GPRINT:queries_min:MIN:%5.0lf Min,", + "GPRINT:queries_avg:AVERAGE:%5.0lf Avg,", + "GPRINT:queries_max:MAX:%5.0lf Max,", + "GPRINT:queries_avg:LAST:%5.0lf Last\\l" + }, + + mysql_threads = { + "-v", "Threads", + "DEF:running_min={file}:running:MIN", + "DEF:running_avg={file}:running:AVERAGE", + "DEF:running_max={file}:running:MAX", + "DEF:connected_min={file}:connected:MIN", + "DEF:connected_avg={file}:connected:AVERAGE", + "DEF:connected_max={file}:connected:MAX", + "DEF:cached_min={file}:cached:MIN", + "DEF:cached_avg={file}:cached:AVERAGE", + "DEF:cached_max={file}:cached:MAX", + "DEF:created_min={file}:created:MIN", + "DEF:created_avg={file}:created:AVERAGE", + "DEF:created_max={file}:created:MAX", + "CDEF:unknown=created_avg,UNKN,+", + "CDEF:cached_agg=connected_avg,cached_avg,+", + "AREA:cached_agg#" .. self.palette.HalfGreen, + "AREA:connected_avg#" .. self.palette.HalfBlue, + "AREA:running_avg#" .. self.palette.HalfRed, + "LINE1:cached_agg#" .. self.palette.FullGreen .. ":Cached ", + "GPRINT:cached_min:MIN:%5.1lf Min,", + "GPRINT:cached_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:cached_max:MAX:%5.1lf Max,", + "GPRINT:cached_avg:LAST:%5.1lf Last\\l", + "LINE1:connected_avg#" .. self.palette.FullBlue .. ":Connected", + "GPRINT:connected_min:MIN:%5.1lf Min,", + "GPRINT:connected_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:connected_max:MAX:%5.1lf Max,", + "GPRINT:connected_avg:LAST:%5.1lf Last\\l", + "LINE1:running_avg#" .. self.palette.FullRed .. ":Running ", + "GPRINT:running_min:MIN:%5.1lf Min,", + "GPRINT:running_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:running_max:MAX:%5.1lf Max,", + "GPRINT:running_avg:LAST:%5.1lf Last\\l", + "LINE1:unknown#" .. self.palette.Canvas .. ":Created ", + "GPRINT:created_min:MIN:%5.0lf Min,", + "GPRINT:created_avg:AVERAGE:%5.0lf Avg,", + "GPRINT:created_max:MAX:%5.0lf Max,", + "GPRINT:created_avg:LAST:%5.0lf Last\\l" + }, + + nfs_procedure = { + "-v", "Issues/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + nfs3_procedures = { + "DEF:null_avg={file}:null:AVERAGE", + "DEF:getattr_avg={file}:getattr:AVERAGE", + "DEF:setattr_avg={file}:setattr:AVERAGE", + "DEF:lookup_avg={file}:lookup:AVERAGE", + "DEF:access_avg={file}:access:AVERAGE", + "DEF:readlink_avg={file}:readlink:AVERAGE", + "DEF:read_avg={file}:read:AVERAGE", + "DEF:write_avg={file}:write:AVERAGE", + "DEF:create_avg={file}:create:AVERAGE", + "DEF:mkdir_avg={file}:mkdir:AVERAGE", + "DEF:symlink_avg={file}:symlink:AVERAGE", + "DEF:mknod_avg={file}:mknod:AVERAGE", + "DEF:remove_avg={file}:remove:AVERAGE", + "DEF:rmdir_avg={file}:rmdir:AVERAGE", + "DEF:rename_avg={file}:rename:AVERAGE", + "DEF:link_avg={file}:link:AVERAGE", + "DEF:readdir_avg={file}:readdir:AVERAGE", + "DEF:readdirplus_avg={file}:readdirplus:AVERAGE", + "DEF:fsstat_avg={file}:fsstat:AVERAGE", + "DEF:fsinfo_avg={file}:fsinfo:AVERAGE", + "DEF:pathconf_avg={file}:pathconf:AVERAGE", + "DEF:commit_avg={file}:commit:AVERAGE", + "DEF:null_max={file}:null:MAX", + "DEF:getattr_max={file}:getattr:MAX", + "DEF:setattr_max={file}:setattr:MAX", + "DEF:lookup_max={file}:lookup:MAX", + "DEF:access_max={file}:access:MAX", + "DEF:readlink_max={file}:readlink:MAX", + "DEF:read_max={file}:read:MAX", + "DEF:write_max={file}:write:MAX", + "DEF:create_max={file}:create:MAX", + "DEF:mkdir_max={file}:mkdir:MAX", + "DEF:symlink_max={file}:symlink:MAX", + "DEF:mknod_max={file}:mknod:MAX", + "DEF:remove_max={file}:remove:MAX", + "DEF:rmdir_max={file}:rmdir:MAX", + "DEF:rename_max={file}:rename:MAX", + "DEF:link_max={file}:link:MAX", + "DEF:readdir_max={file}:readdir:MAX", + "DEF:readdirplus_max={file}:readdirplus:MAX", + "DEF:fsstat_max={file}:fsstat:MAX", + "DEF:fsinfo_max={file}:fsinfo:MAX", + "DEF:pathconf_max={file}:pathconf:MAX", + "DEF:commit_max={file}:commit:MAX", + "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+", + "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+", + "CDEF:stack_read=read_avg", + "CDEF:stack_getattr=stack_read,getattr_avg,+", + "CDEF:stack_access=stack_getattr,access_avg,+", + "CDEF:stack_lookup=stack_access,lookup_avg,+", + "CDEF:stack_write=stack_lookup,write_avg,+", + "CDEF:stack_commit=stack_write,commit_avg,+", + "CDEF:stack_setattr=stack_commit,setattr_avg,+", + "CDEF:stack_other=stack_setattr,other_avg,+", + "AREA:stack_other#" .. self.palette.HalfRed, + "AREA:stack_setattr#" .. self.palette.HalfGreen, + "AREA:stack_commit#" .. self.palette.HalfYellow, + "AREA:stack_write#" .. self.palette.HalfGreen, + "AREA:stack_lookup#" .. self.palette.HalfBlue, + "AREA:stack_access#" .. self.palette.HalfMagenta, + "AREA:stack_getattr#" .. self.palette.HalfCyan, + "AREA:stack_read#" .. self.palette.HalfBlue, + "LINE1:stack_other#" .. self.palette.FullRed .. ":Other ", + "GPRINT:other_max:MAX:%5.1lf Max,", + "GPRINT:other_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:other_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_setattr#" .. self.palette.FullGreen .. ":setattr", + "GPRINT:setattr_max:MAX:%5.1lf Max,", + "GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:setattr_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_commit#" .. self.palette.FullYellow .. ":commit ", + "GPRINT:commit_max:MAX:%5.1lf Max,", + "GPRINT:commit_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:commit_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_write#" .. self.palette.FullGreen .. ":write ", + "GPRINT:write_max:MAX:%5.1lf Max,", + "GPRINT:write_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:write_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_lookup#" .. self.palette.FullBlue .. ":lookup ", + "GPRINT:lookup_max:MAX:%5.1lf Max,", + "GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:lookup_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_access#" .. self.palette.FullMagenta .. ":access ", + "GPRINT:access_max:MAX:%5.1lf Max,", + "GPRINT:access_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:access_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_getattr#" .. self.palette.FullCyan .. ":getattr", + "GPRINT:getattr_max:MAX:%5.1lf Max,", + "GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:getattr_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_read#" .. self.palette.FullBlue .. ":read ", + "GPRINT:read_max:MAX:%5.1lf Max,", + "GPRINT:read_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:read_avg:LAST:%5.1lf Last\\l" + }, + + partition = { + "DEF:rbyte_avg={file}:rbytes:AVERAGE", + "DEF:rbyte_min={file}:rbytes:MIN", + "DEF:rbyte_max={file}:rbytes:MAX", + "DEF:wbyte_avg={file}:wbytes:AVERAGE", + "DEF:wbyte_min={file}:wbytes:MIN", + "DEF:wbyte_max={file}:wbytes:MAX", + "CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF", + "AREA:wbyte_avg#" .. self.palette.HalfGreen, + "AREA:rbyte_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:wbyte_avg#" .. self.palette.FullGreen .. ":Write", + "GPRINT:wbyte_min:MIN:%5.1lf%s Min,", + "GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:wbyte_max:MAX:%5.1lf%s Max,", + "GPRINT:wbyte_avg:LAST:%5.1lf%s Last\\l", + "LINE1:rbyte_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:rbyte_min:MIN:%5.1lf%s Min,", + "GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rbyte_max:MAX:%5.1lf%s Max,", + "GPRINT:rbyte_avg:LAST:%5.1lf%s Last\\l" + }, + + percent = { + "-v", "Percent", + "DEF:avg={file}:percent:AVERAGE", + "DEF:min={file}:percent:MIN", + "DEF:max={file}:percent:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", + "GPRINT:min:MIN:%5.1lf%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%% Avg,", + "GPRINT:max:MAX:%5.1lf%% Max,", + "GPRINT:avg:LAST:%5.1lf%% Last\\l" + }, + + ping = { + "DEF:ping_avg={file}:ping:AVERAGE", + "DEF:ping_min={file}:ping:MIN", + "DEF:ping_max={file}:ping:MAX", + "AREA:ping_max#" .. self.palette.HalfBlue, + "AREA:ping_min#" .. self.palette.Canvas, + "LINE1:ping_avg#" .. self.palette.FullBlue .. ":Ping", + "GPRINT:ping_min:MIN:%4.1lf ms Min,", + "GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,", + "GPRINT:ping_max:MAX:%4.1lf ms Max,", + "GPRINT:ping_avg:LAST:%4.1lf ms Last\\l" + }, + + power = { + "-v", "Watt", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Watt", + "GPRINT:min:MIN:%5.1lf%sW Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sW Avg,", + "GPRINT:max:MAX:%5.1lf%sW Max,", + "GPRINT:avg:LAST:%5.1lf%sW Last\\l" + }, + + _processes = { + "DEF:running_avg={file}:running:AVERAGE", + "DEF:running_min={file}:running:MIN", + "DEF:running_max={file}:running:MAX", + "DEF:sleeping_avg={file}:sleeping:AVERAGE", + "DEF:sleeping_min={file}:sleeping:MIN", + "DEF:sleeping_max={file}:sleeping:MAX", + "DEF:zombies_avg={file}:zombies:AVERAGE", + "DEF:zombies_min={file}:zombies:MIN", + "DEF:zombies_max={file}:zombies:MAX", + "DEF:stopped_avg={file}:stopped:AVERAGE", + "DEF:stopped_min={file}:stopped:MIN", + "DEF:stopped_max={file}:stopped:MAX", + "DEF:paging_avg={file}:paging:AVERAGE", + "DEF:paging_min={file}:paging:MIN", + "DEF:paging_max={file}:paging:MAX", + "DEF:blocked_avg={file}:blocked:AVERAGE", + "DEF:blocked_min={file}:blocked:MIN", + "DEF:blocked_max={file}:blocked:MAX", + "CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+", + "CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+", + "CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+", + "CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+", + "CDEF:running_acc=sleeping_avg,running_avg,+", + "CDEF:sleeping_acc=sleeping_avg", + "AREA:paging_acc#" .. self.palette.HalfYellow, + "AREA:blocked_acc#" .. self.palette.HalfCyan, + "AREA:zombies_acc#" .. self.palette.HalfRed, + "AREA:stopped_acc#" .. self.palette.HalfMagenta, + "AREA:running_acc#" .. self.palette.HalfGreen, + "AREA:sleeping_acc#" .. self.palette.HalfBlue, + "LINE1:paging_acc#" .. self.palette.FullYellow .. ":Paging ", + "GPRINT:paging_min:MIN:%5.1lf Min,", + "GPRINT:paging_avg:AVERAGE:%5.1lf Average,", + "GPRINT:paging_max:MAX:%5.1lf Max,", + "GPRINT:paging_avg:LAST:%5.1lf Last\\l", + "LINE1:blocked_acc#" .. self.palette.FullCyan .. ":Blocked ", + "GPRINT:blocked_min:MIN:%5.1lf Min,", + "GPRINT:blocked_avg:AVERAGE:%5.1lf Average,", + "GPRINT:blocked_max:MAX:%5.1lf Max,", + "GPRINT:blocked_avg:LAST:%5.1lf Last\\l", + "LINE1:zombies_acc#" .. self.palette.FullRed .. ":Zombies ", + "GPRINT:zombies_min:MIN:%5.1lf Min,", + "GPRINT:zombies_avg:AVERAGE:%5.1lf Average,", + "GPRINT:zombies_max:MAX:%5.1lf Max,", + "GPRINT:zombies_avg:LAST:%5.1lf Last\\l", + "LINE1:stopped_acc#" .. self.palette.FullMagenta .. ":Stopped ", + "GPRINT:stopped_min:MIN:%5.1lf Min,", + "GPRINT:stopped_avg:AVERAGE:%5.1lf Average,", + "GPRINT:stopped_max:MAX:%5.1lf Max,", + "GPRINT:stopped_avg:LAST:%5.1lf Last\\l", + "LINE1:running_acc#" .. self.palette.FullGreen .. ":Running ", + "GPRINT:running_min:MIN:%5.1lf Min,", + "GPRINT:running_avg:AVERAGE:%5.1lf Average,", + "GPRINT:running_max:MAX:%5.1lf Max,", + "GPRINT:running_avg:LAST:%5.1lf Last\\l", + "LINE1:sleeping_acc#" .. self.palette.FullBlue .. ":Sleeping", + "GPRINT:sleeping_min:MIN:%5.1lf Min,", + "GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,", + "GPRINT:sleeping_max:MAX:%5.1lf Max,", + "GPRINT:sleeping_avg:LAST:%5.1lf Last\\l" + }, + + ps_count = { + "-v", "Processes", + "DEF:procs_avg={file}:processes:AVERAGE", + "DEF:procs_min={file}:processes:MIN", + "DEF:procs_max={file}:processes:MAX", + "DEF:thrds_avg={file}:threads:AVERAGE", + "DEF:thrds_min={file}:threads:MIN", + "DEF:thrds_max={file}:threads:MAX", + "AREA:thrds_avg#" .. self.palette.HalfBlue, + "AREA:procs_avg#" .. self.palette.HalfRed, + "LINE1:thrds_avg#" .. self.palette.FullBlue .. ":Threads ", + "GPRINT:thrds_min:MIN:%5.1lf Min,", + "GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:thrds_max:MAX:%5.1lf Max,", + "GPRINT:thrds_avg:LAST:%5.1lf Last\\l", + "LINE1:procs_avg#" .. self.palette.FullRed .. ":Processes", + "GPRINT:procs_min:MIN:%5.1lf Min,", + "GPRINT:procs_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:procs_max:MAX:%5.1lf Max,", + "GPRINT:procs_avg:LAST:%5.1lf Last\\l" + }, + + ps_cputime = { + "-v", "Jiffies", + "DEF:user_avg_raw={file}:user:AVERAGE", + "DEF:user_min_raw={file}:user:MIN", + "DEF:user_max_raw={file}:user:MAX", + "DEF:syst_avg_raw={file}:syst:AVERAGE", + "DEF:syst_min_raw={file}:syst:MIN", + "DEF:syst_max_raw={file}:syst:MAX", + "CDEF:user_avg=user_avg_raw,1000000,/", + "CDEF:user_min=user_min_raw,1000000,/", + "CDEF:user_max=user_max_raw,1000000,/", + "CDEF:syst_avg=syst_avg_raw,1000000,/", + "CDEF:syst_min=syst_min_raw,1000000,/", + "CDEF:syst_max=syst_max_raw,1000000,/", + "CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+", + "AREA:user_syst#" .. self.palette.HalfBlue, + "AREA:syst_avg#" .. self.palette.HalfRed, + "LINE1:user_syst#" .. self.palette.FullBlue .. ":User ", + "GPRINT:user_min:MIN:%5.1lf%s Min,", + "GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:user_max:MAX:%5.1lf%s Max,", + "GPRINT:user_avg:LAST:%5.1lf%s Last\\l", + "LINE1:syst_avg#" .. self.palette.FullRed .. ":System", + "GPRINT:syst_min:MIN:%5.1lf%s Min,", + "GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:syst_max:MAX:%5.1lf%s Max,", + "GPRINT:syst_avg:LAST:%5.1lf%s Last\\l" + }, + + ps_pagefaults = { + "-v", "Pagefaults/s", + "DEF:minor_avg={file}:minflt:AVERAGE", + "DEF:minor_min={file}:minflt:MIN", + "DEF:minor_max={file}:minflt:MAX", + "DEF:major_avg={file}:majflt:AVERAGE", + "DEF:major_min={file}:majflt:MIN", + "DEF:major_max={file}:majflt:MAX", + "CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+", + "AREA:minor_major#" .. self.palette.HalfBlue, + "AREA:major_avg#" .. self.palette.HalfRed, + "LINE1:minor_major#" .. self.palette.FullBlue .. ":Minor", + "GPRINT:minor_min:MIN:%5.1lf%s Min,", + "GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:minor_max:MAX:%5.1lf%s Max,", + "GPRINT:minor_avg:LAST:%5.1lf%s Last\\l", + "LINE1:major_avg#" .. self.palette.FullRed .. ":Major", + "GPRINT:major_min:MIN:%5.1lf%s Min,", + "GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:major_max:MAX:%5.1lf%s Max,", + "GPRINT:major_avg:LAST:%5.1lf%s Last\\l" + }, + + ps_rss = { + "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":RSS", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + _ps_state = { + "-v", "Processes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + _signal_noise = { + "-v", "dBm", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Noise", + "GPRINT:min:MIN:%5.1lf%sdBm Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", + "GPRINT:max:MAX:%5.1lf%sdBm Max,", + "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" + }, + + _signal_power = { + "-v", "dBm", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Power", + "GPRINT:min:MIN:%5.1lf%sdBm Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", + "GPRINT:max:MAX:%5.1lf%sdBm Max,", + "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" + }, + + _signal_quality = { + "-v", "%", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Quality", + "GPRINT:min:MIN:%5.1lf%s%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", + "GPRINT:max:MAX:%5.1lf%s%% Max,", + "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" + }, + + swap = { + "-v", "Bytes", "-b", "1024", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bytes", + "GPRINT:min:MIN:%6.2lf%sByte Min,", + "GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,", + "GPRINT:max:MAX:%6.2lf%sByte Max,", + "GPRINT:avg:LAST:%6.2lf%sByte Last\\l" + }, + + old_swap = { + "DEF:used_avg={file}:used:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:used_max={file}:used:MAX", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:free_min={file}:free:MIN", + "DEF:free_max={file}:free:MAX", + "DEF:cach_avg={file}:cached:AVERAGE", + "DEF:cach_min={file}:cached:MIN", + "DEF:cach_max={file}:cached:MAX", + "DEF:resv_avg={file}:resv:AVERAGE", + "DEF:resv_min={file}:resv:MIN", + "DEF:resv_max={file}:resv:MAX", + "CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF", + "CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF", + "CDEF:used_acc=used_avg", + "CDEF:resv_acc=used_acc,resv_avg_notnull,+", + "CDEF:cach_acc=resv_acc,cach_avg_notnull,+", + "CDEF:free_acc=cach_acc,free_avg,+", + "AREA:free_acc#" .. self.palette.HalfGreen, + "AREA:cach_acc#" .. self.palette.HalfBlue, + "AREA:resv_acc#" .. self.palette.HalfYellow, + "AREA:used_acc#" .. self.palette.HalfRed, + "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free ", + "GPRINT:free_min:MIN:%5.1lf%s Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:free_max:MAX:%5.1lf%s Max,", + "GPRINT:free_avg:LAST:%5.1lf%s Last\n", + "LINE1:cach_acc#" .. self.palette.FullBlue .. ":Cached ", + "GPRINT:cach_min:MIN:%5.1lf%s Min,", + "GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cach_max:MAX:%5.1lf%s Max,", + "GPRINT:cach_avg:LAST:%5.1lf%s Last\\l", + "LINE1:resv_acc#" .. self.palette.FullYellow .. ":Reserved", + "GPRINT:resv_min:MIN:%5.1lf%s Min,", + "GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:resv_max:MAX:%5.1lf%s Max,", + "GPRINT:resv_avg:LAST:%5.1lf%s Last\n", + "LINE1:used_acc#" .. self.palette.FullRed .. ":Used ", + "GPRINT:used_min:MIN:%5.1lf%s Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:used_max:MAX:%5.1lf%s Max,", + "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" + }, + + tcp_connections = { + "-v", "Connections", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Connections", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + temperature = { + "-v", "Celsius", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+", + "AREA:temp_max#" .. self.palette.HalfRed, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", + "GPRINT:temp_max:MAX:%4.1lf Max,", + "GPRINT:temp_avg:LAST:%4.1lf Last\\l" + }, + + timeleft = { + "-v", "Minutes", + "DEF:avg={file}:timeleft:AVERAGE", + "DEF:min={file}:timeleft:MIN", + "DEF:max={file}:timeleft:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Time left [min]", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + time_offset = { + "DEF:s_avg={file}:seconds:AVERAGE", + "DEF:s_min={file}:seconds:MIN", + "DEF:s_max={file}:seconds:MAX", + "AREA:s_max#" .. self.palette.HalfBlue, + "AREA:s_min#" .. self.palette.Canvas, + "LINE1:s_avg#" .. self.palette.FullBlue .. ":{inst}", + "GPRINT:s_min:MIN:%7.3lf%s Min,", + "GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,", + "GPRINT:s_max:MAX:%7.3lf%s Max,", + "GPRINT:s_avg:LAST:%7.3lf%s Last\\l" + }, + + if_octets = { + "-v", "Bits/s", "-l", "0", + "DEF:out_min_raw={file}:tx:MIN", + "DEF:out_avg_raw={file}:tx:AVERAGE", + "DEF:out_max_raw={file}:tx:MAX", + "DEF:inc_min_raw={file}:rx:MIN", + "DEF:inc_avg_raw={file}:rx:AVERAGE", + "DEF:inc_max_raw={file}:rx:MAX", + "CDEF:out_min=out_min_raw,8,*", + "CDEF:out_avg=out_avg_raw,8,*", + "CDEF:out_max=out_max_raw,8,*", + "CDEF:inc_min=inc_min_raw,8,*", + "CDEF:inc_avg=inc_avg_raw,8,*", + "CDEF:inc_max=inc_max_raw,8,*", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "CDEF:mytime=out_avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Outgoing", + "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_max:MAX:%5.1lf%s Max,", + "GPRINT:out_avg:LAST:%5.1lf%s Last", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Incoming", + --"GPRINT:inc_min:MIN:%5.1lf %s Min,", + "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_avg:LAST:%5.1lf%s Last", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l" + }, + + cpufreq = { + "DEF:cpufreq_avg={file}:value:AVERAGE", + "DEF:cpufreq_min={file}:value:MIN", + "DEF:cpufreq_max={file}:value:MAX", + "AREA:cpufreq_max#" .. self.palette.HalfBlue, + "AREA:cpufreq_min#" .. self.palette.Canvas, + "LINE1:cpufreq_avg#" .. self.palette.FullBlue .. ":Frequency", + "GPRINT:cpufreq_min:MIN:%5.1lf%s Min,", + "GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cpufreq_max:MAX:%5.1lf%s Max,", + "GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\\l" + }, + + multimeter = { + "DEF:multimeter_avg={file}:value:AVERAGE", + "DEF:multimeter_min={file}:value:MIN", + "DEF:multimeter_max={file}:value:MAX", + "AREA:multimeter_max#" .. self.palette.HalfBlue, + "AREA:multimeter_min#" .. self.palette.Canvas, + "LINE1:multimeter_avg#" .. self.palette.FullBlue .. ":Multimeter", + "GPRINT:multimeter_min:MIN:%4.1lf Min,", + "GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,", + "GPRINT:multimeter_max:MAX:%4.1lf Max,", + "GPRINT:multimeter_avg:LAST:%4.1lf Last\\l" + }, + + users = { + "-v", "Users", + "DEF:users_avg={file}:users:AVERAGE", + "DEF:users_min={file}:users:MIN", + "DEF:users_max={file}:users:MAX", + "AREA:users_max#" .. self.palette.HalfBlue, + "AREA:users_min#" .. self.palette.Canvas, + "LINE1:users_avg#" .. self.palette.FullBlue .. ":Users", + "GPRINT:users_min:MIN:%4.1lf Min,", + "GPRINT:users_avg:AVERAGE:%4.1lf Average,", + "GPRINT:users_max:MAX:%4.1lf Max,", + "GPRINT:users_avg:LAST:%4.1lf Last\\l" + }, + + voltage = { + "-v", "Voltage", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Voltage", + "GPRINT:min:MIN:%5.1lf%sV Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sV Avg,", + "GPRINT:max:MAX:%5.1lf%sV Max,", + "GPRINT:avg:LAST:%5.1lf%sV Last\\l" + }, + + vs_threads = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Threads", + "GPRINT:min:MIN:%5.1lf Min,", + "GPRINT:avg:AVERAGE:%5.1lf Avg.,", + "GPRINT:max:MAX:%5.1lf Max,", + "GPRINT:avg:LAST:%5.1lf Last\\l", + }, + + vs_memory = { + "-b", "1024", "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":", + "GPRINT:min:MIN:%5.1lf%sbytes Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sbytes Avg.,", + "GPRINT:max:MAX:%5.1lf%sbytes Max,", + "GPRINT:avg:LAST:%5.1lf%sbytes Last\\l", + }, + + vs_processes = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%5.1lf Min,", + "GPRINT:avg:AVERAGE:%5.1lf Avg.,", + "GPRINT:max:MAX:%5.1lf Max,", + "GPRINT:avg:LAST:%5.1lf Last\\l", + }, + } + + + + -- used color palette + colors = { + Canvas = "FFFFFF", + + FullRed = "FF0000", + FullGreen = "00E000", + FullBlue = "0000FF", + FullYellow = "F0A000", + FullCyan = "00A0FF", + FullMagenta = "A000FF", + + HalfRed = "F7B7B7", + HalfGreen = "B7EFB7", + HalfBlue = "B7B7F7", + HalfYellow = "F3DFB7", + HalfCyan = "B7DFF7", + HalfMagenta = "DFB7F7", + + HalfBlueGreen = "89B3C9" + } + + + -- plotting arguments for each defined datasource + rrd_args = { + apache_bytes = { + "DEF:min_raw={file}:count:MIN", + "DEF:avg_raw={file}:count:AVERAGE", + "DEF:max_raw={file}:count:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "CDEF:mytime=avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bit/s", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + apache_requests = { + "DEF:min={file}:count:MIN", + "DEF:avg={file}:count:AVERAGE", + "DEF:max={file}:count:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Requests/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + apache_scoreboard = { + "DEF:min={file}:count:MIN", + "DEF:avg={file}:count:AVERAGE", + "DEF:max={file}:count:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + bitrate = { + "-v", "Bits/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Average,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + charge = { + "-v", "Ah", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Charge", + "GPRINT:min:MIN:%5.1lf%sAh Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,", + "GPRINT:max:MAX:%5.1lf%sAh Max,", + "GPRINT:avg:LAST:%5.1lf%sAh Last\\l" + }, + + cpu = { + "-v", "CPU load", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", + "GPRINT:min:MIN:%6.2lf%% Min,", + "GPRINT:avg:AVERAGE:%6.2lf%% Avg,", + "GPRINT:max:MAX:%6.2lf%% Max,", + "GPRINT:avg:LAST:%6.2lf%% Last\\l" + }, + + current = { + "-v", "Ampere", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Current", + "GPRINT:min:MIN:%5.1lf%sA Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sA Avg,", + "GPRINT:max:MAX:%5.1lf%sA Max,", + "GPRINT:avg:LAST:%5.1lf%sA Last\\l" + }, + + df = { + "-v", "Percent", "-l", "0", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:free_min={file}:free:MIN", + "DEF:free_max={file}:free:MAX", + "DEF:used_avg={file}:used:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:used_max={file}:used:MAX", + "CDEF:total=free_avg,used_avg,+", + "CDEF:free_pct=100,free_avg,*,total,/", + "CDEF:used_pct=100,used_avg,*,total,/", + "CDEF:free_acc=free_pct,used_pct,+", + "CDEF:used_acc=used_pct", + "AREA:free_acc#" .. self.palette.HalfGreen, + "AREA:used_acc#" .. self.palette.HalfRed, + "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free", + "GPRINT:free_min:MIN:%5.1lf%sB Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,", + "GPRINT:free_max:MAX:%5.1lf%sB Max,", + "GPRINT:free_avg:LAST:%5.1lf%sB Last\\l", + "LINE1:used_acc#" .. self.palette.FullRed .. ":Used", + "GPRINT:used_min:MIN:%5.1lf%sB Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,", + "GPRINT:used_max:MAX:%5.1lf%sB Max,", + "GPRINT:used_avg:LAST:%5.1lf%sB Last\\l" + }, + + disk = { + "DEF:rtime_avg={file}:rtime:AVERAGE", + "DEF:rtime_min={file}:rtime:MIN", + "DEF:rtime_max={file}:rtime:MAX", + "DEF:wtime_avg={file}:wtime:AVERAGE", + "DEF:wtime_min={file}:wtime:MIN", + "DEF:wtime_max={file}:wtime:MAX", + "CDEF:rtime_avg_ms=rtime_avg,1000,/", + "CDEF:rtime_min_ms=rtime_min,1000,/", + "CDEF:rtime_max_ms=rtime_max,1000,/", + "CDEF:wtime_avg_ms=wtime_avg,1000,/", + "CDEF:wtime_min_ms=wtime_min,1000,/", + "CDEF:wtime_max_ms=wtime_max,1000,/", + "CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+", + "CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+", + "CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+", + "AREA:total_max_ms#" .. self.palette.HalfRed, + "AREA:total_min_ms#" .. self.palette.Canvas, + "LINE1:wtime_avg_ms#" .. self.palette.FullGreen .. ":Write", + "GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n", + "LINE1:rtime_avg_ms#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n", + "LINE1:total_avg_ms#" .. self.palette.FullRed .. ":Total", + "GPRINT:total_min_ms:MIN:%5.1lf%s Min,", + "GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,", + "GPRINT:total_max_ms:MAX:%5.1lf%s Max,", + "GPRINT:total_avg_ms:LAST:%5.1lf%s Last\\l" + }, + + disk_octets = { + "-v", "Bytes/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "CDEF:mytime=out_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_max:MAX:%5.1lf%s Max,", + "GPRINT:out_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + disk_merged = { + "-v", "Merged Ops/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:out_max:MAX:%6.2lf Max,", + "GPRINT:out_avg:LAST:%6.2lf Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:inc_max:MAX:%6.2lf Max,", + "GPRINT:inc_avg:LAST:%6.2lf Last\\l" + }, + + disk_ops = { + "-v", "Ops/s", + "DEF:out_min={file}:write:MIN", + "DEF:out_avg={file}:write:AVERAGE", + "DEF:out_max={file}:write:MAX", + "DEF:inc_min={file}:read:MIN", + "DEF:inc_avg={file}:read:AVERAGE", + "DEF:inc_max={file}:read:MAX", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:out_max:MAX:%6.2lf Max,", + "GPRINT:out_avg:LAST:%6.2lf Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:inc_max:MAX:%6.2lf Max,", + "GPRINT:inc_avg:LAST:%6.2lf Last\\l" + }, + + disk_time = { + "-v", "Seconds/s", + "DEF:out_min_raw={file}:write:MIN", + "DEF:out_avg_raw={file}:write:AVERAGE", + "DEF:out_max_raw={file}:write:MAX", + "DEF:inc_min_raw={file}:read:MIN", + "DEF:inc_avg_raw={file}:read:AVERAGE", + "DEF:inc_max_raw={file}:read:MAX", + "CDEF:out_min=out_min_raw,1000,/", + "CDEF:out_avg=out_avg_raw,1000,/", + "CDEF:out_max=out_max_raw,1000,/", + "CDEF:inc_min=inc_min_raw,1000,/", + "CDEF:inc_avg=inc_avg_raw,1000,/", + "CDEF:inc_max=inc_max_raw,1000,/", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_avg:AVERAGE:%5.1lf%ss Avg,", + "GPRINT:out_max:MAX:%5.1lf%ss Max,", + "GPRINT:out_avg:LAST:%5.1lf%ss Last\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_avg:AVERAGE:%5.1lf%ss Avg,", + "GPRINT:inc_max:MAX:%5.1lf%ss Max,", + "GPRINT:inc_avg:LAST:%5.1lf%ss Last\\l" + }, + + dns_octets = { + "DEF:rsp_min_raw={file}:responses:MIN", + "DEF:rsp_avg_raw={file}:responses:AVERAGE", + "DEF:rsp_max_raw={file}:responses:MAX", + "DEF:qry_min_raw={file}:queries:MIN", + "DEF:qry_avg_raw={file}:queries:AVERAGE", + "DEF:qry_max_raw={file}:queries:MAX", + "CDEF:rsp_min=rsp_min_raw,8,*", + "CDEF:rsp_avg=rsp_avg_raw,8,*", + "CDEF:rsp_max=rsp_max_raw,8,*", + "CDEF:qry_min=qry_min_raw,8,*", + "CDEF:qry_avg=qry_avg_raw,8,*", + "CDEF:qry_max=qry_max_raw,8,*", + "CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF", + "CDEF:mytime=rsp_avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*", + "CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+", + "CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*", + "CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+", + "AREA:rsp_avg#" .. self.palette.HalfGreen, + "AREA:qry_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:rsp_avg#" .. self.palette.FullGreen .. ":Responses", + "GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rsp_max:MAX:%5.1lf%s Max,", + "GPRINT:rsp_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:qry_avg#" .. self.palette.FullBlue .. ":Queries ", + #"GPRINT:qry_min:MIN:%5.1lf %s Min,", + "GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:qry_max:MAX:%5.1lf%s Max,", + "GPRINT:qry_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + dns_opcode = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Queries/s", + "GPRINT:min:MIN:%9.3lf Min,", + "GPRINT:avg:AVERAGE:%9.3lf Average,", + "GPRINT:max:MAX:%9.3lf Max,", + "GPRINT:avg:LAST:%9.3lf Last\\l" + }, + + email_count = { + "-v", "Mails", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + email_size = { + "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + spam_score = { + "-v", "Score", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Score ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + spam_check = { + "DEF:avg={file}:hits:AVERAGE", + "DEF:min={file}:hits:MIN", + "DEF:max={file}:hits:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + entropy = { + "-v", "Bits", + "DEF:avg={file}:entropy:AVERAGE", + "DEF:min={file}:entropy:MIN", + "DEF:max={file}:entropy:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits", + "GPRINT:min:MIN:%4.0lfbit Min,", + "GPRINT:avg:AVERAGE:%4.0lfbit Avg,", + "GPRINT:max:MAX:%4.0lfbit Max,", + "GPRINT:avg:LAST:%4.0lfbit Last\\l" + }, + + fanspeed = { + "-v", "RPM", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfMagenta, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullMagenta .. ":RPM", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + frequency = { + "-v", "Hertz", + "DEF:avg={file}:frequency:AVERAGE", + "DEF:min={file}:frequency:MIN", + "DEF:max={file}:frequency:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Frequency [Hz]", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + frequency_offset = { + "DEF:ppm_avg={file}:ppm:AVERAGE", + "DEF:ppm_min={file}:ppm:MIN", + "DEF:ppm_max={file}:ppm:MAX", + "AREA:ppm_max#" .. self.palette.HalfBlue, + "AREA:ppm_min#" .. self.palette.Canvas, + "LINE1:ppm_avg#" .. self.palette.FullBlue .. ":{inst}", + "GPRINT:ppm_min:MIN:%5.2lf Min,", + "GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:ppm_max:MAX:%5.2lf Max,", + "GPRINT:ppm_avg:LAST:%5.2lf Last\\l" + }, + + gauge = { + "-v", "Exec value", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfBlue, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullBlue .. ":Exec value", + "GPRINT:temp_min:MIN:%6.2lf Min,", + "GPRINT:temp_avg:AVERAGE:%6.2lf Avg,", + "GPRINT:temp_max:MAX:%6.2lf Max,", + "GPRINT:temp_avg:LAST:%6.2lf Last\\l" + }, + + hddtemp = { + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfRed, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", + "GPRINT:temp_max:MAX:%4.1lf Max,", + "GPRINT:temp_avg:LAST:%4.1lf Last\\l" + }, + + humidity = { + "-v", "Percent", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "AREA:temp_max#" .. self.palette.HalfGreen, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullGreen .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf%% Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,", + "GPRINT:temp_max:MAX:%4.1lf%% Max,", + "GPRINT:temp_avg:LAST:%4.1lf%% Last\\l" + }, + + if_errors = { + "-v", "Errors/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_collisions = { + "-v", "Collisions/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Collisions/s", + "GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + if_dropped = { + "-v", "Packets/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_packets = { + "-v", "Packets/s", + "DEF:tx_min={file}:tx:MIN", + "DEF:tx_avg={file}:tx:AVERAGE", + "DEF:tx_max={file}:tx:MAX", + "DEF:rx_min={file}:rx:MIN", + "DEF:rx_avg={file}:rx:AVERAGE", + "DEF:rx_max={file}:rx:MAX", + "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", + "CDEF:mytime=tx_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", + "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", + "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", + "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", + "AREA:tx_avg#" .. self.palette.HalfGreen, + "AREA:rx_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", + "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:tx_max:MAX:%5.1lf%s Max,", + "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", + "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", + #"GPRINT:rx_min:MIN:%5.1lf %s Min,", + "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rx_max:MAX:%5.1lf%s Max,", + "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" + }, + + if_rx_errors = { + "-v", "Errors/s", + "DEF:min={file}:value:MIN", + "DEF:avg={file}:value:AVERAGE", + "DEF:max={file}:value:MAX", + "CDEF:mytime=avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":Errors/s", + "GPRINT:avg:AVERAGE:%3.1lf%s Avg,", + "GPRINT:max:MAX:%3.1lf%s Max,", + "GPRINT:avg:LAST:%3.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)" + }, + + ipt_bytes = { + "-v", "Bits/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "CDEF:mytime=avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", + "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", + #"GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l", + "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + ipt_packets = { + "-v", "Packets/s", + "DEF:min_raw={file}:value:MIN", + "DEF:avg_raw={file}:value:AVERAGE", + "DEF:max_raw={file}:value:MAX", + "CDEF:min=min_raw,8,*", + "CDEF:avg=avg_raw,8,*", + "CDEF:max=max_raw,8,*", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Packets/s", + "GPRINT:min:MIN:%5.1lf %s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + irq = { + "-v", "Issues/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + load = { + "-v", "System load", + "DEF:s_avg={file}:shortterm:AVERAGE", + "DEF:s_min={file}:shortterm:MIN", + "DEF:s_max={file}:shortterm:MAX", + "DEF:m_avg={file}:midterm:AVERAGE", + "DEF:m_min={file}:midterm:MIN", + "DEF:m_max={file}:midterm:MAX", + "DEF:l_avg={file}:longterm:AVERAGE", + "DEF:l_min={file}:longterm:MIN", + "DEF:l_max={file}:longterm:MAX", + "AREA:s_max#" .. self.palette.HalfGreen, + "AREA:s_min#" .. self.palette.Canvas, + "LINE1:s_avg#" .. self.palette.FullGreen .. ": 1m average", + "GPRINT:s_min:MIN:%4.2lf Min,", + "GPRINT:s_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:s_max:MAX:%4.2lf Max,", + "GPRINT:s_avg:LAST:%4.2lf Last\n", + "LINE1:m_avg#" .. self.palette.FullBlue .. ": 5m average", + "GPRINT:m_min:MIN:%4.2lf Min,", + "GPRINT:m_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:m_max:MAX:%4.2lf Max,", + "GPRINT:m_avg:LAST:%4.2lf Last\n", + "LINE1:l_avg#" .. self.palette.FullRed .. ":15m average", + "GPRINT:l_min:MIN:%4.2lf Min,", + "GPRINT:l_avg:AVERAGE:%4.2lf Avg,", + "GPRINT:l_max:MAX:%4.2lf Max,", + "GPRINT:l_avg:LAST:%4.2lf Last\\l" + }, + + load_percent = { + "DEF:avg={file}:percent:AVERAGE", + "DEF:min={file}:percent:MIN", + "DEF:max={file}:percent:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Load", + "GPRINT:min:MIN:%5.1lf%s%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", + "GPRINT:max:MAX:%5.1lf%s%% Max,", + "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" + }, + + mails = { + "DEF:rawgood={file}:good:AVERAGE", + "DEF:rawspam={file}:spam:AVERAGE", + "CDEF:good=rawgood,UN,0,rawgood,IF", + "CDEF:spam=rawspam,UN,0,rawspam,IF", + "CDEF:negspam=spam,-1,*", + "AREA:good#" .. self.palette.HalfGreen, + "LINE1:good#" .. self.palette.FullGreen .. ":Good mails", + "GPRINT:good:AVERAGE:%4.1lf Avg,", + "GPRINT:good:MAX:%4.1lf Max,", + "GPRINT:good:LAST:%4.1lf Last\n", + "AREA:negspam#" .. self.palette.HalfRed, + "LINE1:negspam#" .. self.palette.FullRed .. ":Spam mails", + "GPRINT:spam:AVERAGE:%4.1lf Avg,", + "GPRINT:spam:MAX:%4.1lf Max,", + "GPRINT:spam:LAST:%4.1lf Last\\l", + "HRULE:0#000000" + }, + + memory = { + "-b", "1024", "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Memory", + "GPRINT:min:MIN:%5.1lf%sbyte Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,", + "GPRINT:max:MAX:%5.1lf%sbyte Max,", + "GPRINT:avg:LAST:%5.1lf%sbyte Last\\l" + }, + + old_memory = { + "DEF:used_avg={file}:used:AVERAGE", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:buffers_avg={file}:buffers:AVERAGE", + "DEF:cached_avg={file}:cached:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:free_min={file}:free:MIN", + "DEF:buffers_min={file}:buffers:MIN", + "DEF:cached_min={file}:cached:MIN", + "DEF:used_max={file}:used:MAX", + "DEF:free_max={file}:free:MAX", + "DEF:buffers_max={file}:buffers:MAX", + "DEF:cached_max={file}:cached:MAX", + "CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF", + "CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF", + "CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+", + "CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+", + "CDEF:buffers_used=buffers_avg,used_avg,+", + "AREA:free_cached_buffers_used#" .. self.palette.HalfGreen, + "AREA:cached_buffers_used#" .. self.palette.HalfBlue, + "AREA:buffers_used#" .. self.palette.HalfYellow, + "AREA:used_avg#" .. self.palette.HalfRed, + "LINE1:free_cached_buffers_used#" .. self.palette.FullGreen .. ":Free ", + "GPRINT:free_min:MIN:%5.1lf%s Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:free_max:MAX:%5.1lf%s Max,", + "GPRINT:free_avg:LAST:%5.1lf%s Last\n", + "LINE1:cached_buffers_used#" .. self.palette.FullBlue .. ":Page cache ", + "GPRINT:cached_min:MIN:%5.1lf%s Min,", + "GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cached_max:MAX:%5.1lf%s Max,", + "GPRINT:cached_avg:LAST:%5.1lf%s Last\n", + "LINE1:buffers_used#" .. self.palette.FullYellow .. ":Buffer cache", + "GPRINT:buffers_min:MIN:%5.1lf%s Min,", + "GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:buffers_max:MAX:%5.1lf%s Max,", + "GPRINT:buffers_avg:LAST:%5.1lf%s Last\n", + "LINE1:used_avg#" .. self.palette.FullRed .. ":Used ", + "GPRINT:used_min:MIN:%5.1lf%s Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:used_max:MAX:%5.1lf%s Max,", + "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" + }, + + mysql_commands = { + "-v", "Issues/s", + "DEF:val_avg={file}:value:AVERAGE", + "DEF:val_min={file}:value:MIN", + "DEF:val_max={file}:value:MAX", + "AREA:val_max#" .. self.palette.HalfBlue, + "AREA:val_min#" .. self.palette.Canvas, + "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:val_min:MIN:%5.2lf Min,", + "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:val_max:MAX:%5.2lf Max,", + "GPRINT:val_avg:LAST:%5.2lf Last\\l" + }, + + mysql_handler = { + "-v", "Issues/s", + "DEF:val_avg={file}:value:AVERAGE", + "DEF:val_min={file}:value:MIN", + "DEF:val_max={file}:value:MAX", + "AREA:val_max#" .. self.palette.HalfBlue, + "AREA:val_min#" .. self.palette.Canvas, + "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:val_min:MIN:%5.2lf Min,", + "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:val_max:MAX:%5.2lf Max,", + "GPRINT:val_avg:LAST:%5.2lf Last\\l" + }, + + mysql_octets = { + "-v", "Bits/s", + "DEF:out_min={file}:tx:MIN", + "DEF:out_avg={file}:tx:AVERAGE", + "DEF:out_max={file}:tx:MAX", + "DEF:inc_min={file}:rx:MIN", + "DEF:inc_avg={file}:rx:AVERAGE", + "DEF:inc_max={file}:rx:MAX", + "CDEF:mytime=out_avg,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "CDEF:out_bit_min=out_min,8,*", + "CDEF:out_bit_avg=out_avg,8,*", + "CDEF:out_bit_max=out_max,8,*", + "CDEF:inc_bit_min=inc_min,8,*", + "CDEF:inc_bit_avg=inc_avg,8,*", + "CDEF:inc_bit_max=inc_max,8,*", + "CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF", + "AREA:out_bit_avg#" .. self.palette.HalfGreen, + "AREA:inc_bit_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_bit_avg#" .. self.palette.FullGreen .. ":Written", + "GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_bit_max:MAX:%5.1lf%s Max,", + "GPRINT:out_bit_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", + "LINE1:inc_bit_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_bit_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_bit_avg:LAST:%5.1lf%s Last\\l", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" + }, + + mysql_qcache = { + "-v", "Queries/s", + "DEF:hits_min={file}:hits:MIN", + "DEF:hits_avg={file}:hits:AVERAGE", + "DEF:hits_max={file}:hits:MAX", + "DEF:inserts_min={file}:inserts:MIN", + "DEF:inserts_avg={file}:inserts:AVERAGE", + "DEF:inserts_max={file}:inserts:MAX", + "DEF:not_cached_min={file}:not_cached:MIN", + "DEF:not_cached_avg={file}:not_cached:AVERAGE", + "DEF:not_cached_max={file}:not_cached:MAX", + "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN", + "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE", + "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX", + "DEF:queries_min={file}:queries_in_cache:MIN", + "DEF:queries_avg={file}:queries_in_cache:AVERAGE", + "DEF:queries_max={file}:queries_in_cache:MAX", + "CDEF:unknown=queries_avg,UNKN,+", + "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+", + "CDEF:inserts_agg=hits_avg,inserts_avg,+", + "CDEF:hits_agg=hits_avg", + "AREA:not_cached_agg#" .. self.palette.HalfYellow, + "AREA:inserts_agg#" .. self.palette.HalfBlue, + "AREA:hits_agg#" .. self.palette.HalfGreen, + "LINE1:not_cached_agg#" .. self.palette.FullYellow .. ":Not Cached ", + "GPRINT:not_cached_min:MIN:%5.2lf Min,", + "GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:not_cached_max:MAX:%5.2lf Max,", + "GPRINT:not_cached_avg:LAST:%5.2lf Last\\l", + "LINE1:inserts_agg#" .. self.palette.FullBlue .. ":Inserts ", + "GPRINT:inserts_min:MIN:%5.2lf Min,", + "GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:inserts_max:MAX:%5.2lf Max,", + "GPRINT:inserts_avg:LAST:%5.2lf Last\\l", + "LINE1:hits_agg#" .. self.palette.FullGreen .. ":Hits ", + "GPRINT:hits_min:MIN:%5.2lf Min,", + "GPRINT:hits_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:hits_max:MAX:%5.2lf Max,", + "GPRINT:hits_avg:LAST:%5.2lf Last\\l", + "LINE1:lowmem_prunes_avg#" .. self.palette.FullRed .. ":Lowmem Prunes ", + "GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,", + "GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,", + "GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,", + "GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\\l", + "LINE1:unknown#" .. self.palette.Canvas .. ":Queries in cache", + "GPRINT:queries_min:MIN:%5.0lf Min,", + "GPRINT:queries_avg:AVERAGE:%5.0lf Avg,", + "GPRINT:queries_max:MAX:%5.0lf Max,", + "GPRINT:queries_avg:LAST:%5.0lf Last\\l" + }, + + mysql_threads = { + "-v", "Threads", + "DEF:running_min={file}:running:MIN", + "DEF:running_avg={file}:running:AVERAGE", + "DEF:running_max={file}:running:MAX", + "DEF:connected_min={file}:connected:MIN", + "DEF:connected_avg={file}:connected:AVERAGE", + "DEF:connected_max={file}:connected:MAX", + "DEF:cached_min={file}:cached:MIN", + "DEF:cached_avg={file}:cached:AVERAGE", + "DEF:cached_max={file}:cached:MAX", + "DEF:created_min={file}:created:MIN", + "DEF:created_avg={file}:created:AVERAGE", + "DEF:created_max={file}:created:MAX", + "CDEF:unknown=created_avg,UNKN,+", + "CDEF:cached_agg=connected_avg,cached_avg,+", + "AREA:cached_agg#" .. self.palette.HalfGreen, + "AREA:connected_avg#" .. self.palette.HalfBlue, + "AREA:running_avg#" .. self.palette.HalfRed, + "LINE1:cached_agg#" .. self.palette.FullGreen .. ":Cached ", + "GPRINT:cached_min:MIN:%5.1lf Min,", + "GPRINT:cached_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:cached_max:MAX:%5.1lf Max,", + "GPRINT:cached_avg:LAST:%5.1lf Last\\l", + "LINE1:connected_avg#" .. self.palette.FullBlue .. ":Connected", + "GPRINT:connected_min:MIN:%5.1lf Min,", + "GPRINT:connected_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:connected_max:MAX:%5.1lf Max,", + "GPRINT:connected_avg:LAST:%5.1lf Last\\l", + "LINE1:running_avg#" .. self.palette.FullRed .. ":Running ", + "GPRINT:running_min:MIN:%5.1lf Min,", + "GPRINT:running_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:running_max:MAX:%5.1lf Max,", + "GPRINT:running_avg:LAST:%5.1lf Last\\l", + "LINE1:unknown#" .. self.palette.Canvas .. ":Created ", + "GPRINT:created_min:MIN:%5.0lf Min,", + "GPRINT:created_avg:AVERAGE:%5.0lf Avg,", + "GPRINT:created_max:MAX:%5.0lf Max,", + "GPRINT:created_avg:LAST:%5.0lf Last\\l" + }, + + nfs_procedure = { + "-v", "Issues/s", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + nfs3_procedures = { + "DEF:null_avg={file}:null:AVERAGE", + "DEF:getattr_avg={file}:getattr:AVERAGE", + "DEF:setattr_avg={file}:setattr:AVERAGE", + "DEF:lookup_avg={file}:lookup:AVERAGE", + "DEF:access_avg={file}:access:AVERAGE", + "DEF:readlink_avg={file}:readlink:AVERAGE", + "DEF:read_avg={file}:read:AVERAGE", + "DEF:write_avg={file}:write:AVERAGE", + "DEF:create_avg={file}:create:AVERAGE", + "DEF:mkdir_avg={file}:mkdir:AVERAGE", + "DEF:symlink_avg={file}:symlink:AVERAGE", + "DEF:mknod_avg={file}:mknod:AVERAGE", + "DEF:remove_avg={file}:remove:AVERAGE", + "DEF:rmdir_avg={file}:rmdir:AVERAGE", + "DEF:rename_avg={file}:rename:AVERAGE", + "DEF:link_avg={file}:link:AVERAGE", + "DEF:readdir_avg={file}:readdir:AVERAGE", + "DEF:readdirplus_avg={file}:readdirplus:AVERAGE", + "DEF:fsstat_avg={file}:fsstat:AVERAGE", + "DEF:fsinfo_avg={file}:fsinfo:AVERAGE", + "DEF:pathconf_avg={file}:pathconf:AVERAGE", + "DEF:commit_avg={file}:commit:AVERAGE", + "DEF:null_max={file}:null:MAX", + "DEF:getattr_max={file}:getattr:MAX", + "DEF:setattr_max={file}:setattr:MAX", + "DEF:lookup_max={file}:lookup:MAX", + "DEF:access_max={file}:access:MAX", + "DEF:readlink_max={file}:readlink:MAX", + "DEF:read_max={file}:read:MAX", + "DEF:write_max={file}:write:MAX", + "DEF:create_max={file}:create:MAX", + "DEF:mkdir_max={file}:mkdir:MAX", + "DEF:symlink_max={file}:symlink:MAX", + "DEF:mknod_max={file}:mknod:MAX", + "DEF:remove_max={file}:remove:MAX", + "DEF:rmdir_max={file}:rmdir:MAX", + "DEF:rename_max={file}:rename:MAX", + "DEF:link_max={file}:link:MAX", + "DEF:readdir_max={file}:readdir:MAX", + "DEF:readdirplus_max={file}:readdirplus:MAX", + "DEF:fsstat_max={file}:fsstat:MAX", + "DEF:fsinfo_max={file}:fsinfo:MAX", + "DEF:pathconf_max={file}:pathconf:MAX", + "DEF:commit_max={file}:commit:MAX", + "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+", + "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+", + "CDEF:stack_read=read_avg", + "CDEF:stack_getattr=stack_read,getattr_avg,+", + "CDEF:stack_access=stack_getattr,access_avg,+", + "CDEF:stack_lookup=stack_access,lookup_avg,+", + "CDEF:stack_write=stack_lookup,write_avg,+", + "CDEF:stack_commit=stack_write,commit_avg,+", + "CDEF:stack_setattr=stack_commit,setattr_avg,+", + "CDEF:stack_other=stack_setattr,other_avg,+", + "AREA:stack_other#" .. self.palette.HalfRed, + "AREA:stack_setattr#" .. self.palette.HalfGreen, + "AREA:stack_commit#" .. self.palette.HalfYellow, + "AREA:stack_write#" .. self.palette.HalfGreen, + "AREA:stack_lookup#" .. self.palette.HalfBlue, + "AREA:stack_access#" .. self.palette.HalfMagenta, + "AREA:stack_getattr#" .. self.palette.HalfCyan, + "AREA:stack_read#" .. self.palette.HalfBlue, + "LINE1:stack_other#" .. self.palette.FullRed .. ":Other ", + "GPRINT:other_max:MAX:%5.1lf Max,", + "GPRINT:other_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:other_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_setattr#" .. self.palette.FullGreen .. ":setattr", + "GPRINT:setattr_max:MAX:%5.1lf Max,", + "GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:setattr_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_commit#" .. self.palette.FullYellow .. ":commit ", + "GPRINT:commit_max:MAX:%5.1lf Max,", + "GPRINT:commit_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:commit_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_write#" .. self.palette.FullGreen .. ":write ", + "GPRINT:write_max:MAX:%5.1lf Max,", + "GPRINT:write_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:write_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_lookup#" .. self.palette.FullBlue .. ":lookup ", + "GPRINT:lookup_max:MAX:%5.1lf Max,", + "GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:lookup_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_access#" .. self.palette.FullMagenta .. ":access ", + "GPRINT:access_max:MAX:%5.1lf Max,", + "GPRINT:access_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:access_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_getattr#" .. self.palette.FullCyan .. ":getattr", + "GPRINT:getattr_max:MAX:%5.1lf Max,", + "GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:getattr_avg:LAST:%5.1lf Last\\l", + "LINE1:stack_read#" .. self.palette.FullBlue .. ":read ", + "GPRINT:read_max:MAX:%5.1lf Max,", + "GPRINT:read_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:read_avg:LAST:%5.1lf Last\\l" + }, + + partition = { + "DEF:rbyte_avg={file}:rbytes:AVERAGE", + "DEF:rbyte_min={file}:rbytes:MIN", + "DEF:rbyte_max={file}:rbytes:MAX", + "DEF:wbyte_avg={file}:wbytes:AVERAGE", + "DEF:wbyte_min={file}:wbytes:MIN", + "DEF:wbyte_max={file}:wbytes:MAX", + "CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF", + "AREA:wbyte_avg#" .. self.palette.HalfGreen, + "AREA:rbyte_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:wbyte_avg#" .. self.palette.FullGreen .. ":Write", + "GPRINT:wbyte_min:MIN:%5.1lf%s Min,", + "GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:wbyte_max:MAX:%5.1lf%s Max,", + "GPRINT:wbyte_avg:LAST:%5.1lf%s Last\\l", + "LINE1:rbyte_avg#" .. self.palette.FullBlue .. ":Read ", + "GPRINT:rbyte_min:MIN:%5.1lf%s Min,", + "GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:rbyte_max:MAX:%5.1lf%s Max,", + "GPRINT:rbyte_avg:LAST:%5.1lf%s Last\\l" + }, + + percent = { + "-v", "Percent", + "DEF:avg={file}:percent:AVERAGE", + "DEF:min={file}:percent:MIN", + "DEF:max={file}:percent:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", + "GPRINT:min:MIN:%5.1lf%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%% Avg,", + "GPRINT:max:MAX:%5.1lf%% Max,", + "GPRINT:avg:LAST:%5.1lf%% Last\\l" + }, + + ping = { + "DEF:ping_avg={file}:ping:AVERAGE", + "DEF:ping_min={file}:ping:MIN", + "DEF:ping_max={file}:ping:MAX", + "AREA:ping_max#" .. self.palette.HalfBlue, + "AREA:ping_min#" .. self.palette.Canvas, + "LINE1:ping_avg#" .. self.palette.FullBlue .. ":Ping", + "GPRINT:ping_min:MIN:%4.1lf ms Min,", + "GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,", + "GPRINT:ping_max:MAX:%4.1lf ms Max,", + "GPRINT:ping_avg:LAST:%4.1lf ms Last\\l" + }, + + power = { + "-v", "Watt", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Watt", + "GPRINT:min:MIN:%5.1lf%sW Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sW Avg,", + "GPRINT:max:MAX:%5.1lf%sW Max,", + "GPRINT:avg:LAST:%5.1lf%sW Last\\l" + }, + + processes = { + "DEF:running_avg={file}:running:AVERAGE", + "DEF:running_min={file}:running:MIN", + "DEF:running_max={file}:running:MAX", + "DEF:sleeping_avg={file}:sleeping:AVERAGE", + "DEF:sleeping_min={file}:sleeping:MIN", + "DEF:sleeping_max={file}:sleeping:MAX", + "DEF:zombies_avg={file}:zombies:AVERAGE", + "DEF:zombies_min={file}:zombies:MIN", + "DEF:zombies_max={file}:zombies:MAX", + "DEF:stopped_avg={file}:stopped:AVERAGE", + "DEF:stopped_min={file}:stopped:MIN", + "DEF:stopped_max={file}:stopped:MAX", + "DEF:paging_avg={file}:paging:AVERAGE", + "DEF:paging_min={file}:paging:MIN", + "DEF:paging_max={file}:paging:MAX", + "DEF:blocked_avg={file}:blocked:AVERAGE", + "DEF:blocked_min={file}:blocked:MIN", + "DEF:blocked_max={file}:blocked:MAX", + "CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+", + "CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+", + "CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+", + "CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+", + "CDEF:running_acc=sleeping_avg,running_avg,+", + "CDEF:sleeping_acc=sleeping_avg", + "AREA:paging_acc#" .. self.palette.HalfYellow, + "AREA:blocked_acc#" .. self.palette.HalfCyan, + "AREA:zombies_acc#" .. self.palette.HalfRed, + "AREA:stopped_acc#" .. self.palette.HalfMagenta, + "AREA:running_acc#" .. self.palette.HalfGreen, + "AREA:sleeping_acc#" .. self.palette.HalfBlue, + "LINE1:paging_acc#" .. self.palette.FullYellow .. ":Paging ", + "GPRINT:paging_min:MIN:%5.1lf Min,", + "GPRINT:paging_avg:AVERAGE:%5.1lf Average,", + "GPRINT:paging_max:MAX:%5.1lf Max,", + "GPRINT:paging_avg:LAST:%5.1lf Last\\l", + "LINE1:blocked_acc#" .. self.palette.FullCyan .. ":Blocked ", + "GPRINT:blocked_min:MIN:%5.1lf Min,", + "GPRINT:blocked_avg:AVERAGE:%5.1lf Average,", + "GPRINT:blocked_max:MAX:%5.1lf Max,", + "GPRINT:blocked_avg:LAST:%5.1lf Last\\l", + "LINE1:zombies_acc#" .. self.palette.FullRed .. ":Zombies ", + "GPRINT:zombies_min:MIN:%5.1lf Min,", + "GPRINT:zombies_avg:AVERAGE:%5.1lf Average,", + "GPRINT:zombies_max:MAX:%5.1lf Max,", + "GPRINT:zombies_avg:LAST:%5.1lf Last\\l", + "LINE1:stopped_acc#" .. self.palette.FullMagenta .. ":Stopped ", + "GPRINT:stopped_min:MIN:%5.1lf Min,", + "GPRINT:stopped_avg:AVERAGE:%5.1lf Average,", + "GPRINT:stopped_max:MAX:%5.1lf Max,", + "GPRINT:stopped_avg:LAST:%5.1lf Last\\l", + "LINE1:running_acc#" .. self.palette.FullGreen .. ":Running ", + "GPRINT:running_min:MIN:%5.1lf Min,", + "GPRINT:running_avg:AVERAGE:%5.1lf Average,", + "GPRINT:running_max:MAX:%5.1lf Max,", + "GPRINT:running_avg:LAST:%5.1lf Last\\l", + "LINE1:sleeping_acc#" .. self.palette.FullBlue .. ":Sleeping", + "GPRINT:sleeping_min:MIN:%5.1lf Min,", + "GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,", + "GPRINT:sleeping_max:MAX:%5.1lf Max,", + "GPRINT:sleeping_avg:LAST:%5.1lf Last\\l" + }, + + ps_count = { + "-v", "Processes", + "DEF:procs_avg={file}:processes:AVERAGE", + "DEF:procs_min={file}:processes:MIN", + "DEF:procs_max={file}:processes:MAX", + "DEF:thrds_avg={file}:threads:AVERAGE", + "DEF:thrds_min={file}:threads:MIN", + "DEF:thrds_max={file}:threads:MAX", + "AREA:thrds_avg#" .. self.palette.HalfBlue, + "AREA:procs_avg#" .. self.palette.HalfRed, + "LINE1:thrds_avg#" .. self.palette.FullBlue .. ":Threads ", + "GPRINT:thrds_min:MIN:%5.1lf Min,", + "GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:thrds_max:MAX:%5.1lf Max,", + "GPRINT:thrds_avg:LAST:%5.1lf Last\\l", + "LINE1:procs_avg#" .. self.palette.FullRed .. ":Processes", + "GPRINT:procs_min:MIN:%5.1lf Min,", + "GPRINT:procs_avg:AVERAGE:%5.1lf Avg,", + "GPRINT:procs_max:MAX:%5.1lf Max,", + "GPRINT:procs_avg:LAST:%5.1lf Last\\l" + }, + + ps_cputime = { + "-v", "Jiffies", + "DEF:user_avg_raw={file}:user:AVERAGE", + "DEF:user_min_raw={file}:user:MIN", + "DEF:user_max_raw={file}:user:MAX", + "DEF:syst_avg_raw={file}:syst:AVERAGE", + "DEF:syst_min_raw={file}:syst:MIN", + "DEF:syst_max_raw={file}:syst:MAX", + "CDEF:user_avg=user_avg_raw,1000000,/", + "CDEF:user_min=user_min_raw,1000000,/", + "CDEF:user_max=user_max_raw,1000000,/", + "CDEF:syst_avg=syst_avg_raw,1000000,/", + "CDEF:syst_min=syst_min_raw,1000000,/", + "CDEF:syst_max=syst_max_raw,1000000,/", + "CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+", + "AREA:user_syst#" .. self.palette.HalfBlue, + "AREA:syst_avg#" .. self.palette.HalfRed, + "LINE1:user_syst#" .. self.palette.FullBlue .. ":User ", + "GPRINT:user_min:MIN:%5.1lf%s Min,", + "GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:user_max:MAX:%5.1lf%s Max,", + "GPRINT:user_avg:LAST:%5.1lf%s Last\\l", + "LINE1:syst_avg#" .. self.palette.FullRed .. ":System", + "GPRINT:syst_min:MIN:%5.1lf%s Min,", + "GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:syst_max:MAX:%5.1lf%s Max,", + "GPRINT:syst_avg:LAST:%5.1lf%s Last\\l" + }, + + ps_pagefaults = { + "-v", "Pagefaults/s", + "DEF:minor_avg={file}:minflt:AVERAGE", + "DEF:minor_min={file}:minflt:MIN", + "DEF:minor_max={file}:minflt:MAX", + "DEF:major_avg={file}:majflt:AVERAGE", + "DEF:major_min={file}:majflt:MIN", + "DEF:major_max={file}:majflt:MAX", + "CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+", + "AREA:minor_major#" .. self.palette.HalfBlue, + "AREA:major_avg#" .. self.palette.HalfRed, + "LINE1:minor_major#" .. self.palette.FullBlue .. ":Minor", + "GPRINT:minor_min:MIN:%5.1lf%s Min,", + "GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:minor_max:MAX:%5.1lf%s Max,", + "GPRINT:minor_avg:LAST:%5.1lf%s Last\\l", + "LINE1:major_avg#" .. self.palette.FullRed .. ":Major", + "GPRINT:major_min:MIN:%5.1lf%s Min,", + "GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:major_max:MAX:%5.1lf%s Max,", + "GPRINT:major_avg:LAST:%5.1lf%s Last\\l" + }, + + ps_rss = { + "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:avg#" .. self.palette.HalfBlue, + "LINE1:avg#" .. self.palette.FullBlue .. ":RSS", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + ps_state = { + "-v", "Processes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%6.2lf Min,", + "GPRINT:avg:AVERAGE:%6.2lf Avg,", + "GPRINT:max:MAX:%6.2lf Max,", + "GPRINT:avg:LAST:%6.2lf Last\\l" + }, + + signal_noise = { + "-v", "dBm", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Noise", + "GPRINT:min:MIN:%5.1lf%sdBm Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", + "GPRINT:max:MAX:%5.1lf%sdBm Max,", + "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" + }, + + signal_power = { + "-v", "dBm", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Power", + "GPRINT:min:MIN:%5.1lf%sdBm Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", + "GPRINT:max:MAX:%5.1lf%sdBm Max,", + "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" + }, + + signal_quality = { + "-v", "%", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Quality", + "GPRINT:min:MIN:%5.1lf%s%% Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", + "GPRINT:max:MAX:%5.1lf%s%% Max,", + "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" + }, + + swap = { + "-v", "Bytes", "-b", "1024", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Bytes", + "GPRINT:min:MIN:%6.2lf%sByte Min,", + "GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,", + "GPRINT:max:MAX:%6.2lf%sByte Max,", + "GPRINT:avg:LAST:%6.2lf%sByte Last\\l" + }, + + old_swap = { + "DEF:used_avg={file}:used:AVERAGE", + "DEF:used_min={file}:used:MIN", + "DEF:used_max={file}:used:MAX", + "DEF:free_avg={file}:free:AVERAGE", + "DEF:free_min={file}:free:MIN", + "DEF:free_max={file}:free:MAX", + "DEF:cach_avg={file}:cached:AVERAGE", + "DEF:cach_min={file}:cached:MIN", + "DEF:cach_max={file}:cached:MAX", + "DEF:resv_avg={file}:resv:AVERAGE", + "DEF:resv_min={file}:resv:MIN", + "DEF:resv_max={file}:resv:MAX", + "CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF", + "CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF", + "CDEF:used_acc=used_avg", + "CDEF:resv_acc=used_acc,resv_avg_notnull,+", + "CDEF:cach_acc=resv_acc,cach_avg_notnull,+", + "CDEF:free_acc=cach_acc,free_avg,+", + "AREA:free_acc#" .. self.palette.HalfGreen, + "AREA:cach_acc#" .. self.palette.HalfBlue, + "AREA:resv_acc#" .. self.palette.HalfYellow, + "AREA:used_acc#" .. self.palette.HalfRed, + "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free ", + "GPRINT:free_min:MIN:%5.1lf%s Min,", + "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:free_max:MAX:%5.1lf%s Max,", + "GPRINT:free_avg:LAST:%5.1lf%s Last\n", + "LINE1:cach_acc#" .. self.palette.FullBlue .. ":Cached ", + "GPRINT:cach_min:MIN:%5.1lf%s Min,", + "GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cach_max:MAX:%5.1lf%s Max,", + "GPRINT:cach_avg:LAST:%5.1lf%s Last\\l", + "LINE1:resv_acc#" .. self.palette.FullYellow .. ":Reserved", + "GPRINT:resv_min:MIN:%5.1lf%s Min,", + "GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:resv_max:MAX:%5.1lf%s Max,", + "GPRINT:resv_avg:LAST:%5.1lf%s Last\n", + "LINE1:used_acc#" .. self.palette.FullRed .. ":Used ", + "GPRINT:used_min:MIN:%5.1lf%s Min,", + "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:used_max:MAX:%5.1lf%s Max,", + "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" + }, + + tcp_connections = { + "-v", "Connections", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Connections", + "GPRINT:min:MIN:%4.1lf Min,", + "GPRINT:avg:AVERAGE:%4.1lf Avg,", + "GPRINT:max:MAX:%4.1lf Max,", + "GPRINT:avg:LAST:%4.1lf Last\\l" + }, + + temperature = { + "-v", "Celsius", + "DEF:temp_avg={file}:value:AVERAGE", + "DEF:temp_min={file}:value:MIN", + "DEF:temp_max={file}:value:MAX", + "CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+", + "AREA:temp_max#" .. self.palette.HalfRed, + "AREA:temp_min#" .. self.palette.Canvas, + "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", + "GPRINT:temp_min:MIN:%4.1lf Min,", + "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", + "GPRINT:temp_max:MAX:%4.1lf Max,", + "GPRINT:temp_avg:LAST:%4.1lf Last\\l" + }, + + timeleft = { + "-v", "Minutes", + "DEF:avg={file}:timeleft:AVERAGE", + "DEF:min={file}:timeleft:MIN", + "DEF:max={file}:timeleft:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Time left [min]", + "GPRINT:min:MIN:%5.1lf%s Min,", + "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:max:MAX:%5.1lf%s Max,", + "GPRINT:avg:LAST:%5.1lf%s Last\\l" + }, + + time_offset = { + "DEF:s_avg={file}:seconds:AVERAGE", + "DEF:s_min={file}:seconds:MIN", + "DEF:s_max={file}:seconds:MAX", + "AREA:s_max#" .. self.palette.HalfBlue, + "AREA:s_min#" .. self.palette.Canvas, + "LINE1:s_avg#" .. self.palette.FullBlue .. ":{inst}", + "GPRINT:s_min:MIN:%7.3lf%s Min,", + "GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,", + "GPRINT:s_max:MAX:%7.3lf%s Max,", + "GPRINT:s_avg:LAST:%7.3lf%s Last\\l" + }, + + if_octets = { + "-v", "Bits/s", "-l", "0", + "DEF:out_min_raw={file}:tx:MIN", + "DEF:out_avg_raw={file}:tx:AVERAGE", + "DEF:out_max_raw={file}:tx:MAX", + "DEF:inc_min_raw={file}:rx:MIN", + "DEF:inc_avg_raw={file}:rx:AVERAGE", + "DEF:inc_max_raw={file}:rx:MAX", + "CDEF:out_min=out_min_raw,8,*", + "CDEF:out_avg=out_avg_raw,8,*", + "CDEF:out_max=out_max_raw,8,*", + "CDEF:inc_min=inc_min_raw,8,*", + "CDEF:inc_avg=inc_avg_raw,8,*", + "CDEF:inc_max=inc_max_raw,8,*", + "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", + "CDEF:mytime=out_avg_raw,TIME,TIME,IF", + "CDEF:sample_len_raw=mytime,PREV(mytime),-", + "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", + "CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*", + "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", + "CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*", + "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", + "AREA:out_avg#" .. self.palette.HalfGreen, + "AREA:inc_avg#" .. self.palette.HalfBlue, + "AREA:overlap#" .. self.palette.HalfBlueGreen, + "LINE1:out_avg#" .. self.palette.FullGreen .. ":Outgoing", + "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:out_max:MAX:%5.1lf%s Max,", + "GPRINT:out_avg:LAST:%5.1lf%s Last", + "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l", + "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Incoming", + --"GPRINT:inc_min:MIN:%5.1lf %s Min,", + "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:inc_max:MAX:%5.1lf%s Max,", + "GPRINT:inc_avg:LAST:%5.1lf%s Last", + "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l" + }, + + cpufreq = { + "DEF:cpufreq_avg={file}:value:AVERAGE", + "DEF:cpufreq_min={file}:value:MIN", + "DEF:cpufreq_max={file}:value:MAX", + "AREA:cpufreq_max#" .. self.palette.HalfBlue, + "AREA:cpufreq_min#" .. self.palette.Canvas, + "LINE1:cpufreq_avg#" .. self.palette.FullBlue .. ":Frequency", + "GPRINT:cpufreq_min:MIN:%5.1lf%s Min,", + "GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,", + "GPRINT:cpufreq_max:MAX:%5.1lf%s Max,", + "GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\\l" + }, + + multimeter = { + "DEF:multimeter_avg={file}:value:AVERAGE", + "DEF:multimeter_min={file}:value:MIN", + "DEF:multimeter_max={file}:value:MAX", + "AREA:multimeter_max#" .. self.palette.HalfBlue, + "AREA:multimeter_min#" .. self.palette.Canvas, + "LINE1:multimeter_avg#" .. self.palette.FullBlue .. ":Multimeter", + "GPRINT:multimeter_min:MIN:%4.1lf Min,", + "GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,", + "GPRINT:multimeter_max:MAX:%4.1lf Max,", + "GPRINT:multimeter_avg:LAST:%4.1lf Last\\l" + }, + + users = { + "-v", "Users", + "DEF:users_avg={file}:users:AVERAGE", + "DEF:users_min={file}:users:MIN", + "DEF:users_max={file}:users:MAX", + "AREA:users_max#" .. self.palette.HalfBlue, + "AREA:users_min#" .. self.palette.Canvas, + "LINE1:users_avg#" .. self.palette.FullBlue .. ":Users", + "GPRINT:users_min:MIN:%4.1lf Min,", + "GPRINT:users_avg:AVERAGE:%4.1lf Average,", + "GPRINT:users_max:MAX:%4.1lf Max,", + "GPRINT:users_avg:LAST:%4.1lf Last\\l" + }, + + voltage = { + "-v", "Voltage", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Voltage", + "GPRINT:min:MIN:%5.1lf%sV Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sV Avg,", + "GPRINT:max:MAX:%5.1lf%sV Max,", + "GPRINT:avg:LAST:%5.1lf%sV Last\\l" + }, + + vs_threads = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Threads", + "GPRINT:min:MIN:%5.1lf Min,", + "GPRINT:avg:AVERAGE:%5.1lf Avg.,", + "GPRINT:max:MAX:%5.1lf Max,", + "GPRINT:avg:LAST:%5.1lf Last\\l", + }, + + vs_memory = { + "-b", "1024", "-v", "Bytes", + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":", + "GPRINT:min:MIN:%5.1lf%sbytes Min,", + "GPRINT:avg:AVERAGE:%5.1lf%sbytes Avg.,", + "GPRINT:max:MAX:%5.1lf%sbytes Max,", + "GPRINT:avg:LAST:%5.1lf%sbytes Last\\l", + }, + + vs_processes = { + "DEF:avg={file}:value:AVERAGE", + "DEF:min={file}:value:MIN", + "DEF:max={file}:value:MAX", + "AREA:max#" .. self.palette.HalfBlue, + "AREA:min#" .. self.palette.Canvas, + "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", + "GPRINT:min:MIN:%5.1lf Min,", + "GPRINT:avg:AVERAGE:%5.1lf Avg.,", + "GPRINT:max:MAX:%5.1lf Max,", + "GPRINT:avg:LAST:%5.1lf Last\\l", + }, + } +end + diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua new file mode 100644 index 000000000..2626d276d --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/cpu/cpu.lua @@ -0,0 +1,31 @@ +module("luci.statistics.rrdtool.definitions.cpu.cpu",package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance, dtype ) + + dtype_instances = { "idle", "nice", "system", "user" } + + opts = { } + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) + opts.title = host .. ": Prozessorauslastung" + opts.rrd = { "-v", "Percent" } + opts.colors = { + idle = 'ffffff', + nice = '00e000', + user = '0000ff', + wait = 'ffb000', + system = 'ff0000', + softirq = 'ff00ff', + interrupt = 'a000a0', + steal = '000000' + } + + for i, inst in ipairs(dtype_instances) do + opts.sources[i] = { + name = inst, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua new file mode 100644 index 000000000..b16add995 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/iptables/ipt_packets.lua @@ -0,0 +1,26 @@ +module("luci.statistics.rrdtool.definitions.iptables.ipt_packets", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance, dtype ) + + dtype_instances = graph.tree:data_instances( plugin, plugin_instance, dtype ) + opts = { } + + for i, inst in ipairs(dtype_instances) do + + opts[i] = { } + opts[i].image = graph:mkpngpath( host, plugin, plugin_instance, dtype, inst ) + opts[i].title = host .. ": Firewall - " .. inst:gsub("_"," ") + opts[i].rrd = { "-v", "Pakete/s" } + + opts[i].colors = { + + } + + opts[i].sources = { { + name = inst, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua new file mode 100644 index 000000000..3cee6abc0 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/netlink.lua @@ -0,0 +1,163 @@ +module("luci.statistics.rrdtool.definitions.netlink", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance ) + + local diagram_list = { } + + -- diagram names + local dtypes_names = { + "Pakete", + "Paketkollisionen", + "Paketfehler", + "Verkehr", + "RX-Fehler", + "TX-Fehler" + } + + -- diagram units + local dtypes_units = { + "Pakete/s", + "Kollisionen/s", + "Fehler/s", -- (?) + "Bytes/s", + "Fehler/s", + "Fehler/s" + } + + -- data source overrides + local dtypes_sources = { + if_errors = { "rx", "tx" }, -- if_errors has rx and tx + if_octets = { "rx", "tx" } -- if_octets has rx and tx + } + + -- diagram data types + local dtypes_list = { + + -- diagram 1: combined interface packet statistics + { + if_dropped = { "" }, -- packets/s + if_multicast = { "" }, -- packets/s + if_packets = { "" } -- packets/s + }, + + -- diagram 2: interface collision statistics + { + if_collisions = { "" } -- collisions/s + }, + + -- diagram 3: interface error statistics + { + if_errors = { "" } -- errors/s (?) + }, + + -- diagram 4: interface traffic statistics + { + if_octets = { "" } -- bytes/s + }, + + -- diagram 5: interface rx error statistics + { + if_rx_errors = { -- errors/s + "length", "missed", "over", "crc", "fifo", "frame" + } + }, + + -- diagram 6: interface tx error statistics + { + if_tx_errors = { -- errors/s + "aborted", "carrier", "fifo", "heartbeat", "window" + } + } + } + + -- diagram colors + local dtypes_colors = { + + -- diagram 1 + { + if_dropped = "ff0000", + if_multicast = "0000ff", + if_packets = "00ff00" + }, + + -- diagram 2 + { + if_collisions = "ff0000" + }, + + -- diagram 3 + { + if_errors__tx_ = "ff0000", + if_errors__rx_ = "ff5500" + }, + + -- diagram 4 + { + if_octets__tx_ = "00ff00", + if_octets__rx_ = "0000ff" + }, + + -- diagram 5 + { + length = "0000ff", + missed = "ff5500", + over = "ff0066", + crc = "ff0000", + fifo = "00ff00", + frame = "ffff00" + }, + + -- diagram 6 + { + aborted = "ff0000", + carrier = "ffff00", + fifo = "00ff00", + heartbeat = "0000ff", + window = "8800ff" + } + } + + + for i, name in ipairs(dtypes_names) do + + local dtypes = dtypes_list[i] + local opts = { } + + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, "netlink" .. i ) + opts.title = host .. ": Netlink Statistiken - " .. name .. " auf " .. plugin_instance + opts.rrd = { "-v", dtypes_units[i] } + opts.colors = dtypes_colors[i] + + for dtype, dinstances in pairs(dtypes) do + for i, inst in ipairs(dinstances) do + + local name = inst + if name:len() == 0 then name = dtype end + + -- check for data source override + if dtypes_sources[dtype] then + + -- has override + for i, ds in ipairs(dtypes_sources[dtype]) do + table.insert( opts.sources, { + ds = ds, -- override + name = name .. " (" .. ds .. ")", + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } ) + end + else + -- no override, assume single "value" data source + table.insert( opts.sources, { + name = name, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } ) + end + end + end + + table.insert( diagram_list, opts ) + end + + return diagram_list +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua new file mode 100644 index 000000000..b041c015d --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/ping/ping.lua @@ -0,0 +1,23 @@ +module("luci.statistics.rrdtool.definitions.ping.ping", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance, dtype ) + + dtype_instances = graph.tree:data_instances( plugin, plugin_instance, dtype ) + + opts = { } + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) + opts.title = host .. ": Pingzeiten" + opts.rrd = { "-v", "Millisekunden" } + opts.colors = { } + + for i, inst in ipairs(dtype_instances) do + opts.sources[i] = { + ds = "ping", + name = inst, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua new file mode 100644 index 000000000..07cbe1d4a --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/processes/ps_state.lua @@ -0,0 +1,31 @@ +module("luci.statistics.rrdtool.definitions.processes.ps_state", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance, dtype ) + + dtype_instances = { + "sleeping", "running", "paging", "blocked", "stopped", "zombies" + } + + opts = { } + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) + opts.title = host .. ": Prozesse" + opts.rrd = { "-v", "Anzahl" } + opts.colors = { + sleeping = "008080", + running = "008000", + paging = "ffff00", + blocked = "ff5000", + stopped = "555555", + zombies = "ff0000" + } + + for i, inst in ipairs(dtype_instances) do + opts.sources[i] = { + name = inst, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, "ps_state", inst ) + } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua new file mode 100644 index 000000000..049357494 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua @@ -0,0 +1,27 @@ +module("luci.statistics.rrdtool.definitions.tcpconns.tcp_connections", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance, dtype ) + + dtype_instances = { + "SYN_SENT", "SYN_RECV", "LISTEN", "ESTABLISHED", "LAST_ACK", "TIME_WAIT", + "CLOSING", "CLOSE_WAIT", "CLOSED", "FIN_WAIT1", "FIN_WAIT2" + } + + opts = { } + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) + opts.title = host .. ": TCP-Verbindungen - Port " .. plugin_instance + opts.rrd = { "-v", "Anzahl" } + opts.colors = { + + } + + for i, inst in ipairs(dtype_instances) do + opts.sources[i] = { + name = inst, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) + } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua new file mode 100644 index 000000000..e315ca521 --- /dev/null +++ b/applications/luci-statistics/luasrc/statistics/rrdtool/definitions/wireless.lua @@ -0,0 +1,25 @@ +module("luci.statistics.rrdtool.definitions.wireless", package.seeall) + +function rrdargs( graph, host, plugin, plugin_instance ) + + dtypes = { "signal_power", "signal_noise" } + + opts = { } + opts.sources = { } + opts.image = graph:mkpngpath( host, plugin, plugin_instance, "wireless" ) + opts.title = host .. ": WLAN Signal" + opts.rrd = { "-v", "dBm" } + opts.colors = { + signal_power = '0000ff', + signal_noise = 'ff0000' + } + + for i, dtype in ipairs(dtypes) do + opts.sources[i] = { + name = dtype, + rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype ) + } + end + + return opts +end diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/index.htm b/applications/luci-statistics/luasrc/view/admin_statistics/index.htm new file mode 100644 index 000000000..2c1befa50 --- /dev/null +++ b/applications/luci-statistics/luasrc/view/admin_statistics/index.htm @@ -0,0 +1,8 @@ +<%+header%> + +

<%:stat Statistiken%>

+ +

<%:stat_desc Die Statistiken bauen auf Collectd auf und nutzen +RRD Tool um Graphen aus den erfassten Daten zu rendern.%>

+ +<%+footer%> diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm new file mode 100644 index 000000000..d3aa87eb1 --- /dev/null +++ b/applications/luci-statistics/luasrc/view/admin_statistics/networkplugins.htm @@ -0,0 +1,18 @@ +<%+header%> + +

<%:stat_networkplugins Netzwerkplugins%>

+ +

<%:stat_networkplugins_desc Netzwerkplugins sammeln Werte über offene TCP-Verbindung, allgemeines Verkehrsaufkommen +auf verschiedenen Schnittstellen, DNS-Verkehr u.v.m.%>

+ +

<%:stat_networkplugins_installed Installierte Netzwerkplugins:%> +

    + <% for plugin, desc in pairs(plugins) do %> + <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> +
  • <%=desc%>
  • + <% end %> + <% end %> +
+

+ +<%+footer%> diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm new file mode 100644 index 000000000..5a8a76045 --- /dev/null +++ b/applications/luci-statistics/luasrc/view/admin_statistics/outputplugins.htm @@ -0,0 +1,19 @@ +<%+header%> + +

<%:stat_outputplugins Ausgabeplugins%>

+ +

<%:stat_outputplugins_desc Ausgabeplugins stellen verschiedene Möglichkeiten zur Speicherung +der Daten bereit. Es können auch mehrere Plugins gleichzeitig aktiviert werden um beispielsweise +die gesammelten Werte in RRD-Datenbanken zu sichern und zusätzlich über das Netzwerk zu versenden.%>

+ +

<%:stat_outputplugins_installed Installierte Ausgabeplugins:%> +

    + <% for plugin, desc in pairs(plugins) do %> + <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> +
  • <%=desc%>
  • + <% end %> + <% end %> +
+

+ +<%+footer%> diff --git a/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm b/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm new file mode 100644 index 000000000..2a32bf5ca --- /dev/null +++ b/applications/luci-statistics/luasrc/view/admin_statistics/systemplugins.htm @@ -0,0 +1,18 @@ +<%+header%> + +

<%:stat_systemplugins Systemplugins%>

+ +

<%:stat_systemplugins_desc Systemplugins sammeln Werte über den aktuellen Systemzustand und den Ressourcenverbrauch +auf dem Gerät.%>

+ +

<%:stat_systemplugins_installed Installierte Systemplugins:%> +

    + <% for plugin, desc in pairs(plugins) do %> + <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> +
  • <%=desc%>
  • + <% end %> + <% end %> +
+

+ +<%+footer%> diff --git a/applications/luci-statistics/luasrc/view/public_statistics/graph.htm b/applications/luci-statistics/luasrc/view/public_statistics/graph.htm new file mode 100644 index 000000000..093d76d0e --- /dev/null +++ b/applications/luci-statistics/luasrc/view/public_statistics/graph.htm @@ -0,0 +1,9 @@ +<%+header%> + +

Statistik

+ +<% for i, img in ipairs(images) do %> + " /> +<% end %> + +<%+footer%> diff --git a/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua b/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua deleted file mode 100644 index df262a115..000000000 --- a/applications/luci-statistics/src/controller/luci_statistics/luci_statistics.lua +++ /dev/null @@ -1,107 +0,0 @@ -module("luci.controller.luci_statistics.luci_statistics", package.seeall) - -local fs = require("luci.fs") -local tpl = require("luci.template") -local rrd = require("luci.statistics.rrdtool") -local data = require("luci.statistics.datatree").Instance() - - -function _entry( path, ... ) - local file = path[4] or path[3] - if fs.isfile( "/usr/lib/collectd/" .. file .. ".so" ) then - entry( path, ... ) - end -end - - -function index() - entry({"admin", "statistics"}, statistics_index, "Statistiken", 80) - entry({"admin", "statistics", "collectd"}, cbi("luci_statistics/collectd"), "Collectd", 10) - - entry({"admin", "statistics", "output"}, statistics_outputplugins, "Ausgabeplugins", 20) - _entry({"admin", "statistics", "output", "rrdtool"}, cbi("luci_statistics/rrdtool"), "RRDTool", 10) - _entry({"admin", "statistics", "output", "network"}, cbi("luci_statistics/network"), "Netzwerk", 20) - _entry({"admin", "statistics", "output", "unixsock"}, cbi("luci_statistics/unixsock"), "Unix Socket", 30) - _entry({"admin", "statistics", "output", "csv"}, cbi("luci_statistics/csv"), "CSV", 40) - - entry({"admin", "statistics", "system"}, statistics_systemplugins, "Systemplugins", 30) - _entry({"admin", "statistics", "system", "exec"}, cbi("luci_statistics/exec"), "Exec", 10) - _entry({"admin", "statistics", "system", "email"}, cbi("luci_statistics/email"), "E-Mail", 20) - _entry({"admin", "statistics", "system", "cpu"}, cbi("luci_statistics/cpu"), "Prozessor", 30) - _entry({"admin", "statistics", "system", "df"}, cbi("luci_statistics/df"), "Speicherplatz", 40) - _entry({"admin", "statistics", "system", "disk"}, cbi("luci_statistics/disk"), "Datenträger", 50) - _entry({"admin", "statistics", "system", "irq"}, cbi("luci_statistics/irq"), "Interrupts", 60) - _entry({"admin", "statistics", "system", "processes"}, cbi("luci_statistics/processes"), "Prozesse", 70) - - entry({"admin", "statistics", "network"}, statistics_networkplugins, "Netzwerkplugins", 40) - _entry({"admin", "statistics", "network", "interface"}, cbi("luci_statistics/interface"), "Schnittstellen", 10) - _entry({"admin", "statistics", "network", "netlink"}, cbi("luci_statistics/netlink"), "Netlink", 20) - _entry({"admin", "statistics", "network", "iptables"}, cbi("luci_statistics/iptables"), "Firewall", 30) - _entry({"admin", "statistics", "network", "tcpconns"}, cbi("luci_statistics/tcpconns"), "Verbindungen", 40) - _entry({"admin", "statistics", "network", "ping"}, cbi("luci_statistics/ping"), "Ping", 50) - _entry({"admin", "statistics", "network", "dns"}, cbi("luci_statistics/dns"), "DNS", 60) - - - -- public views - entry({"freifunk", "statistics"}, statistics_index, "Statistiken", 80) - - for i, plugin in ipairs( data:plugins() ) do - _entry({"freifunk", "statistics", plugin}, statistics_render, plugin, i) - end -end - - -function statistics_index() - tpl.render("admin_statistics/index") -end - -function statistics_outputplugins() - plugins = { - rrdtool="RRDTool", - network="Netzwerk", - unixsock="Unix Socket", - csv="CSV" - } - - tpl.render("admin_statistics/outputplugins", {plugins=plugins}) -end - -function statistics_systemplugins() - plugins = { - exec="Exec", - email="E-Mail", - disk="Datenträger", - irq="Interrupts", - processes="Prozesse" - } - - tpl.render("admin_statistics/systemplugins", {plugins=plugins}) -end - -function statistics_networkplugins() - plugins = { - interface="Schnittstellen", - netlink="Netlink", - iptables="Firewall", - tcpconns="Verbindungen", - ping="Ping", - dns="DNS" - } - - tpl.render("admin_statistics/networkplugins", {plugins=plugins}) -end - - -function statistics_render() - local plugin = luci.dispatcher.request[3] - local images = { } - - for i, inst in ipairs( data:plugin_instances( plugin ) ) do - local graph = rrd.Graph() - for i, img in ipairs( graph:render( "OpenWrt", plugin, inst ) ) do - table.insert( images, img ) - end - end - - tpl.render("public_statistics/graph", { images=images, plugin=plugin } ) -end diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/collectd.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/collectd.lua deleted file mode 100644 index e09a11df1..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/collectd.lua +++ /dev/null @@ -1,71 +0,0 @@ ---[[ - -Luci configuration model for statistics - general collectd configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -require("luci.sys") - - -m = Map("luci_statistics", "Collector Daemon", -[[Collectd ist ein kleiner und flexibler Dienst zum Sammeln und Abfragen von Daten -aus verschieden Quellen. Zur weiteren Verarbeitung werden die Daten in RRD Datenbanken -gespeichert oder per Multicast Relaying über das Netzwerk versendet.]]) - --- general config section -s = m:section( NamedSection, "general", "luci_statistics", "Allgemeine Einstellungen" ) - --- general.basedir (BaseDir) -basedir = s:option( Value, "BaseDir", "Basisverzeichnis" ) -basedir.default = "/var/run/collectd" - --- general.include (Include) -include = s:option( Value, "Include", "Verzeichnis für Unterkonfigurationen" ) -include.default = "/etc/collectd/conf.d/*.conf" - --- general.pidfile (PIDFile) -pidfile = s:option( Value, "PIDFile", "PID-Datei für den Collector Dienst" ) -pidfile.default = "/var/run/collectd.pid" - --- general.plugindir (PluginDir) -plugindir = s:option( Value, "PluginDir", "Verzeichnis für die Collector-Plugins" ) -plugindir.default = "/usr/lib/collectd/" - --- general.typesdb (TypesDB) -typesdb = s:option( Value, "TypesDB", "Datenbank mit den Datenset-Beschreibungen" ) -typesdb.default = "/etc/collectd/types.db" - --- general.interval (Interval) -interval = s:option( Value, "Interval", "Abfrageintervall für die Datenerfassung", "Sekunden" ) -interval.default = 60 -interval.isnumber = true - --- general.readthreads (ReadThreads) -readthreads = s:option( Value, "ReadThreads", "Anzahl paralleler Prozesse für die Datenabfrage" ) -readthreads.default = 5 -readthreads.isnumber = true - --- general.hostname (Hostname) -hostname = s:option( Value, "Hostname", "Hostname zur Identifikation des Collector Dienstes (leer lassen um den Namen automatisch zu bestimmen)" ) -hostname.default = luci.sys.hostname() -hostname.optional = true - --- general.fqdnlookup (FQDNLookup) -fqdnlookup = s:option( Flag, "FQDNLookup", "Versuchen den vollen Hostnamen dieser Installation herauszufinden" ) -fqdnlookup.enabled = "true" -fqdnlookup.disabled = "false" -fqdnlookup.default = "false" -fqdnlookup.optional = true -fqdnlookup:depends( "Hostname", "" ) - - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/csv.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/csv.lua deleted file mode 100644 index e1f2c351d..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/csv.lua +++ /dev/null @@ -1,39 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd csv plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "CSV Plugin", -[[Das CSV-Plugin schreibt in regelmäßigen Abständen die gesammelten Daten als -CSV-Dateien in das angegebene Verzeichnis. Der Speicherbedarf wächst dabei -kontinuierlich!]]) - --- collectd_csv config section -s = m:section( NamedSection, "collectd_csv", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_csv.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_csv.datadir (DataDir) -datadir = s:option( Value, "DataDir", "Ablageverzeichnis für die CSV-Dateien" ) -datadir.default = "127.0.0.1" -datadir:depends( "enable", 1 ) - --- collectd_csv.storerates (StoreRates) -storerates = s:option( Flag, "StoreRates", "Werte nicht absolut, sondern als Raten speichern" ) -storerates.default = 0 -storerates:depends( "enable", 1 ) - -return m - diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/df.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/df.lua deleted file mode 100644 index 6e35afcb3..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/df.lua +++ /dev/null @@ -1,50 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd df plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "DF Plugin", -[[Das DF-Plugin sammelt Informationen über den belegten und verfügbaren Speicherplatz auf den -angegebenen Geräten, Mountpunkten oder Dateisystemtypen.]]) - --- collectd_df config section -s = m:section( NamedSection, "collectd_df", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_df.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_df.devices (Device) -devices = s:option( Value, "Devices", "Gerätedateien", "Einträge mit Leerzeichen trennen" ) -devices.default = "/dev/mtdblock/4" -devices.rmempty = true -devices:depends( "enable", 1 ) - --- collectd_df.mountpoints (MountPoint) -mountpoints = s:option( Value, "MountPoints", "Mountpunkte", "Einträge mit Leerzeichen trennen" ) -mountpoints.default = "/jffs" -mountpoints.rmempty = true -mountpoints:depends( "enable", 1 ) - --- collectd_df.fstypes (FSType) -fstypes = s:option( Value, "FSTypes", "Dateisystemtypen", "Einträge mit Leerzeichen trennen" ) -fstypes.default = "tmpfs" -fstypes.rmempty = true -fstypes:depends( "enable", 1 ) - --- collectd_df.ignoreselected (IgnoreSelected) -ignoreselected = s:option( Flag, "IgnoreSelected", "Logik umkehren und alle Datenträger überwachen die nicht auf die obigen Kriterien zutreffen" ) -ignoreselected.default = 0 -ignoreselected:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/disk.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/disk.lua deleted file mode 100644 index 587091fbd..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/disk.lua +++ /dev/null @@ -1,37 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd disk plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Disk Plugin", -[[Das Disk-Plugin sammelt Informationen über Augewählte Fesplatten.]]) - --- collectd_disk config section -s = m:section( NamedSection, "collectd_disk", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_disk.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_disk.disks (Disk) -devices = s:option( Value, "Disks", "Fesplatten oder Partitionen", "Einträge mit Leerzeichen trennen" ) -devices.default = "hda1 hdb" -devices.rmempty = true -devices:depends( "enable", 1 ) - --- collectd_disk.ignoreselected (IgnoreSelected) -ignoreselected = s:option( Flag, "IgnoreSelected", "Logik umkehren und alle Datenträger und Partitionen überwachen die nicht auf die obigen Kriterien zutreffen" ) -ignoreselected.default = 0 -ignoreselected:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/dns.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/dns.lua deleted file mode 100644 index dc7f57d68..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/dns.lua +++ /dev/null @@ -1,42 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd dns plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -require("luci.sys") - - -m = Map("luci_statistics", "DNS Plugin", -[[Das DNS-Plugin nutzt die pcap Bibliothek um DNS-Verkehr zu analysieren.]]) - --- collectd_dns config section -s = m:section( NamedSection, "collectd_dns", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_dns.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_dns.interfaces (Interface) -interfaces = s:option( ListValue, "Interface", "Folgende Schnittstelle überwachen:" ) -interfaces:depends( "enable", 1 ) -interfaces:value("any") -for k, v in pairs(luci.sys.net.devices()) do - interfaces:value(v) -end - --- collectd_dns.ignoresources (IgnoreSource) -ignoresources = s:option( Value, "IgnoreSources", "Verkehr von folgenden IP Adressen ignorieren:", "mehrere Einträge mit Leerzeichen trennen" ) -ignoresources.default = "127.0.0.1" -ignoresources:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/email.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/email.lua deleted file mode 100644 index 7b259e829..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/email.lua +++ /dev/null @@ -1,55 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd email plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "E-Mail Plugin", -[[Das E-Mail-Plugin öffnet einen Unix-Socket über welchen E-Mail Statistiken an collectd -übergeben werden können. Dieses Plugin ist primär für die Verwendung mit -Mail::SpamAssassin::Plugin::Collectd gedacht, lässt sich aber auch anderweitig einsetzen.]]) - --- collectd_email config section -s = m:section( NamedSection, "collectd_email", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_email.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_email.socketfile (SocketFile) -socketfile = s:option( Value, "SocketFile", "Pfad für den Unix-Socket" ) -socketfile.default = "/var/run/collect-email.sock" -socketfile:depends( "enable", 1 ) - --- collectd_email.socketgroup (SocketGroup) -socketgroup = s:option( Value, "SocketGroup", "Dateibesitzergruppe für den Unix-Socket ändern" ) -socketgroup.default = "nobody" -socketgroup.rmempty = true -socketgroup.optional = true -socketgroup:depends( "enable", 1 ) - --- collectd_email.socketperms (SocketPerms) -socketperms = s:option( Value, "SocketPerms", "Dateiberechtigungen für den Unix-Socket ändern" ) -socketperms.default = "0770" -socketperms.rmempty = true -socketperms.optional = true -socketperms:depends( "enable", 1 ) - --- collectd_email.maxconns (MaxConns) -maxconns = s:option( Value, "MaxConns", "Maximale Anzahl paralleler Verbindungen", "Werte von 1 bis 16384" ) -maxconns.default = 5 -maxconns.isinteger = true -maxconns.rmempty = true -maxconns.optional = true -maxconns:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/exec.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/exec.lua deleted file mode 100644 index d1fe0f0db..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/exec.lua +++ /dev/null @@ -1,77 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd exec plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Exec Plugin", -[[Das Exec-Plugin ermöglicht das Ausführen von externen Programmen um Werte einzulesen -oder Aktionen beim Eintreten bestimmter Ereignisse anzustoßen.]]) - --- collectd_exec config section -s = m:section( NamedSection, "collectd_exec", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_exec.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - - --- collectd_exec_input config section (Exec directives) -exec = m:section( TypedSection, "collectd_exec_input", "Befehl zum Einlesen von Daten hinzufügen", -[[Hier können externe Kommandos definiert werden welche durch collectd gestartet werden um bestimmte -Daten zu sammeln. Die Werte werden dabei von der Standardausgabe des Programmes gelesen.]]) -exec.addremove = true -exec.anonymous = true - --- collectd_exec_input.cmdline -exec_cmdline = exec:option( Value, "cmdline", "Kommandozeile" ) -exec_cmdline.default = "/usr/bin/stat-dhcpusers" - --- collectd_exec_input.cmdline -exec_cmduser = exec:option( Value, "cmduser", "Als anderer Benutzer ausführen" ) -exec_cmduser.default = "nobody" -exec_cmduser.rmempty = true -exec_cmduser.optional = true - --- collectd_exec_input.cmdline -exec_cmdgroup = exec:option( Value, "cmdgroup", "Als andere Gruppe ausführen" ) -exec_cmdgroup.default = "nogroup" -exec_cmdgroup.rmempty = true -exec_cmdgroup.optional = true - - --- collectd_exec_notify config section (NotifyExec directives) -notify = m:section( TypedSection, "collectd_exec_notify", "Befehl zum Ausgeben von Daten hinzufügen", -[[Hier können externe Kommandos definiert werden welche zur Ausführung kommen sobald bestimmte -Ereignise eintreten. Die Daten werden dabei an die Standardeingabe des aufgerufenen Programmes gesendet. -Siehe dazu auch die Sektion "Limits".]]) -notify.addremove = true -notify.anonymous = true - --- collectd_notify_input.cmdline -notify_cmdline = notify:option( Value, "cmdline", "Kommandozeile" ) -notify_cmdline.default = "/usr/bin/stat-dhcpusers" - --- collectd_notify_input.cmdline -notify_cmduser = notify:option( Value, "cmduser", "Als anderer Benutzer ausführen" ) -notify_cmduser.default = "nobody" -notify_cmduser.rmempty = true -notify_cmduser.optional = true - --- collectd_notify_input.cmdline -notify_cmdgroup = notify:option( Value, "cmdgroup", "Als andere Gruppe ausführen" ) -notify_cmdgroup.default = "nogroup" -notify_cmdgroup.rmempty = true -notify_cmdgroup.optional = true - - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/interface.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/interface.lua deleted file mode 100644 index 3cd71a15d..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/interface.lua +++ /dev/null @@ -1,42 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd interface plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -require("luci.sys") - - -m = Map("luci_statistics", "Interface Plugin", -[[Das Interface-Plugin sammelt Informationen zum Netzwerkverkehr auf den einzelnen Schnittstellen.]]) - --- collectd_interface config section -s = m:section( NamedSection, "collectd_interface", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_interface.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_interface.interfaces (Interface) -interfaces = s:option( MultiValue, "Interfaces", "Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) -interfaces.widget = "select" -interfaces:depends( "enable", 1 ) -for k, v in pairs(luci.sys.net.devices()) do - interfaces:value(v) -end - --- collectd_interface.ignoreselected (IgnoreSelected) -ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Schnittstellen außer ausgewählte überwachen" ) -ignoreselected.default = 0 -ignoreselected:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/iptables.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/iptables.lua deleted file mode 100644 index 4b6d9dbf4..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/iptables.lua +++ /dev/null @@ -1,121 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd iptables plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -require("luci.sys.iptparser") - -ip = luci.sys.iptparser.IptParser() -chains = { } -targets = { } - -for i, rule in ipairs( ip:find() ) do - chains[rule.chain] = true - targets[rule.target] = true -end - - -m = Map("luci_statistics", "Iptables Plugin", -[[Das Iptables-Plugin ermöglicht die Überwachung bestimmter Firewallregeln um -Werte wie die Anzahl der verarbeiteten Pakete oder die insgesamt erfasste Datenmenge -zu speichern.]]) - --- collectd_iptables config section -s = m:section( NamedSection, "collectd_iptables", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_iptables.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - - --- collectd_iptables_match config section (Chain directives) -rule = m:section( TypedSection, "collectd_iptables_match", "Regel hinzufügen", -[[Hier werden die Kriterien festgelegt, nach welchen die Firewall-Regeln zur Überwachung -ausgewählt werden.]]) -rule.addremove = true -rule.anonymous = true - - --- collectd_iptables_match.name -rule_table = rule:option( Value, "name", "Name der Regel", "wird im Diagram verwendet" ) - --- collectd_iptables_match.table -rule_table = rule:option( ListValue, "table", "Firewall-Tabelle" ) -rule_table.default = "filter" -rule_table.rmempty = true -rule_table.optional = true -rule_table:value("") -rule_table:value("filter") -rule_table:value("nat") -rule_table:value("mangle") - - --- collectd_iptables_match.chain -rule_chain = rule:option( ListValue, "chain", "Firewall-Kette (Chain)" ) -rule_chain.rmempty = true -rule_chain.optional = true -rule_chain:value("") - -for chain, void in pairs( chains ) do - rule_chain:value( chain ) -end - - --- collectd_iptables_match.target -rule_target = rule:option( ListValue, "target", "Firewall-Aktion (Target)" ) -rule_target.rmempty = true -rule_target.optional = true -rule_target:value("") - -for target, void in pairs( targets ) do - rule_target:value( target ) -end - - --- collectd_iptables_match.protocol -rule_protocol = rule:option( ListValue, "protocol", "Netzwerkprotokoll" ) -rule_protocol.rmempty = true -rule_protocol.optional = true -rule_protocol:value("") -rule_protocol:value("tcp") -rule_protocol:value("udp") -rule_protocol:value("icmp") - --- collectd_iptables_match.source -rule_source = rule:option( Value, "source", "Quell-IP-Bereich", "Bereich in CIDR Notation" ) -rule_source.default = "0.0.0.0/0" -rule_source.rmempty = true -rule_source.optional = true - --- collectd_iptables_match.destination -rule_destination = rule:option( Value, "destination", "Ziel-IP-Bereich", "Bereich in CIDR Notation" ) -rule_destination.default = "0.0.0.0/0" -rule_destination.rmempty = true -rule_destination.optional = true - --- collectd_iptables_match.inputif -rule_inputif = rule:option( Value, "inputif", "eingehende Schnittstelle", "z.B. eth0.0" ) -rule_inputif.rmempty = true -rule_inputif.optional = true - --- collectd_iptables_match.outputif -rule_outputif = rule:option( Value, "outputif", "ausgehende Schnittstelle", "z.B. eth0.1" ) -rule_outputif.rmempty = true -rule_outputif.optional = true - --- collectd_iptables_match.options -rule_options = rule:option( Value, "options", "Optionen", "z.B. reject-with tcp-reset" ) -rule_options.rmempty = true -rule_options.optional = true - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/irq.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/irq.lua deleted file mode 100644 index 2d15e5232..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/irq.lua +++ /dev/null @@ -1,39 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd irq plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "IRQ Plugin", -[[Das IRQ-Plugin sammelt Informationen zur Auslastung einzelner Interrupts. -Werden keine Interrupts angegeben, überwacht das Plugin alle vorhanden IRQs im System. -]]) - --- collectd_irq config section -s = m:section( NamedSection, "collectd_irq", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_irq.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_irq.irqs (Irq) -irqs = s:option( Value, "Irqs", "Überwachte Interrupts", "mehrere mit Leerzeichen trennen" ) -irqs.optional = true -irqs:depends( "enable", 1 ) - --- collectd_irq.ignoreselected (IgnoreSelected) -ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Interrupts außer ausgewählte überwachen" ) -ignoreselected.default = 0 -ignoreselected.optional = "true" -ignoreselected:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/netlink.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/netlink.lua deleted file mode 100644 index a27def8eb..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/netlink.lua +++ /dev/null @@ -1,84 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd netlink plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -require("luci.sys") - - -m = Map("luci_statistics", "Interface Plugin", -[[Das Netlink-Plugin sammelt erweiterte Informationen wie Qdisc-, Class- und Filter-Werten auf einzelnen Schnittstellen.]]) - --- collectd_netlink config section -s = m:section( NamedSection, "collectd_netlink", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_netlink.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_netlink.interfaces (Interface) -interfaces = s:option( MultiValue, "Interfaces", "einfach Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) -interfaces.widget = "select" -interfaces.optional = true -interfaces:depends( "enable", 1 ) -interfaces:value("") -for i, v in ipairs(luci.sys.net.devices()) do - interfaces:value(v) -end - --- collectd_netlink.verboseinterfaces (VerboseInterface) -verboseinterfaces = s:option( MultiValue, "VerboseInterfaces", "detailliert Überwachte Schnittstellen", "mehrere Einträge mit Strg selektieren" ) -verboseinterfaces.widget = "select" -verboseinterfaces.optional = true -verboseinterfaces:depends( "enable", 1 ) -verboseinterfaces:value("") -for i, v in ipairs(luci.sys.net.devices()) do - verboseinterfaces:value(v) -end - --- collectd_netlink.qdiscs (QDisc) -qdiscs = s:option( MultiValue, "QDiscs", "Queue Discipline auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) -qdiscs.widget = "select" -qdiscs.optional = true -qdiscs:depends( "enable", 1 ) -qdiscs:value("") -for i, v in ipairs(luci.sys.net.devices()) do - qdiscs:value(v) -end - --- collectd_netlink.classes (Class) -classs = s:option( MultiValue, "Classes", "Shapingklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) -classs.widget = "select" -classs.optional = true -classs:depends( "enable", 1 ) -classs:value("") -for i, v in ipairs(luci.sys.net.devices()) do - classs:value(v) -end - --- collectd_netlink.filters (Filter) -filters = s:option( MultiValue, "Filters", "Filterklassen auf Schnittstellen Überwachen", "mehrere Einträge mit Strg selektieren" ) -filters.widget = "select" -filters.optional = true -filters:depends( "enable", 1 ) -filters:value("") -for i, v in ipairs(luci.sys.net.devices()) do - filters:value(v) -end - --- collectd_netlink.ignoreselected (IgnoreSelected) -ignoreselected = s:option( Flag, "IgnoreSelected", "Alle Schnittstellen außer ausgewählte überwachen" ) -ignoreselected.default = 0 -ignoreselected:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/network.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/network.lua deleted file mode 100644 index ab3c6303c..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/network.lua +++ /dev/null @@ -1,84 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd network plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - - -m = Map("luci_statistics", "Network Plugin", -[[Das Network-Plugin ermöglicht den netzwerkgestützen Austausch von Statistikdaten.]]) - --- collectd_network config section -s = m:section( NamedSection, "collectd_network", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_network.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - - --- collectd_network_listen config section (Listen) -listen = m:section( TypedSection, "collectd_network_listen", "Schnittstellen für eingehende Verbindungen", -[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd auf eingehende Verbindungen wartet.]]) -listen.addremove = true -listen.anonymous = true - - --- collectd_network_listen.host -listen_host = listen:option( Value, "host", "Listen-Host", "Host-, IP- oder IPv6-Adresse" ) -listen_host.default = "0.0.0.0" - --- collectd_network_listen.port -listen_port = listen:option( Value, "port", "Listen-Port", "Partnummer 0 - 65535" ) -listen_port.default = 25826 -listen_port.isinteger = true -listen_port.optional = true - - --- collectd_network_server config section (Server) -server = m:section( TypedSection, "collectd_network_server", "Schnittstellen für ausgehende Verbindungen", -[[Legt fest auf welchen Schnittstellen bzw. IP-Adressen collectd als Server agiert.]]) -server.addremove = true -server.anonymous = true - - --- collectd_network_server.host -server_host = server:option( Value, "host", "Server-Host", "Host-, IP- oder IPv6-Adresse" ) -server_host.default = "0.0.0.0" - --- collectd_network_server.port -server_port = server:option( Value, "port", "Server-Port", "Partnummer 0 - 65535" ) -server_port.default = 25826 -server_port.isinteger = true -server_port.optional = true - --- collectd_network.timetolive (TimeToLive) -ttl = s:option( Value, "TimeToLive", "Time-to-Live für die Pakete", "Werte 0 bis 255" ) -ttl.default = 128 -ttl.isinteger = true -ttl.optional = true -ttl:depends( "enable", 1 ) - --- collectd_network.forward (Forward) -forward = s:option( Flag, "Forward", "Weiterleitung zwischen verschiedenen Listen- und Server-Adressen" ) -forward.default = 0 -forward.optional = true -forward:depends( "enable", 1 ) - --- collectd_network.forward (CacheFlush) -forward = s:option( Value, "CacheFlush", "Löschintervall für temporäre Daten", "in Sekunden" ) -forward.default = 86400 -forward.isinteger = true -forward.optional = true -forward:depends( "enable", 1 ) - - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/ping.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/ping.lua deleted file mode 100644 index 334a0300d..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/ping.lua +++ /dev/null @@ -1,38 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd ping plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Ping Plugin", -[[Das Ping-Plugin veranlasst periodische ICMP-Requests an die angegebenen Adressen und zeichnet -Parameter wie Verfügbarkeit und Antwortzeiten auf.]]) - --- collectd_ping config section -s = m:section( NamedSection, "collectd_ping", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_ping.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_ping.hosts (Host) -hosts = s:option( Value, "Hosts", "Zieladressen", "Einträge durch Leerzeichen trennen" ) -hosts.default = "127.0.0.1" -hosts:depends( "enable", 1 ) - --- collectd_ping.ttl (TTL) -ttl = s:option( Value, "TTL", "Time-to-Live für die ICMP-Pakete (Werte 0 bis 255)" ) -ttl.isinteger = true -ttl.default = 128 -ttl:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/processes.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/processes.lua deleted file mode 100644 index 354cecaf1..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/processes.lua +++ /dev/null @@ -1,31 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd processes plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Processes Plugin", -[[Das Processes-Plugin sammelt Informationen über ausgewählte Prozesse auf diesem Gerät.]]) - --- collectd_processes config section -s = m:section( NamedSection, "collectd_processes", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_processes.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_processes.processes (Process) -processes = s:option( Value, "Processes", "Überwachte Prozesse", "mehrere mit Leerzeichen trennen" ) -processes.default = "olsrd bmxd httpd dnsmasq dropbear tinc" -processes:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/rrdtool.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/rrdtool.lua deleted file mode 100644 index 89adf52a7..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/rrdtool.lua +++ /dev/null @@ -1,99 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd rrdtool plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "RRDTool Plugin", -[[Das RRDTool-Plugin schreibt die gesammelten Werte in sogenannte RRD Datenbanken, welche die -Grundlage für die Statistik-Diagramme bilden.

-Die Einstellungen auf dieser Seite sollten nur in Ausnahmefällen geändert werden, -falsche Einstellungen führen zu einem sehr hohem Platzverbrauch im Temp-Verzeichnis und das -Gerät kann nur noch im Failsafe-Modus repariert werden!]]) - --- collectd_rrdtool config section -s = m:section( NamedSection, "collectd_rrdtool", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_rrdtool.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 1 - --- collectd_rrdtool.datadir (DataDir) -datadir = s:option( Value, "DataDir", "Speicherort für die RRD Datenbanken" ) -datadir.default = "/tmp" -datadir.rmempty = true -datadir.optional = true -datadir:depends( "enable", 1 ) - --- collectd_rrdtool.stepsize (StepSize) -stepsize = s:option( Value, "StepSize", "Schritt-Interval", "in Sekunden" ) -stepsize.default = 30 -stepsize.isinteger = true -stepsize.rmempty = true -stepsize.optional = true -stepsize:depends( "enable", 1 ) - --- collectd_rrdtool.heartbeat (HeartBeat) -heartbeat = s:option( Value, "HeartBeat", "Heart-Beat-Interval", "in Sekunden" ) -heartbeat.default = 60 -heartbeat.isinteger = true -heartbeat.rmempty = true -heartbeat.optional = true -heartbeat:depends( "enable", 1 ) - --- collectd_rrdtool.rrasingle (RRASingle) -rrasingle = s:option( Flag, "RRASingle", 'Jeweils nur ein RRA anlegen', "reduziert die Größe der RRDs" ) -rrasingle.default = true -rrasingle.rmempty = true -rrasingle.optional = true -rrasingle:depends( "enable", 1 ) - --- collectd_rrdtool.rratimespans (RRATimespan) -rratimespans = s:option( Value, "RRATimespans", "Gespeicherte Zeitspannen", "in Sekunden; mehrere mit Leerzeichen trennen" ) -rratimespans.default = "600 86400 604800 2678400 31622400" -rratimespans.rmempty = true -rratimespans.optional = true -rratimespans:depends( "enable", 1 ) - --- collectd_rrdtool.rrarows (RRARows) -rrarows = s:option( Value, "RRARows", "Anzahl der Datenpunkte pro Zeitspanne" ) -rrarows.isinteger = true -rrarows.default = 100 -rrarows.rmempty = true -rrarows.optional = true -rrarows:depends( "enable", 1 ) - --- collectd_rrdtool.xff (XFF) -xff = s:option( Value, "XFF", "RRD XFiles Faktor" ) -xff.default = 0.1 -xff.isnumber = true -xff.rmempty = true -xff.optional = true -xff:depends( "enable", 1 ) - --- collectd_rrdtool.cachetimeout (CacheTimeout) -cachetimeout = s:option( Value, "CacheTimeout", "Daten für Zeitspanne cachen", "in Sekunden" ) -cachetimeout.isinteger = true -cachetimeout.default = 100 -cachetimeout.rmempty = true -cachetimeout.optional = true -cachetimeout:depends( "enable", 1 ) - --- collectd_rrdtool.cacheflush (CacheFlush) -cacheflush = s:option( Value, "CacheFlush", "Cache nach Zeitspanne leeren", "in Sekunden" ) -cacheflush.isinteger = true -cacheflush.default = 100 -cacheflush.rmempty = true -cacheflush.optional = true -cacheflush:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/tcpconns.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/tcpconns.lua deleted file mode 100644 index 079befac5..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/tcpconns.lua +++ /dev/null @@ -1,41 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd tcpconns plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Tcpconns Plugin", -[[Das Tcpconns-Plugin zählt TCP-Verbindungen auf einzelnen Ports.]]) - --- collectd_tcpconns config section -s = m:section( NamedSection, "collectd_tcpconns", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_tcpconns.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_tcpconns.listeningports (ListeningPorts) -listeningports = s:option( Flag, "ListeningPorts", "Alle von lokalen Diensten genutzen Ports überwachen" ) -listeningports.default = 1 -listeningports:depends( "enable", 1 ) - --- collectd_tcpconns.localports (LocalPort) -localports = s:option( Value, "LocalPorts", "Lokale Ports", "mit Leerzeichen trennen" ) -localports.optional = true -localports:depends( "enable", 1 ) - --- collectd_tcpconns.remoteports (RemotePort) -remoteports = s:option( Value, "RemotePorts", "Entfernte Ports", "mit Leerzeichen trennen" ) -remoteports.optional = true -remoteports:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/model/cbi/luci_statistics/unixsock.lua b/applications/luci-statistics/src/model/cbi/luci_statistics/unixsock.lua deleted file mode 100644 index dcedd381b..000000000 --- a/applications/luci-statistics/src/model/cbi/luci_statistics/unixsock.lua +++ /dev/null @@ -1,46 +0,0 @@ ---[[ - -Luci configuration model for statistics - collectd unixsock plugin configuration -(c) 2008 Freifunk Leipzig / 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 - -$Id$ - -]]-- - -m = Map("luci_statistics", "Unixsock Plugin", -[[Das Unixsock-Plugin öffnet einen Socket über welchen die gesammelten Werte des -laufenden collectd Prozesses abgefragt werden können.]]) - --- collectd_unixsock config section -s = m:section( NamedSection, "collectd_unixsock", "luci_statistics", "Pluginkonfiguration" ) - --- collectd_unixsock.enable -enable = s:option( Flag, "enable", "Plugin aktivieren" ) -enable.default = 0 - --- collectd_unixsock.socketfile (SocketFile) -socketfile = s:option( Value, "SocketFile", "Pfad für den Unix-Socket" ) -socketfile.default = "/var/run/collect-query.socket" -socketfile:depends( "enable", 1 ) - --- collectd_unixsock.socketgroup (SocketGroup) -socketgroup = s:option( Value, "SocketGroup", "Dateibesitzergruppe für den Unix-Socket ändern" ) -socketgroup.default = "nobody" -socketgroup.rmempty = true -socketgroup.optional = true -socketgroup:depends( "enable", 1 ) - --- collectd_unixsock.socketperms (SocketPerms) -socketperms = s:option( Value, "SocketPerms", "Dateiberechtigungen für den Unix-Socket ändern" ) -socketperms.default = "0770" -socketperms.rmempty = true -socketperms.optional = true -socketperms:depends( "enable", 1 ) - -return m diff --git a/applications/luci-statistics/src/statistics/datatree.lua b/applications/luci-statistics/src/statistics/datatree.lua deleted file mode 100644 index 957b230a9..000000000 --- a/applications/luci-statistics/src/statistics/datatree.lua +++ /dev/null @@ -1,134 +0,0 @@ -module("luci.statistics.datatree", package.seeall) - -local util = require("luci.util") -local sys = require("luci.sys") -local fs = require("luci.fs") -local uci = require("luci.model.uci").Session() -local sections, names = uci:sections( "luci_statistics" ) - - -Instance = util.class() - -function Instance.__init__( self, host ) - self._host = host or sections.collectd.Hostname or sys.hostname() - self._libdir = sections.collectd.PluginDir or "/usr/lib/collectd" - self._rrddir = sections.collectd_rrdtool.DataDir or "/tmp" - - self._libdir = self._libdir:gsub("/$","") - self._rrddir = self._rrddir:gsub("/$","") - self._plugins = { } - - self:_scan() -end - -function Instance._mkpath( self, plugin, pinstance ) - local dir = self._rrddir .. "/" .. self._host - - if type(plugin) == "string" and plugin:len() > 0 then - dir = dir .. "/" .. plugin - - if type(pinstance) == "string" and pinstance:len() > 0 then - dir = dir .. "-" .. pinstance - end - end - - return dir -end - -function Instance._notzero( self, table ) - for k in pairs(table) do - return true - end - - return false -end - -function Instance._scan( self ) - for i, plugin in ipairs( fs.dir( self._libdir ) ) do - if plugin:match("%w+.so") then - self._plugins[ plugin:gsub(".so", "") ] = { } - end - end - - for plugin, instances in pairs( self._plugins ) do - for i, dir in ipairs( fs.dir( self:_mkpath() ) ) do - if dir:find( plugin .. "%-" ) or dir == plugin then - local instance = "" - - if dir ~= plugin then - instance = dir:gsub( plugin .. "%-", "", 1 ) - end - - instances[instance] = { } - end - end - - for instance, data_instances in pairs( instances ) do - for i, file in ipairs( fs.dir( self:_mkpath( plugin, instance ) ) ) do - if file:find("%.rrd") then - file = file:gsub("%.rrd","") - - local data_type - local data_instance - - if file:find("%-") then - data_type = file:gsub( "%-.+","" ) - data_instance = file:gsub( "[^%-]-%-", "", 1 ) - else - data_type = file - data_instance = "" - end - - if not data_instances[data_type] then - data_instances[data_type] = { data_instance } - else - table.insert( data_instances[data_type], data_instance ) - end - end - end - end - end -end - - -function Instance.plugins( self ) - local rv = { } - - for plugin, val in pairs( self._plugins ) do - if self:_notzero( val ) then - table.insert( rv, plugin ) - end - end - - return rv -end - -function Instance.plugin_instances( self, plugin ) - local rv = { } - - for instance, val in pairs( self._plugins[plugin] ) do - table.insert( rv, instance ) - end - - return rv -end - -function Instance.data_types( self, plugin, instance ) - local rv = { } - - for type, val in pairs( self._plugins[plugin][instance] ) do - table.insert( rv, type ) - end - - return rv -end - -function Instance.data_instances( self, plugin, instance, type ) - local rv = { } - - for i, instance in ipairs( self._plugins[plugin][instance][type] ) do - table.insert( rv, instance ) - end - - return rv -end diff --git a/applications/luci-statistics/src/statistics/rrdtool.lua b/applications/luci-statistics/src/statistics/rrdtool.lua deleted file mode 100644 index b399866a8..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool.lua +++ /dev/null @@ -1,264 +0,0 @@ -module("luci.statistics.rrdtool", package.seeall) - -require("luci.statistics.datatree") -require("luci.statistics.rrdtool.colors") -require("luci.statistics.rrdtool.definitions") -require("luci.util") -require("luci.bits") -require("luci.fs") - - -Graph = luci.util.class() - -function Graph.__init__( self, timespan, opts ) - - opts = opts or { } - opts.width = opts.width or "400" - - self.colors = luci.statistics.rrdtool.colors.Instance() - self.defs = luci.statistics.rrdtool.definitions.Instance() - self.tree = luci.statistics.datatree.Instance() - - -- rrdtool defalt args - self.args = { - "-a", "PNG", - "-s", "NOW-" .. ( timespan or 900 ), - "-w", opts.width - } -end - -function Graph.mktitle( self, host, plugin, plugin_instance, dtype, dtype_instance ) - local t = host .. "/" .. plugin - if type(plugin_instance) == "string" and plugin_instance:len() > 0 then - t = t .. "-" .. plugin_instance - end - t = t .. "/" .. dtype - if type(dtype_instance) == "string" and dtype_instance:len() > 0 then - t = t .. "-" .. dtype_instance - end - return t -end - -function Graph.mkrrdpath( self, ... ) - return string.format( "/tmp/%s.rrd", self:mktitle( ... ) ) -end - -function Graph.mkpngpath( self, ... ) - return string.format( "/tmp/rrdimg/%s.png", self:mktitle( ... ) ) -end - -function Graph._push( self, elem ) - - if type(elem) == "string" then - table.insert( self.args, elem ) - else - for i, item in ipairs(elem) do - table.insert( self.args, item ) - end - end - - return( self.args ) -end - -function Graph._clearargs( self ) - for i = #self.args, 7, -1 do - table.remove( self.args, i ) - end -end - -function Graph._forcelol( self, list ) - if type(list[1]) ~= "table" then - return( { list } ) - end - return( list ) -end - -function Graph._rrdtool( self, png, rrd ) - - -- prepare directory - local dir = png:gsub("/[^/]+$","") - luci.fs.mkdir( dir, true ) - - -- construct commandline - local cmdline = "rrdtool graph " .. png - - for i, opt in ipairs(self.args) do - - opt = opt .. "" -- force string - - if rrd then - opt = opt:gsub( "{file}", rrd ) - end - - if opt:match("[^%w]") then - cmdline = cmdline .. " '" .. opt .. "'" - else - cmdline = cmdline .. " " .. opt - end - end - - -- execute rrdtool - local rrdtool = io.popen( cmdline ) - rrdtool:close() -end - -function Graph._generic( self, opts ) - - local images = { } - - -- remember images - table.insert( images, opts.image ) - - -- insert provided addition rrd options - self:_push( { "-t", opts.title or "Unknown title" } ) - self:_push( opts.rrd ) - - -- construct an array of safe instance names - local inst_names = { } - for i, source in ipairs(opts.sources) do - inst_names[i] = i .. source.name:gsub("[^A-Za-z0-9%-_]","_") - end - - -- create DEF statements for each instance, find longest instance name - local longest_name = 0 - for i, source in ipairs(opts.sources) do - if source.name:len() > longest_name then - longest_name = source.name:len() - end - - local ds = source.ds or "value" - - self:_push( "DEF:" .. inst_names[i] .. "_min=" ..source.rrd .. ":" .. ds .. ":MIN" ) - self:_push( "DEF:" .. inst_names[i] .. "_avg=" ..source.rrd .. ":" .. ds .. ":AVERAGE" ) - self:_push( "DEF:" .. inst_names[i] .. "_max=" ..source.rrd .. ":" .. ds .. ":MAX" ) - self:_push( "CDEF:" .. inst_names[i] .. "_nnl=" .. inst_names[i] .. "_avg,UN,0," .. inst_names[i] .. "_avg,IF" ) - end - - -- create CDEF statement for last instance name - self:_push( "CDEF:" .. inst_names[#inst_names] .. "_stk=" .. inst_names[#inst_names] .. "_nnl" ) - - -- create CDEF statements for each instance - for i, source in ipairs(inst_names) do - if i > 1 then - self:_push( - "CDEF:" .. - inst_names[1 + #inst_names - i] .. "_stk=" .. - inst_names[1 + #inst_names - i] .. "_nnl," .. - inst_names[2 + #inst_names - i] .. "_stk,+" - ) - end - end - - -- create LINE and GPRINT statements for each instance - for i, source in ipairs(opts.sources) do - - local legend = string.format( - "%-" .. longest_name .. "s", - source.name - ) - - local numfmt = opts.number_format or "%6.1lf" - - local line_color - local area_color - - -- find color: try source, then opts.colors; fall back to random color - if type(source.color) == "string" then - line_color = source.color - area_color = self.colors:from_string( line_color ) - elseif type(opts.colors[source.name:gsub("[^%w]","_")]) == "string" then - line_color = opts.colors[source.name:gsub("[^%w]","_")] - area_color = self.colors:from_string( line_color ) - else - area_color = self.colors:random() - line_color = self.colors:to_string( area_color ) - end - - -- derive area background color from line color - area_color = self.colors:to_string( self.colors:faded( area_color ) ) - - - self:_push( "AREA:" .. inst_names[i] .. "_stk#" .. area_color ) - self:_push( "LINE1:" .. inst_names[i] .. "_stk#" .. line_color .. ":" .. legend ) - self:_push( "GPRINT:" .. inst_names[i] .. "_min:MIN:" .. numfmt .. " Min" ) - self:_push( "GPRINT:" .. inst_names[i] .. "_avg:AVERAGE:" .. numfmt .. " Avg" ) - self:_push( "GPRINT:" .. inst_names[i] .. "_max:MAX:" .. numfmt .. " Max" ) - self:_push( "GPRINT:" .. inst_names[i] .. "_avg:LAST:" .. numfmt .. " Last\\l" ) - end - - return images -end - -function Graph.render( self, host, plugin, plugin_instance ) - - dtype_instances = dtype_instances or { "" } - local pngs = { } - - -- check for a whole graph handler - local plugin_def = "luci.statistics.rrdtool.definitions." .. plugin - local stat, def = pcall( require, plugin_def ) - - if stat and def and type(def.rrdargs) == "function" then - for i, opts in ipairs( self:_forcelol( def.rrdargs( self, host, plugin, plugin_instance, dtype ) ) ) do - for i, png in ipairs( self:_generic( opts ) ) do - table.insert( pngs, png ) - - -- exec - self:_rrdtool( png ) - - -- clear args - self:_clearargs() - end - end - else - - -- no graph handler, iterate over data types - for i, dtype in ipairs( self.tree:data_types( plugin, plugin_instance ) ) do - - -- check for data type handler - local dtype_def = plugin_def .. "." .. dtype - local stat, def = pcall( require, dtype_def ) - - if stat and def and type(def.rrdargs) == "function" then - for i, opts in ipairs( self:_forcelol( def.rrdargs( self, host, plugin, plugin_instance, dtype ) ) ) do - for i, png in ipairs( self:_generic( opts ) ) do - table.insert( pngs, png ) - - -- exec - self:_rrdtool( png ) - - -- clear args - self:_clearargs() - end - end - else - - -- no data type handler, fall back to builtin definition - if type(self.defs.definitions[dtype]) == "table" then - - -- iterate over data type instances - for i, inst in ipairs( self.tree:data_instances( plugin, plugin_instance, dtype ) ) do - - local title = self:mktitle( host, plugin, plugin_instance, dtype, inst ) - local png = self:mkpngpath( host, plugin, plugin_instance, dtype, inst ) - local rrd = self:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - - self:_push( { "-t", title } ) - self:_push( self.defs.definitions[dtype] ) - - table.insert( pngs, png ) - - -- exec - self:_rrdtool( png, rrd ) - - -- clear args - self:_clearargs() - end - end - end - end - end - - return pngs -end - diff --git a/applications/luci-statistics/src/statistics/rrdtool/colors.lua b/applications/luci-statistics/src/statistics/rrdtool/colors.lua deleted file mode 100644 index cdd6f7105..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/colors.lua +++ /dev/null @@ -1,59 +0,0 @@ -module("luci.statistics.rrdtool.colors", package.seeall) - -require("luci.util") -require("luci.bits") - - -Instance = luci.util.class() - -function Instance.from_string( self, s ) - return { - luci.bits.Hex2Dec(s:sub(1,2)), - luci.bits.Hex2Dec(s:sub(3,4)), - luci.bits.Hex2Dec(s:sub(5,6)) - } -end - -function Instance.to_string( self, c ) - return string.format( - "%02x%02x%02x", - math.floor(c[1]), - math.floor(c[2]), - math.floor(c[3]) - ) -end - -function Instance.random( self ) - local r = math.random(255) - local g = math.random(255) - local min = 0 - local max = 255 - - if ( r + g ) < 255 then - min = 255 - r - g - else - max = 511 - r - g - end - - local b = min + math.floor( math.random() * ( max - min ) ) - - return { r, g, b } -end - -function Instance.faded( self, fg, opts ) - opts = opts or {} - opts.background = opts.background or { 255, 255, 255 } - opts.alpha = opts.alpha or 0.25 - - if type(opts.background) == "string" then - opts.background = _string_to_color(opts.background) - end - - local bg = opts.background - - return { - ( opts.alpha * fg[1] ) + ( ( 1.0 - opts.alpha ) * bg[1] ), - ( opts.alpha * fg[2] ) + ( ( 1.0 - opts.alpha ) * bg[2] ), - ( opts.alpha * fg[3] ) + ( ( 1.0 - opts.alpha ) * bg[3] ) - } -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions.lua deleted file mode 100644 index add69e4b6..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions.lua +++ /dev/null @@ -1,3177 +0,0 @@ -module("luci.statistics.rrdtool.definitions", package.seeall) - -require("luci.util") -require("luci.fs") - - -Instance = luci.util.class() - -function Instance.__init__( self, ... ) - - -- used color palette - self.palette = { - Canvas = "FFFFFF", - FullRed = "FF0000", - FullGreen = "00E000", - FullBlue = "0000FF", - FullYellow = "F0A000", - FullCyan = "00A0FF", - FullMagenta = "A000FF", - HalfRed = "F7B7B7", - HalfGreen = "B7EFB7", - HalfBlue = "B7B7F7", - HalfYellow = "F3DFB7", - HalfCyan = "B7DFF7", - HalfMagenta = "DFB7F7", - HalfBlueGreen = "89B3C9" - } - - -- plotting arguments for each defined datasource - self.definitions = { - apache_bytes = { - "DEF:min_raw={file}:count:MIN", - "DEF:avg_raw={file}:count:AVERAGE", - "DEF:max_raw={file}:count:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "CDEF:mytime=avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bit/s", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - apache_requests = { - "DEF:min={file}:count:MIN", - "DEF:avg={file}:count:AVERAGE", - "DEF:max={file}:count:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Requests/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - apache_scoreboard = { - "DEF:min={file}:count:MIN", - "DEF:avg={file}:count:AVERAGE", - "DEF:max={file}:count:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - bitrate = { - "-v", "Bits/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Average,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - charge = { - "-v", "Ah", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Charge", - "GPRINT:min:MIN:%5.1lf%sAh Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,", - "GPRINT:max:MAX:%5.1lf%sAh Max,", - "GPRINT:avg:LAST:%5.1lf%sAh Last\\l" - }, - - __cpu = { - "-v", "CPU load", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", - "GPRINT:min:MIN:%6.2lf%% Min,", - "GPRINT:avg:AVERAGE:%6.2lf%% Avg,", - "GPRINT:max:MAX:%6.2lf%% Max,", - "GPRINT:avg:LAST:%6.2lf%% Last\\l" - }, - - current = { - "-v", "Ampere", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Current", - "GPRINT:min:MIN:%5.1lf%sA Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sA Avg,", - "GPRINT:max:MAX:%5.1lf%sA Max,", - "GPRINT:avg:LAST:%5.1lf%sA Last\\l" - }, - - df = { - "-v", "Percent", "-l", "0", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:free_min={file}:free:MIN", - "DEF:free_max={file}:free:MAX", - "DEF:used_avg={file}:used:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:used_max={file}:used:MAX", - "CDEF:total=free_avg,used_avg,+", - "CDEF:free_pct=100,free_avg,*,total,/", - "CDEF:used_pct=100,used_avg,*,total,/", - "CDEF:free_acc=free_pct,used_pct,+", - "CDEF:used_acc=used_pct", - "AREA:free_acc#" .. self.palette.HalfGreen, - "AREA:used_acc#" .. self.palette.HalfRed, - "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free", - "GPRINT:free_min:MIN:%5.1lf%sB Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,", - "GPRINT:free_max:MAX:%5.1lf%sB Max,", - "GPRINT:free_avg:LAST:%5.1lf%sB Last\\l", - "LINE1:used_acc#" .. self.palette.FullRed .. ":Used", - "GPRINT:used_min:MIN:%5.1lf%sB Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,", - "GPRINT:used_max:MAX:%5.1lf%sB Max,", - "GPRINT:used_avg:LAST:%5.1lf%sB Last\\l" - }, - - disk = { - "DEF:rtime_avg={file}:rtime:AVERAGE", - "DEF:rtime_min={file}:rtime:MIN", - "DEF:rtime_max={file}:rtime:MAX", - "DEF:wtime_avg={file}:wtime:AVERAGE", - "DEF:wtime_min={file}:wtime:MIN", - "DEF:wtime_max={file}:wtime:MAX", - "CDEF:rtime_avg_ms=rtime_avg,1000,/", - "CDEF:rtime_min_ms=rtime_min,1000,/", - "CDEF:rtime_max_ms=rtime_max,1000,/", - "CDEF:wtime_avg_ms=wtime_avg,1000,/", - "CDEF:wtime_min_ms=wtime_min,1000,/", - "CDEF:wtime_max_ms=wtime_max,1000,/", - "CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+", - "CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+", - "CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+", - "AREA:total_max_ms#" .. self.palette.HalfRed, - "AREA:total_min_ms#" .. self.palette.Canvas, - "LINE1:wtime_avg_ms#" .. self.palette.FullGreen .. ":Write", - "GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n", - "LINE1:rtime_avg_ms#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n", - "LINE1:total_avg_ms#" .. self.palette.FullRed .. ":Total", - "GPRINT:total_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:total_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:total_avg_ms:LAST:%5.1lf%s Last\\l" - }, - - disk_octets = { - "-v", "Bytes/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "CDEF:mytime=out_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_max:MAX:%5.1lf%s Max,", - "GPRINT:out_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - disk_merged = { - "-v", "Merged Ops/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:out_max:MAX:%6.2lf Max,", - "GPRINT:out_avg:LAST:%6.2lf Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:inc_max:MAX:%6.2lf Max,", - "GPRINT:inc_avg:LAST:%6.2lf Last\\l" - }, - - disk_ops = { - "-v", "Ops/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:out_max:MAX:%6.2lf Max,", - "GPRINT:out_avg:LAST:%6.2lf Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:inc_max:MAX:%6.2lf Max,", - "GPRINT:inc_avg:LAST:%6.2lf Last\\l" - }, - - disk_time = { - "-v", "Seconds/s", - "DEF:out_min_raw={file}:write:MIN", - "DEF:out_avg_raw={file}:write:AVERAGE", - "DEF:out_max_raw={file}:write:MAX", - "DEF:inc_min_raw={file}:read:MIN", - "DEF:inc_avg_raw={file}:read:AVERAGE", - "DEF:inc_max_raw={file}:read:MAX", - "CDEF:out_min=out_min_raw,1000,/", - "CDEF:out_avg=out_avg_raw,1000,/", - "CDEF:out_max=out_max_raw,1000,/", - "CDEF:inc_min=inc_min_raw,1000,/", - "CDEF:inc_avg=inc_avg_raw,1000,/", - "CDEF:inc_max=inc_max_raw,1000,/", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%5.1lf%ss Avg,", - "GPRINT:out_max:MAX:%5.1lf%ss Max,", - "GPRINT:out_avg:LAST:%5.1lf%ss Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%5.1lf%ss Avg,", - "GPRINT:inc_max:MAX:%5.1lf%ss Max,", - "GPRINT:inc_avg:LAST:%5.1lf%ss Last\\l" - }, - - dns_octets = { - "DEF:rsp_min_raw={file}:responses:MIN", - "DEF:rsp_avg_raw={file}:responses:AVERAGE", - "DEF:rsp_max_raw={file}:responses:MAX", - "DEF:qry_min_raw={file}:queries:MIN", - "DEF:qry_avg_raw={file}:queries:AVERAGE", - "DEF:qry_max_raw={file}:queries:MAX", - "CDEF:rsp_min=rsp_min_raw,8,*", - "CDEF:rsp_avg=rsp_avg_raw,8,*", - "CDEF:rsp_max=rsp_max_raw,8,*", - "CDEF:qry_min=qry_min_raw,8,*", - "CDEF:qry_avg=qry_avg_raw,8,*", - "CDEF:qry_max=qry_max_raw,8,*", - "CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF", - "CDEF:mytime=rsp_avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*", - "CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+", - "CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*", - "CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+", - "AREA:rsp_avg#" .. self.palette.HalfGreen, - "AREA:qry_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:rsp_avg#" .. self.palette.FullGreen .. ":Responses", - "GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rsp_max:MAX:%5.1lf%s Max,", - "GPRINT:rsp_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:qry_avg#" .. self.palette.FullBlue .. ":Queries ", - #"GPRINT:qry_min:MIN:%5.1lf %s Min,", - "GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:qry_max:MAX:%5.1lf%s Max,", - "GPRINT:qry_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - dns_opcode = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Queries/s", - "GPRINT:min:MIN:%9.3lf Min,", - "GPRINT:avg:AVERAGE:%9.3lf Average,", - "GPRINT:max:MAX:%9.3lf Max,", - "GPRINT:avg:LAST:%9.3lf Last\\l" - }, - - email_count = { - "-v", "Mails", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - email_size = { - "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - spam_score = { - "-v", "Score", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Score ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - spam_check = { - "DEF:avg={file}:hits:AVERAGE", - "DEF:min={file}:hits:MIN", - "DEF:max={file}:hits:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - entropy = { - "-v", "Bits", - "DEF:avg={file}:entropy:AVERAGE", - "DEF:min={file}:entropy:MIN", - "DEF:max={file}:entropy:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits", - "GPRINT:min:MIN:%4.0lfbit Min,", - "GPRINT:avg:AVERAGE:%4.0lfbit Avg,", - "GPRINT:max:MAX:%4.0lfbit Max,", - "GPRINT:avg:LAST:%4.0lfbit Last\\l" - }, - - fanspeed = { - "-v", "RPM", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":RPM", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - frequency = { - "-v", "Hertz", - "DEF:avg={file}:frequency:AVERAGE", - "DEF:min={file}:frequency:MIN", - "DEF:max={file}:frequency:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Frequency [Hz]", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - frequency_offset = { - "DEF:ppm_avg={file}:ppm:AVERAGE", - "DEF:ppm_min={file}:ppm:MIN", - "DEF:ppm_max={file}:ppm:MAX", - "AREA:ppm_max#" .. self.palette.HalfBlue, - "AREA:ppm_min#" .. self.palette.Canvas, - "LINE1:ppm_avg#" .. self.palette.FullBlue .. ":{inst}", - "GPRINT:ppm_min:MIN:%5.2lf Min,", - "GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:ppm_max:MAX:%5.2lf Max,", - "GPRINT:ppm_avg:LAST:%5.2lf Last\\l" - }, - - gauge = { - "-v", "Exec value", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfBlue, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullBlue .. ":Exec value", - "GPRINT:temp_min:MIN:%6.2lf Min,", - "GPRINT:temp_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:temp_max:MAX:%6.2lf Max,", - "GPRINT:temp_avg:LAST:%6.2lf Last\\l" - }, - - hddtemp = { - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfRed, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", - "GPRINT:temp_max:MAX:%4.1lf Max,", - "GPRINT:temp_avg:LAST:%4.1lf Last\\l" - }, - - humidity = { - "-v", "Percent", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfGreen, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullGreen .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf%% Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,", - "GPRINT:temp_max:MAX:%4.1lf%% Max,", - "GPRINT:temp_avg:LAST:%4.1lf%% Last\\l" - }, - - if_errors = { - "-v", "Errors/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_collisions = { - "-v", "Collisions/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Collisions/s", - "GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - if_dropped = { - "-v", "Packets/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_packets = { - "-v", "Packets/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_rx_errors = { - "-v", "Errors/s", - "DEF:min={file}:value:MIN", - "DEF:avg={file}:value:AVERAGE", - "DEF:max={file}:value:MAX", - "CDEF:mytime=avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":Errors/s", - "GPRINT:avg:AVERAGE:%3.1lf%s Avg,", - "GPRINT:max:MAX:%3.1lf%s Max,", - "GPRINT:avg:LAST:%3.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)" - }, - - ipt_bytes = { - "-v", "Bits/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "CDEF:mytime=avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", - #"GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - ipt_packets = { - "-v", "Packets/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Packets/s", - "GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - irq = { - "-v", "Issues/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - load = { - "-v", "System load", - "DEF:s_avg={file}:shortterm:AVERAGE", - "DEF:s_min={file}:shortterm:MIN", - "DEF:s_max={file}:shortterm:MAX", - "DEF:m_avg={file}:midterm:AVERAGE", - "DEF:m_min={file}:midterm:MIN", - "DEF:m_max={file}:midterm:MAX", - "DEF:l_avg={file}:longterm:AVERAGE", - "DEF:l_min={file}:longterm:MIN", - "DEF:l_max={file}:longterm:MAX", - "AREA:s_max#" .. self.palette.HalfGreen, - "AREA:s_min#" .. self.palette.Canvas, - "LINE1:s_avg#" .. self.palette.FullGreen .. ": 1m average", - "GPRINT:s_min:MIN:%4.2lf Min,", - "GPRINT:s_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:s_max:MAX:%4.2lf Max,", - "GPRINT:s_avg:LAST:%4.2lf Last\n", - "LINE1:m_avg#" .. self.palette.FullBlue .. ": 5m average", - "GPRINT:m_min:MIN:%4.2lf Min,", - "GPRINT:m_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:m_max:MAX:%4.2lf Max,", - "GPRINT:m_avg:LAST:%4.2lf Last\n", - "LINE1:l_avg#" .. self.palette.FullRed .. ":15m average", - "GPRINT:l_min:MIN:%4.2lf Min,", - "GPRINT:l_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:l_max:MAX:%4.2lf Max,", - "GPRINT:l_avg:LAST:%4.2lf Last\\l" - }, - - load_percent = { - "DEF:avg={file}:percent:AVERAGE", - "DEF:min={file}:percent:MIN", - "DEF:max={file}:percent:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Load", - "GPRINT:min:MIN:%5.1lf%s%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", - "GPRINT:max:MAX:%5.1lf%s%% Max,", - "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" - }, - - mails = { - "DEF:rawgood={file}:good:AVERAGE", - "DEF:rawspam={file}:spam:AVERAGE", - "CDEF:good=rawgood,UN,0,rawgood,IF", - "CDEF:spam=rawspam,UN,0,rawspam,IF", - "CDEF:negspam=spam,-1,*", - "AREA:good#" .. self.palette.HalfGreen, - "LINE1:good#" .. self.palette.FullGreen .. ":Good mails", - "GPRINT:good:AVERAGE:%4.1lf Avg,", - "GPRINT:good:MAX:%4.1lf Max,", - "GPRINT:good:LAST:%4.1lf Last\n", - "AREA:negspam#" .. self.palette.HalfRed, - "LINE1:negspam#" .. self.palette.FullRed .. ":Spam mails", - "GPRINT:spam:AVERAGE:%4.1lf Avg,", - "GPRINT:spam:MAX:%4.1lf Max,", - "GPRINT:spam:LAST:%4.1lf Last\\l", - "HRULE:0#000000" - }, - - memory = { - "-b", "1024", "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Memory", - "GPRINT:min:MIN:%5.1lf%sbyte Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,", - "GPRINT:max:MAX:%5.1lf%sbyte Max,", - "GPRINT:avg:LAST:%5.1lf%sbyte Last\\l" - }, - - old_memory = { - "DEF:used_avg={file}:used:AVERAGE", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:buffers_avg={file}:buffers:AVERAGE", - "DEF:cached_avg={file}:cached:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:free_min={file}:free:MIN", - "DEF:buffers_min={file}:buffers:MIN", - "DEF:cached_min={file}:cached:MIN", - "DEF:used_max={file}:used:MAX", - "DEF:free_max={file}:free:MAX", - "DEF:buffers_max={file}:buffers:MAX", - "DEF:cached_max={file}:cached:MAX", - "CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF", - "CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF", - "CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+", - "CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+", - "CDEF:buffers_used=buffers_avg,used_avg,+", - "AREA:free_cached_buffers_used#" .. self.palette.HalfGreen, - "AREA:cached_buffers_used#" .. self.palette.HalfBlue, - "AREA:buffers_used#" .. self.palette.HalfYellow, - "AREA:used_avg#" .. self.palette.HalfRed, - "LINE1:free_cached_buffers_used#" .. self.palette.FullGreen .. ":Free ", - "GPRINT:free_min:MIN:%5.1lf%s Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:free_max:MAX:%5.1lf%s Max,", - "GPRINT:free_avg:LAST:%5.1lf%s Last\n", - "LINE1:cached_buffers_used#" .. self.palette.FullBlue .. ":Page cache ", - "GPRINT:cached_min:MIN:%5.1lf%s Min,", - "GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cached_max:MAX:%5.1lf%s Max,", - "GPRINT:cached_avg:LAST:%5.1lf%s Last\n", - "LINE1:buffers_used#" .. self.palette.FullYellow .. ":Buffer cache", - "GPRINT:buffers_min:MIN:%5.1lf%s Min,", - "GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:buffers_max:MAX:%5.1lf%s Max,", - "GPRINT:buffers_avg:LAST:%5.1lf%s Last\n", - "LINE1:used_avg#" .. self.palette.FullRed .. ":Used ", - "GPRINT:used_min:MIN:%5.1lf%s Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:used_max:MAX:%5.1lf%s Max,", - "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" - }, - - mysql_commands = { - "-v", "Issues/s", - "DEF:val_avg={file}:value:AVERAGE", - "DEF:val_min={file}:value:MIN", - "DEF:val_max={file}:value:MAX", - "AREA:val_max#" .. self.palette.HalfBlue, - "AREA:val_min#" .. self.palette.Canvas, - "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:val_min:MIN:%5.2lf Min,", - "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:val_max:MAX:%5.2lf Max,", - "GPRINT:val_avg:LAST:%5.2lf Last\\l" - }, - - mysql_handler = { - "-v", "Issues/s", - "DEF:val_avg={file}:value:AVERAGE", - "DEF:val_min={file}:value:MIN", - "DEF:val_max={file}:value:MAX", - "AREA:val_max#" .. self.palette.HalfBlue, - "AREA:val_min#" .. self.palette.Canvas, - "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:val_min:MIN:%5.2lf Min,", - "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:val_max:MAX:%5.2lf Max,", - "GPRINT:val_avg:LAST:%5.2lf Last\\l" - }, - - mysql_octets = { - "-v", "Bits/s", - "DEF:out_min={file}:tx:MIN", - "DEF:out_avg={file}:tx:AVERAGE", - "DEF:out_max={file}:tx:MAX", - "DEF:inc_min={file}:rx:MIN", - "DEF:inc_avg={file}:rx:AVERAGE", - "DEF:inc_max={file}:rx:MAX", - "CDEF:mytime=out_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "CDEF:out_bit_min=out_min,8,*", - "CDEF:out_bit_avg=out_avg,8,*", - "CDEF:out_bit_max=out_max,8,*", - "CDEF:inc_bit_min=inc_min,8,*", - "CDEF:inc_bit_avg=inc_avg,8,*", - "CDEF:inc_bit_max=inc_max,8,*", - "CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF", - "AREA:out_bit_avg#" .. self.palette.HalfGreen, - "AREA:inc_bit_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_bit_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_bit_max:MAX:%5.1lf%s Max,", - "GPRINT:out_bit_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:inc_bit_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_bit_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_bit_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - mysql_qcache = { - "-v", "Queries/s", - "DEF:hits_min={file}:hits:MIN", - "DEF:hits_avg={file}:hits:AVERAGE", - "DEF:hits_max={file}:hits:MAX", - "DEF:inserts_min={file}:inserts:MIN", - "DEF:inserts_avg={file}:inserts:AVERAGE", - "DEF:inserts_max={file}:inserts:MAX", - "DEF:not_cached_min={file}:not_cached:MIN", - "DEF:not_cached_avg={file}:not_cached:AVERAGE", - "DEF:not_cached_max={file}:not_cached:MAX", - "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN", - "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE", - "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX", - "DEF:queries_min={file}:queries_in_cache:MIN", - "DEF:queries_avg={file}:queries_in_cache:AVERAGE", - "DEF:queries_max={file}:queries_in_cache:MAX", - "CDEF:unknown=queries_avg,UNKN,+", - "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+", - "CDEF:inserts_agg=hits_avg,inserts_avg,+", - "CDEF:hits_agg=hits_avg", - "AREA:not_cached_agg#" .. self.palette.HalfYellow, - "AREA:inserts_agg#" .. self.palette.HalfBlue, - "AREA:hits_agg#" .. self.palette.HalfGreen, - "LINE1:not_cached_agg#" .. self.palette.FullYellow .. ":Not Cached ", - "GPRINT:not_cached_min:MIN:%5.2lf Min,", - "GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:not_cached_max:MAX:%5.2lf Max,", - "GPRINT:not_cached_avg:LAST:%5.2lf Last\\l", - "LINE1:inserts_agg#" .. self.palette.FullBlue .. ":Inserts ", - "GPRINT:inserts_min:MIN:%5.2lf Min,", - "GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:inserts_max:MAX:%5.2lf Max,", - "GPRINT:inserts_avg:LAST:%5.2lf Last\\l", - "LINE1:hits_agg#" .. self.palette.FullGreen .. ":Hits ", - "GPRINT:hits_min:MIN:%5.2lf Min,", - "GPRINT:hits_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:hits_max:MAX:%5.2lf Max,", - "GPRINT:hits_avg:LAST:%5.2lf Last\\l", - "LINE1:lowmem_prunes_avg#" .. self.palette.FullRed .. ":Lowmem Prunes ", - "GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,", - "GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,", - "GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\\l", - "LINE1:unknown#" .. self.palette.Canvas .. ":Queries in cache", - "GPRINT:queries_min:MIN:%5.0lf Min,", - "GPRINT:queries_avg:AVERAGE:%5.0lf Avg,", - "GPRINT:queries_max:MAX:%5.0lf Max,", - "GPRINT:queries_avg:LAST:%5.0lf Last\\l" - }, - - mysql_threads = { - "-v", "Threads", - "DEF:running_min={file}:running:MIN", - "DEF:running_avg={file}:running:AVERAGE", - "DEF:running_max={file}:running:MAX", - "DEF:connected_min={file}:connected:MIN", - "DEF:connected_avg={file}:connected:AVERAGE", - "DEF:connected_max={file}:connected:MAX", - "DEF:cached_min={file}:cached:MIN", - "DEF:cached_avg={file}:cached:AVERAGE", - "DEF:cached_max={file}:cached:MAX", - "DEF:created_min={file}:created:MIN", - "DEF:created_avg={file}:created:AVERAGE", - "DEF:created_max={file}:created:MAX", - "CDEF:unknown=created_avg,UNKN,+", - "CDEF:cached_agg=connected_avg,cached_avg,+", - "AREA:cached_agg#" .. self.palette.HalfGreen, - "AREA:connected_avg#" .. self.palette.HalfBlue, - "AREA:running_avg#" .. self.palette.HalfRed, - "LINE1:cached_agg#" .. self.palette.FullGreen .. ":Cached ", - "GPRINT:cached_min:MIN:%5.1lf Min,", - "GPRINT:cached_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:cached_max:MAX:%5.1lf Max,", - "GPRINT:cached_avg:LAST:%5.1lf Last\\l", - "LINE1:connected_avg#" .. self.palette.FullBlue .. ":Connected", - "GPRINT:connected_min:MIN:%5.1lf Min,", - "GPRINT:connected_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:connected_max:MAX:%5.1lf Max,", - "GPRINT:connected_avg:LAST:%5.1lf Last\\l", - "LINE1:running_avg#" .. self.palette.FullRed .. ":Running ", - "GPRINT:running_min:MIN:%5.1lf Min,", - "GPRINT:running_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:running_max:MAX:%5.1lf Max,", - "GPRINT:running_avg:LAST:%5.1lf Last\\l", - "LINE1:unknown#" .. self.palette.Canvas .. ":Created ", - "GPRINT:created_min:MIN:%5.0lf Min,", - "GPRINT:created_avg:AVERAGE:%5.0lf Avg,", - "GPRINT:created_max:MAX:%5.0lf Max,", - "GPRINT:created_avg:LAST:%5.0lf Last\\l" - }, - - nfs_procedure = { - "-v", "Issues/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - nfs3_procedures = { - "DEF:null_avg={file}:null:AVERAGE", - "DEF:getattr_avg={file}:getattr:AVERAGE", - "DEF:setattr_avg={file}:setattr:AVERAGE", - "DEF:lookup_avg={file}:lookup:AVERAGE", - "DEF:access_avg={file}:access:AVERAGE", - "DEF:readlink_avg={file}:readlink:AVERAGE", - "DEF:read_avg={file}:read:AVERAGE", - "DEF:write_avg={file}:write:AVERAGE", - "DEF:create_avg={file}:create:AVERAGE", - "DEF:mkdir_avg={file}:mkdir:AVERAGE", - "DEF:symlink_avg={file}:symlink:AVERAGE", - "DEF:mknod_avg={file}:mknod:AVERAGE", - "DEF:remove_avg={file}:remove:AVERAGE", - "DEF:rmdir_avg={file}:rmdir:AVERAGE", - "DEF:rename_avg={file}:rename:AVERAGE", - "DEF:link_avg={file}:link:AVERAGE", - "DEF:readdir_avg={file}:readdir:AVERAGE", - "DEF:readdirplus_avg={file}:readdirplus:AVERAGE", - "DEF:fsstat_avg={file}:fsstat:AVERAGE", - "DEF:fsinfo_avg={file}:fsinfo:AVERAGE", - "DEF:pathconf_avg={file}:pathconf:AVERAGE", - "DEF:commit_avg={file}:commit:AVERAGE", - "DEF:null_max={file}:null:MAX", - "DEF:getattr_max={file}:getattr:MAX", - "DEF:setattr_max={file}:setattr:MAX", - "DEF:lookup_max={file}:lookup:MAX", - "DEF:access_max={file}:access:MAX", - "DEF:readlink_max={file}:readlink:MAX", - "DEF:read_max={file}:read:MAX", - "DEF:write_max={file}:write:MAX", - "DEF:create_max={file}:create:MAX", - "DEF:mkdir_max={file}:mkdir:MAX", - "DEF:symlink_max={file}:symlink:MAX", - "DEF:mknod_max={file}:mknod:MAX", - "DEF:remove_max={file}:remove:MAX", - "DEF:rmdir_max={file}:rmdir:MAX", - "DEF:rename_max={file}:rename:MAX", - "DEF:link_max={file}:link:MAX", - "DEF:readdir_max={file}:readdir:MAX", - "DEF:readdirplus_max={file}:readdirplus:MAX", - "DEF:fsstat_max={file}:fsstat:MAX", - "DEF:fsinfo_max={file}:fsinfo:MAX", - "DEF:pathconf_max={file}:pathconf:MAX", - "DEF:commit_max={file}:commit:MAX", - "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+", - "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+", - "CDEF:stack_read=read_avg", - "CDEF:stack_getattr=stack_read,getattr_avg,+", - "CDEF:stack_access=stack_getattr,access_avg,+", - "CDEF:stack_lookup=stack_access,lookup_avg,+", - "CDEF:stack_write=stack_lookup,write_avg,+", - "CDEF:stack_commit=stack_write,commit_avg,+", - "CDEF:stack_setattr=stack_commit,setattr_avg,+", - "CDEF:stack_other=stack_setattr,other_avg,+", - "AREA:stack_other#" .. self.palette.HalfRed, - "AREA:stack_setattr#" .. self.palette.HalfGreen, - "AREA:stack_commit#" .. self.palette.HalfYellow, - "AREA:stack_write#" .. self.palette.HalfGreen, - "AREA:stack_lookup#" .. self.palette.HalfBlue, - "AREA:stack_access#" .. self.palette.HalfMagenta, - "AREA:stack_getattr#" .. self.palette.HalfCyan, - "AREA:stack_read#" .. self.palette.HalfBlue, - "LINE1:stack_other#" .. self.palette.FullRed .. ":Other ", - "GPRINT:other_max:MAX:%5.1lf Max,", - "GPRINT:other_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:other_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_setattr#" .. self.palette.FullGreen .. ":setattr", - "GPRINT:setattr_max:MAX:%5.1lf Max,", - "GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:setattr_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_commit#" .. self.palette.FullYellow .. ":commit ", - "GPRINT:commit_max:MAX:%5.1lf Max,", - "GPRINT:commit_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:commit_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_write#" .. self.palette.FullGreen .. ":write ", - "GPRINT:write_max:MAX:%5.1lf Max,", - "GPRINT:write_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:write_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_lookup#" .. self.palette.FullBlue .. ":lookup ", - "GPRINT:lookup_max:MAX:%5.1lf Max,", - "GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:lookup_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_access#" .. self.palette.FullMagenta .. ":access ", - "GPRINT:access_max:MAX:%5.1lf Max,", - "GPRINT:access_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:access_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_getattr#" .. self.palette.FullCyan .. ":getattr", - "GPRINT:getattr_max:MAX:%5.1lf Max,", - "GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:getattr_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_read#" .. self.palette.FullBlue .. ":read ", - "GPRINT:read_max:MAX:%5.1lf Max,", - "GPRINT:read_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:read_avg:LAST:%5.1lf Last\\l" - }, - - partition = { - "DEF:rbyte_avg={file}:rbytes:AVERAGE", - "DEF:rbyte_min={file}:rbytes:MIN", - "DEF:rbyte_max={file}:rbytes:MAX", - "DEF:wbyte_avg={file}:wbytes:AVERAGE", - "DEF:wbyte_min={file}:wbytes:MIN", - "DEF:wbyte_max={file}:wbytes:MAX", - "CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF", - "AREA:wbyte_avg#" .. self.palette.HalfGreen, - "AREA:rbyte_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:wbyte_avg#" .. self.palette.FullGreen .. ":Write", - "GPRINT:wbyte_min:MIN:%5.1lf%s Min,", - "GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:wbyte_max:MAX:%5.1lf%s Max,", - "GPRINT:wbyte_avg:LAST:%5.1lf%s Last\\l", - "LINE1:rbyte_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:rbyte_min:MIN:%5.1lf%s Min,", - "GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rbyte_max:MAX:%5.1lf%s Max,", - "GPRINT:rbyte_avg:LAST:%5.1lf%s Last\\l" - }, - - percent = { - "-v", "Percent", - "DEF:avg={file}:percent:AVERAGE", - "DEF:min={file}:percent:MIN", - "DEF:max={file}:percent:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", - "GPRINT:min:MIN:%5.1lf%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%% Avg,", - "GPRINT:max:MAX:%5.1lf%% Max,", - "GPRINT:avg:LAST:%5.1lf%% Last\\l" - }, - - ping = { - "DEF:ping_avg={file}:ping:AVERAGE", - "DEF:ping_min={file}:ping:MIN", - "DEF:ping_max={file}:ping:MAX", - "AREA:ping_max#" .. self.palette.HalfBlue, - "AREA:ping_min#" .. self.palette.Canvas, - "LINE1:ping_avg#" .. self.palette.FullBlue .. ":Ping", - "GPRINT:ping_min:MIN:%4.1lf ms Min,", - "GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,", - "GPRINT:ping_max:MAX:%4.1lf ms Max,", - "GPRINT:ping_avg:LAST:%4.1lf ms Last\\l" - }, - - power = { - "-v", "Watt", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Watt", - "GPRINT:min:MIN:%5.1lf%sW Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sW Avg,", - "GPRINT:max:MAX:%5.1lf%sW Max,", - "GPRINT:avg:LAST:%5.1lf%sW Last\\l" - }, - - _processes = { - "DEF:running_avg={file}:running:AVERAGE", - "DEF:running_min={file}:running:MIN", - "DEF:running_max={file}:running:MAX", - "DEF:sleeping_avg={file}:sleeping:AVERAGE", - "DEF:sleeping_min={file}:sleeping:MIN", - "DEF:sleeping_max={file}:sleeping:MAX", - "DEF:zombies_avg={file}:zombies:AVERAGE", - "DEF:zombies_min={file}:zombies:MIN", - "DEF:zombies_max={file}:zombies:MAX", - "DEF:stopped_avg={file}:stopped:AVERAGE", - "DEF:stopped_min={file}:stopped:MIN", - "DEF:stopped_max={file}:stopped:MAX", - "DEF:paging_avg={file}:paging:AVERAGE", - "DEF:paging_min={file}:paging:MIN", - "DEF:paging_max={file}:paging:MAX", - "DEF:blocked_avg={file}:blocked:AVERAGE", - "DEF:blocked_min={file}:blocked:MIN", - "DEF:blocked_max={file}:blocked:MAX", - "CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+", - "CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+", - "CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+", - "CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+", - "CDEF:running_acc=sleeping_avg,running_avg,+", - "CDEF:sleeping_acc=sleeping_avg", - "AREA:paging_acc#" .. self.palette.HalfYellow, - "AREA:blocked_acc#" .. self.palette.HalfCyan, - "AREA:zombies_acc#" .. self.palette.HalfRed, - "AREA:stopped_acc#" .. self.palette.HalfMagenta, - "AREA:running_acc#" .. self.palette.HalfGreen, - "AREA:sleeping_acc#" .. self.palette.HalfBlue, - "LINE1:paging_acc#" .. self.palette.FullYellow .. ":Paging ", - "GPRINT:paging_min:MIN:%5.1lf Min,", - "GPRINT:paging_avg:AVERAGE:%5.1lf Average,", - "GPRINT:paging_max:MAX:%5.1lf Max,", - "GPRINT:paging_avg:LAST:%5.1lf Last\\l", - "LINE1:blocked_acc#" .. self.palette.FullCyan .. ":Blocked ", - "GPRINT:blocked_min:MIN:%5.1lf Min,", - "GPRINT:blocked_avg:AVERAGE:%5.1lf Average,", - "GPRINT:blocked_max:MAX:%5.1lf Max,", - "GPRINT:blocked_avg:LAST:%5.1lf Last\\l", - "LINE1:zombies_acc#" .. self.palette.FullRed .. ":Zombies ", - "GPRINT:zombies_min:MIN:%5.1lf Min,", - "GPRINT:zombies_avg:AVERAGE:%5.1lf Average,", - "GPRINT:zombies_max:MAX:%5.1lf Max,", - "GPRINT:zombies_avg:LAST:%5.1lf Last\\l", - "LINE1:stopped_acc#" .. self.palette.FullMagenta .. ":Stopped ", - "GPRINT:stopped_min:MIN:%5.1lf Min,", - "GPRINT:stopped_avg:AVERAGE:%5.1lf Average,", - "GPRINT:stopped_max:MAX:%5.1lf Max,", - "GPRINT:stopped_avg:LAST:%5.1lf Last\\l", - "LINE1:running_acc#" .. self.palette.FullGreen .. ":Running ", - "GPRINT:running_min:MIN:%5.1lf Min,", - "GPRINT:running_avg:AVERAGE:%5.1lf Average,", - "GPRINT:running_max:MAX:%5.1lf Max,", - "GPRINT:running_avg:LAST:%5.1lf Last\\l", - "LINE1:sleeping_acc#" .. self.palette.FullBlue .. ":Sleeping", - "GPRINT:sleeping_min:MIN:%5.1lf Min,", - "GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,", - "GPRINT:sleeping_max:MAX:%5.1lf Max,", - "GPRINT:sleeping_avg:LAST:%5.1lf Last\\l" - }, - - ps_count = { - "-v", "Processes", - "DEF:procs_avg={file}:processes:AVERAGE", - "DEF:procs_min={file}:processes:MIN", - "DEF:procs_max={file}:processes:MAX", - "DEF:thrds_avg={file}:threads:AVERAGE", - "DEF:thrds_min={file}:threads:MIN", - "DEF:thrds_max={file}:threads:MAX", - "AREA:thrds_avg#" .. self.palette.HalfBlue, - "AREA:procs_avg#" .. self.palette.HalfRed, - "LINE1:thrds_avg#" .. self.palette.FullBlue .. ":Threads ", - "GPRINT:thrds_min:MIN:%5.1lf Min,", - "GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:thrds_max:MAX:%5.1lf Max,", - "GPRINT:thrds_avg:LAST:%5.1lf Last\\l", - "LINE1:procs_avg#" .. self.palette.FullRed .. ":Processes", - "GPRINT:procs_min:MIN:%5.1lf Min,", - "GPRINT:procs_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:procs_max:MAX:%5.1lf Max,", - "GPRINT:procs_avg:LAST:%5.1lf Last\\l" - }, - - ps_cputime = { - "-v", "Jiffies", - "DEF:user_avg_raw={file}:user:AVERAGE", - "DEF:user_min_raw={file}:user:MIN", - "DEF:user_max_raw={file}:user:MAX", - "DEF:syst_avg_raw={file}:syst:AVERAGE", - "DEF:syst_min_raw={file}:syst:MIN", - "DEF:syst_max_raw={file}:syst:MAX", - "CDEF:user_avg=user_avg_raw,1000000,/", - "CDEF:user_min=user_min_raw,1000000,/", - "CDEF:user_max=user_max_raw,1000000,/", - "CDEF:syst_avg=syst_avg_raw,1000000,/", - "CDEF:syst_min=syst_min_raw,1000000,/", - "CDEF:syst_max=syst_max_raw,1000000,/", - "CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+", - "AREA:user_syst#" .. self.palette.HalfBlue, - "AREA:syst_avg#" .. self.palette.HalfRed, - "LINE1:user_syst#" .. self.palette.FullBlue .. ":User ", - "GPRINT:user_min:MIN:%5.1lf%s Min,", - "GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:user_max:MAX:%5.1lf%s Max,", - "GPRINT:user_avg:LAST:%5.1lf%s Last\\l", - "LINE1:syst_avg#" .. self.palette.FullRed .. ":System", - "GPRINT:syst_min:MIN:%5.1lf%s Min,", - "GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:syst_max:MAX:%5.1lf%s Max,", - "GPRINT:syst_avg:LAST:%5.1lf%s Last\\l" - }, - - ps_pagefaults = { - "-v", "Pagefaults/s", - "DEF:minor_avg={file}:minflt:AVERAGE", - "DEF:minor_min={file}:minflt:MIN", - "DEF:minor_max={file}:minflt:MAX", - "DEF:major_avg={file}:majflt:AVERAGE", - "DEF:major_min={file}:majflt:MIN", - "DEF:major_max={file}:majflt:MAX", - "CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+", - "AREA:minor_major#" .. self.palette.HalfBlue, - "AREA:major_avg#" .. self.palette.HalfRed, - "LINE1:minor_major#" .. self.palette.FullBlue .. ":Minor", - "GPRINT:minor_min:MIN:%5.1lf%s Min,", - "GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:minor_max:MAX:%5.1lf%s Max,", - "GPRINT:minor_avg:LAST:%5.1lf%s Last\\l", - "LINE1:major_avg#" .. self.palette.FullRed .. ":Major", - "GPRINT:major_min:MIN:%5.1lf%s Min,", - "GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:major_max:MAX:%5.1lf%s Max,", - "GPRINT:major_avg:LAST:%5.1lf%s Last\\l" - }, - - ps_rss = { - "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":RSS", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - _ps_state = { - "-v", "Processes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - _signal_noise = { - "-v", "dBm", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Noise", - "GPRINT:min:MIN:%5.1lf%sdBm Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", - "GPRINT:max:MAX:%5.1lf%sdBm Max,", - "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" - }, - - _signal_power = { - "-v", "dBm", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Power", - "GPRINT:min:MIN:%5.1lf%sdBm Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", - "GPRINT:max:MAX:%5.1lf%sdBm Max,", - "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" - }, - - _signal_quality = { - "-v", "%", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Quality", - "GPRINT:min:MIN:%5.1lf%s%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", - "GPRINT:max:MAX:%5.1lf%s%% Max,", - "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" - }, - - swap = { - "-v", "Bytes", "-b", "1024", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bytes", - "GPRINT:min:MIN:%6.2lf%sByte Min,", - "GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,", - "GPRINT:max:MAX:%6.2lf%sByte Max,", - "GPRINT:avg:LAST:%6.2lf%sByte Last\\l" - }, - - old_swap = { - "DEF:used_avg={file}:used:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:used_max={file}:used:MAX", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:free_min={file}:free:MIN", - "DEF:free_max={file}:free:MAX", - "DEF:cach_avg={file}:cached:AVERAGE", - "DEF:cach_min={file}:cached:MIN", - "DEF:cach_max={file}:cached:MAX", - "DEF:resv_avg={file}:resv:AVERAGE", - "DEF:resv_min={file}:resv:MIN", - "DEF:resv_max={file}:resv:MAX", - "CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF", - "CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF", - "CDEF:used_acc=used_avg", - "CDEF:resv_acc=used_acc,resv_avg_notnull,+", - "CDEF:cach_acc=resv_acc,cach_avg_notnull,+", - "CDEF:free_acc=cach_acc,free_avg,+", - "AREA:free_acc#" .. self.palette.HalfGreen, - "AREA:cach_acc#" .. self.palette.HalfBlue, - "AREA:resv_acc#" .. self.palette.HalfYellow, - "AREA:used_acc#" .. self.palette.HalfRed, - "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free ", - "GPRINT:free_min:MIN:%5.1lf%s Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:free_max:MAX:%5.1lf%s Max,", - "GPRINT:free_avg:LAST:%5.1lf%s Last\n", - "LINE1:cach_acc#" .. self.palette.FullBlue .. ":Cached ", - "GPRINT:cach_min:MIN:%5.1lf%s Min,", - "GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cach_max:MAX:%5.1lf%s Max,", - "GPRINT:cach_avg:LAST:%5.1lf%s Last\\l", - "LINE1:resv_acc#" .. self.palette.FullYellow .. ":Reserved", - "GPRINT:resv_min:MIN:%5.1lf%s Min,", - "GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:resv_max:MAX:%5.1lf%s Max,", - "GPRINT:resv_avg:LAST:%5.1lf%s Last\n", - "LINE1:used_acc#" .. self.palette.FullRed .. ":Used ", - "GPRINT:used_min:MIN:%5.1lf%s Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:used_max:MAX:%5.1lf%s Max,", - "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" - }, - - tcp_connections = { - "-v", "Connections", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Connections", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - temperature = { - "-v", "Celsius", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+", - "AREA:temp_max#" .. self.palette.HalfRed, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", - "GPRINT:temp_max:MAX:%4.1lf Max,", - "GPRINT:temp_avg:LAST:%4.1lf Last\\l" - }, - - timeleft = { - "-v", "Minutes", - "DEF:avg={file}:timeleft:AVERAGE", - "DEF:min={file}:timeleft:MIN", - "DEF:max={file}:timeleft:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Time left [min]", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - time_offset = { - "DEF:s_avg={file}:seconds:AVERAGE", - "DEF:s_min={file}:seconds:MIN", - "DEF:s_max={file}:seconds:MAX", - "AREA:s_max#" .. self.palette.HalfBlue, - "AREA:s_min#" .. self.palette.Canvas, - "LINE1:s_avg#" .. self.palette.FullBlue .. ":{inst}", - "GPRINT:s_min:MIN:%7.3lf%s Min,", - "GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,", - "GPRINT:s_max:MAX:%7.3lf%s Max,", - "GPRINT:s_avg:LAST:%7.3lf%s Last\\l" - }, - - if_octets = { - "-v", "Bits/s", "-l", "0", - "DEF:out_min_raw={file}:tx:MIN", - "DEF:out_avg_raw={file}:tx:AVERAGE", - "DEF:out_max_raw={file}:tx:MAX", - "DEF:inc_min_raw={file}:rx:MIN", - "DEF:inc_avg_raw={file}:rx:AVERAGE", - "DEF:inc_max_raw={file}:rx:MAX", - "CDEF:out_min=out_min_raw,8,*", - "CDEF:out_avg=out_avg_raw,8,*", - "CDEF:out_max=out_max_raw,8,*", - "CDEF:inc_min=inc_min_raw,8,*", - "CDEF:inc_avg=inc_avg_raw,8,*", - "CDEF:inc_max=inc_max_raw,8,*", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "CDEF:mytime=out_avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Outgoing", - "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_max:MAX:%5.1lf%s Max,", - "GPRINT:out_avg:LAST:%5.1lf%s Last", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Incoming", - --"GPRINT:inc_min:MIN:%5.1lf %s Min,", - "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_avg:LAST:%5.1lf%s Last", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l" - }, - - cpufreq = { - "DEF:cpufreq_avg={file}:value:AVERAGE", - "DEF:cpufreq_min={file}:value:MIN", - "DEF:cpufreq_max={file}:value:MAX", - "AREA:cpufreq_max#" .. self.palette.HalfBlue, - "AREA:cpufreq_min#" .. self.palette.Canvas, - "LINE1:cpufreq_avg#" .. self.palette.FullBlue .. ":Frequency", - "GPRINT:cpufreq_min:MIN:%5.1lf%s Min,", - "GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cpufreq_max:MAX:%5.1lf%s Max,", - "GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\\l" - }, - - multimeter = { - "DEF:multimeter_avg={file}:value:AVERAGE", - "DEF:multimeter_min={file}:value:MIN", - "DEF:multimeter_max={file}:value:MAX", - "AREA:multimeter_max#" .. self.palette.HalfBlue, - "AREA:multimeter_min#" .. self.palette.Canvas, - "LINE1:multimeter_avg#" .. self.palette.FullBlue .. ":Multimeter", - "GPRINT:multimeter_min:MIN:%4.1lf Min,", - "GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,", - "GPRINT:multimeter_max:MAX:%4.1lf Max,", - "GPRINT:multimeter_avg:LAST:%4.1lf Last\\l" - }, - - users = { - "-v", "Users", - "DEF:users_avg={file}:users:AVERAGE", - "DEF:users_min={file}:users:MIN", - "DEF:users_max={file}:users:MAX", - "AREA:users_max#" .. self.palette.HalfBlue, - "AREA:users_min#" .. self.palette.Canvas, - "LINE1:users_avg#" .. self.palette.FullBlue .. ":Users", - "GPRINT:users_min:MIN:%4.1lf Min,", - "GPRINT:users_avg:AVERAGE:%4.1lf Average,", - "GPRINT:users_max:MAX:%4.1lf Max,", - "GPRINT:users_avg:LAST:%4.1lf Last\\l" - }, - - voltage = { - "-v", "Voltage", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Voltage", - "GPRINT:min:MIN:%5.1lf%sV Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sV Avg,", - "GPRINT:max:MAX:%5.1lf%sV Max,", - "GPRINT:avg:LAST:%5.1lf%sV Last\\l" - }, - - vs_threads = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Threads", - "GPRINT:min:MIN:%5.1lf Min,", - "GPRINT:avg:AVERAGE:%5.1lf Avg.,", - "GPRINT:max:MAX:%5.1lf Max,", - "GPRINT:avg:LAST:%5.1lf Last\\l", - }, - - vs_memory = { - "-b", "1024", "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":", - "GPRINT:min:MIN:%5.1lf%sbytes Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sbytes Avg.,", - "GPRINT:max:MAX:%5.1lf%sbytes Max,", - "GPRINT:avg:LAST:%5.1lf%sbytes Last\\l", - }, - - vs_processes = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%5.1lf Min,", - "GPRINT:avg:AVERAGE:%5.1lf Avg.,", - "GPRINT:max:MAX:%5.1lf Max,", - "GPRINT:avg:LAST:%5.1lf Last\\l", - }, - } - - - - -- used color palette - colors = { - Canvas = "FFFFFF", - - FullRed = "FF0000", - FullGreen = "00E000", - FullBlue = "0000FF", - FullYellow = "F0A000", - FullCyan = "00A0FF", - FullMagenta = "A000FF", - - HalfRed = "F7B7B7", - HalfGreen = "B7EFB7", - HalfBlue = "B7B7F7", - HalfYellow = "F3DFB7", - HalfCyan = "B7DFF7", - HalfMagenta = "DFB7F7", - - HalfBlueGreen = "89B3C9" - } - - - -- plotting arguments for each defined datasource - rrd_args = { - apache_bytes = { - "DEF:min_raw={file}:count:MIN", - "DEF:avg_raw={file}:count:AVERAGE", - "DEF:max_raw={file}:count:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "CDEF:mytime=avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bit/s", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - apache_requests = { - "DEF:min={file}:count:MIN", - "DEF:avg={file}:count:AVERAGE", - "DEF:max={file}:count:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Requests/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - apache_scoreboard = { - "DEF:min={file}:count:MIN", - "DEF:avg={file}:count:AVERAGE", - "DEF:max={file}:count:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - bitrate = { - "-v", "Bits/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Average,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - charge = { - "-v", "Ah", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Charge", - "GPRINT:min:MIN:%5.1lf%sAh Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sAh Avg,", - "GPRINT:max:MAX:%5.1lf%sAh Max,", - "GPRINT:avg:LAST:%5.1lf%sAh Last\\l" - }, - - cpu = { - "-v", "CPU load", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", - "GPRINT:min:MIN:%6.2lf%% Min,", - "GPRINT:avg:AVERAGE:%6.2lf%% Avg,", - "GPRINT:max:MAX:%6.2lf%% Max,", - "GPRINT:avg:LAST:%6.2lf%% Last\\l" - }, - - current = { - "-v", "Ampere", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Current", - "GPRINT:min:MIN:%5.1lf%sA Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sA Avg,", - "GPRINT:max:MAX:%5.1lf%sA Max,", - "GPRINT:avg:LAST:%5.1lf%sA Last\\l" - }, - - df = { - "-v", "Percent", "-l", "0", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:free_min={file}:free:MIN", - "DEF:free_max={file}:free:MAX", - "DEF:used_avg={file}:used:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:used_max={file}:used:MAX", - "CDEF:total=free_avg,used_avg,+", - "CDEF:free_pct=100,free_avg,*,total,/", - "CDEF:used_pct=100,used_avg,*,total,/", - "CDEF:free_acc=free_pct,used_pct,+", - "CDEF:used_acc=used_pct", - "AREA:free_acc#" .. self.palette.HalfGreen, - "AREA:used_acc#" .. self.palette.HalfRed, - "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free", - "GPRINT:free_min:MIN:%5.1lf%sB Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%sB Avg,", - "GPRINT:free_max:MAX:%5.1lf%sB Max,", - "GPRINT:free_avg:LAST:%5.1lf%sB Last\\l", - "LINE1:used_acc#" .. self.palette.FullRed .. ":Used", - "GPRINT:used_min:MIN:%5.1lf%sB Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%sB Avg,", - "GPRINT:used_max:MAX:%5.1lf%sB Max,", - "GPRINT:used_avg:LAST:%5.1lf%sB Last\\l" - }, - - disk = { - "DEF:rtime_avg={file}:rtime:AVERAGE", - "DEF:rtime_min={file}:rtime:MIN", - "DEF:rtime_max={file}:rtime:MAX", - "DEF:wtime_avg={file}:wtime:AVERAGE", - "DEF:wtime_min={file}:wtime:MIN", - "DEF:wtime_max={file}:wtime:MAX", - "CDEF:rtime_avg_ms=rtime_avg,1000,/", - "CDEF:rtime_min_ms=rtime_min,1000,/", - "CDEF:rtime_max_ms=rtime_max,1000,/", - "CDEF:wtime_avg_ms=wtime_avg,1000,/", - "CDEF:wtime_min_ms=wtime_min,1000,/", - "CDEF:wtime_max_ms=wtime_max,1000,/", - "CDEF:total_avg_ms=rtime_avg_ms,wtime_avg_ms,+", - "CDEF:total_min_ms=rtime_min_ms,wtime_min_ms,+", - "CDEF:total_max_ms=rtime_max_ms,wtime_max_ms,+", - "AREA:total_max_ms#" .. self.palette.HalfRed, - "AREA:total_min_ms#" .. self.palette.Canvas, - "LINE1:wtime_avg_ms#" .. self.palette.FullGreen .. ":Write", - "GPRINT:wtime_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:wtime_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:wtime_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:wtime_avg_ms:LAST:%5.1lf%s Last\n", - "LINE1:rtime_avg_ms#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:rtime_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:rtime_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rtime_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:rtime_avg_ms:LAST:%5.1lf%s Last\n", - "LINE1:total_avg_ms#" .. self.palette.FullRed .. ":Total", - "GPRINT:total_min_ms:MIN:%5.1lf%s Min,", - "GPRINT:total_avg_ms:AVERAGE:%5.1lf%s Avg,", - "GPRINT:total_max_ms:MAX:%5.1lf%s Max,", - "GPRINT:total_avg_ms:LAST:%5.1lf%s Last\\l" - }, - - disk_octets = { - "-v", "Bytes/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "CDEF:mytime=out_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_max:MAX:%5.1lf%s Max,", - "GPRINT:out_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - disk_merged = { - "-v", "Merged Ops/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:out_max:MAX:%6.2lf Max,", - "GPRINT:out_avg:LAST:%6.2lf Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:inc_max:MAX:%6.2lf Max,", - "GPRINT:inc_avg:LAST:%6.2lf Last\\l" - }, - - disk_ops = { - "-v", "Ops/s", - "DEF:out_min={file}:write:MIN", - "DEF:out_avg={file}:write:AVERAGE", - "DEF:out_max={file}:write:MAX", - "DEF:inc_min={file}:read:MIN", - "DEF:inc_avg={file}:read:AVERAGE", - "DEF:inc_max={file}:read:MAX", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:out_max:MAX:%6.2lf Max,", - "GPRINT:out_avg:LAST:%6.2lf Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:inc_max:MAX:%6.2lf Max,", - "GPRINT:inc_avg:LAST:%6.2lf Last\\l" - }, - - disk_time = { - "-v", "Seconds/s", - "DEF:out_min_raw={file}:write:MIN", - "DEF:out_avg_raw={file}:write:AVERAGE", - "DEF:out_max_raw={file}:write:MAX", - "DEF:inc_min_raw={file}:read:MIN", - "DEF:inc_avg_raw={file}:read:AVERAGE", - "DEF:inc_max_raw={file}:read:MAX", - "CDEF:out_min=out_min_raw,1000,/", - "CDEF:out_avg=out_avg_raw,1000,/", - "CDEF:out_max=out_max_raw,1000,/", - "CDEF:inc_min=inc_min_raw,1000,/", - "CDEF:inc_avg=inc_avg_raw,1000,/", - "CDEF:inc_max=inc_max_raw,1000,/", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_avg:AVERAGE:%5.1lf%ss Avg,", - "GPRINT:out_max:MAX:%5.1lf%ss Max,", - "GPRINT:out_avg:LAST:%5.1lf%ss Last\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_avg:AVERAGE:%5.1lf%ss Avg,", - "GPRINT:inc_max:MAX:%5.1lf%ss Max,", - "GPRINT:inc_avg:LAST:%5.1lf%ss Last\\l" - }, - - dns_octets = { - "DEF:rsp_min_raw={file}:responses:MIN", - "DEF:rsp_avg_raw={file}:responses:AVERAGE", - "DEF:rsp_max_raw={file}:responses:MAX", - "DEF:qry_min_raw={file}:queries:MIN", - "DEF:qry_avg_raw={file}:queries:AVERAGE", - "DEF:qry_max_raw={file}:queries:MAX", - "CDEF:rsp_min=rsp_min_raw,8,*", - "CDEF:rsp_avg=rsp_avg_raw,8,*", - "CDEF:rsp_max=rsp_max_raw,8,*", - "CDEF:qry_min=qry_min_raw,8,*", - "CDEF:qry_avg=qry_avg_raw,8,*", - "CDEF:qry_max=qry_max_raw,8,*", - "CDEF:overlap=rsp_avg,qry_avg,GT,qry_avg,rsp_avg,IF", - "CDEF:mytime=rsp_avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:rsp_avg_sample=rsp_avg_raw,UN,0,rsp_avg_raw,IF,sample_len,*", - "CDEF:rsp_avg_sum=PREV,UN,0,PREV,IF,rsp_avg_sample,+", - "CDEF:qry_avg_sample=qry_avg_raw,UN,0,qry_avg_raw,IF,sample_len,*", - "CDEF:qry_avg_sum=PREV,UN,0,PREV,IF,qry_avg_sample,+", - "AREA:rsp_avg#" .. self.palette.HalfGreen, - "AREA:qry_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:rsp_avg#" .. self.palette.FullGreen .. ":Responses", - "GPRINT:rsp_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rsp_max:MAX:%5.1lf%s Max,", - "GPRINT:rsp_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rsp_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:qry_avg#" .. self.palette.FullBlue .. ":Queries ", - #"GPRINT:qry_min:MIN:%5.1lf %s Min,", - "GPRINT:qry_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:qry_max:MAX:%5.1lf%s Max,", - "GPRINT:qry_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - dns_opcode = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Queries/s", - "GPRINT:min:MIN:%9.3lf Min,", - "GPRINT:avg:AVERAGE:%9.3lf Average,", - "GPRINT:max:MAX:%9.3lf Max,", - "GPRINT:avg:LAST:%9.3lf Last\\l" - }, - - email_count = { - "-v", "Mails", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - email_size = { - "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - spam_score = { - "-v", "Score", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Score ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - spam_check = { - "DEF:avg={file}:hits:AVERAGE", - "DEF:min={file}:hits:MIN", - "DEF:max={file}:hits:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":Count ", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - entropy = { - "-v", "Bits", - "DEF:avg={file}:entropy:AVERAGE", - "DEF:min={file}:entropy:MIN", - "DEF:max={file}:entropy:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits", - "GPRINT:min:MIN:%4.0lfbit Min,", - "GPRINT:avg:AVERAGE:%4.0lfbit Avg,", - "GPRINT:max:MAX:%4.0lfbit Max,", - "GPRINT:avg:LAST:%4.0lfbit Last\\l" - }, - - fanspeed = { - "-v", "RPM", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfMagenta, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullMagenta .. ":RPM", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - frequency = { - "-v", "Hertz", - "DEF:avg={file}:frequency:AVERAGE", - "DEF:min={file}:frequency:MIN", - "DEF:max={file}:frequency:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Frequency [Hz]", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - frequency_offset = { - "DEF:ppm_avg={file}:ppm:AVERAGE", - "DEF:ppm_min={file}:ppm:MIN", - "DEF:ppm_max={file}:ppm:MAX", - "AREA:ppm_max#" .. self.palette.HalfBlue, - "AREA:ppm_min#" .. self.palette.Canvas, - "LINE1:ppm_avg#" .. self.palette.FullBlue .. ":{inst}", - "GPRINT:ppm_min:MIN:%5.2lf Min,", - "GPRINT:ppm_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:ppm_max:MAX:%5.2lf Max,", - "GPRINT:ppm_avg:LAST:%5.2lf Last\\l" - }, - - gauge = { - "-v", "Exec value", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfBlue, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullBlue .. ":Exec value", - "GPRINT:temp_min:MIN:%6.2lf Min,", - "GPRINT:temp_avg:AVERAGE:%6.2lf Avg,", - "GPRINT:temp_max:MAX:%6.2lf Max,", - "GPRINT:temp_avg:LAST:%6.2lf Last\\l" - }, - - hddtemp = { - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfRed, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", - "GPRINT:temp_max:MAX:%4.1lf Max,", - "GPRINT:temp_avg:LAST:%4.1lf Last\\l" - }, - - humidity = { - "-v", "Percent", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "AREA:temp_max#" .. self.palette.HalfGreen, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullGreen .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf%% Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf%% Avg,", - "GPRINT:temp_max:MAX:%4.1lf%% Max,", - "GPRINT:temp_avg:LAST:%4.1lf%% Last\\l" - }, - - if_errors = { - "-v", "Errors/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_collisions = { - "-v", "Collisions/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Collisions/s", - "GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - if_dropped = { - "-v", "Packets/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_packets = { - "-v", "Packets/s", - "DEF:tx_min={file}:tx:MIN", - "DEF:tx_avg={file}:tx:AVERAGE", - "DEF:tx_max={file}:tx:MAX", - "DEF:rx_min={file}:rx:MIN", - "DEF:rx_avg={file}:rx:AVERAGE", - "DEF:rx_max={file}:rx:MAX", - "CDEF:overlap=tx_avg,rx_avg,GT,rx_avg,tx_avg,IF", - "CDEF:mytime=tx_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:tx_avg_sample=tx_avg,UN,0,tx_avg,IF,sample_len,*", - "CDEF:tx_avg_sum=PREV,UN,0,PREV,IF,tx_avg_sample,+", - "CDEF:rx_avg_sample=rx_avg,UN,0,rx_avg,IF,sample_len,*", - "CDEF:rx_avg_sum=PREV,UN,0,PREV,IF,rx_avg_sample,+", - "AREA:tx_avg#" .. self.palette.HalfGreen, - "AREA:rx_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:tx_avg#" .. self.palette.FullGreen .. ":TX", - "GPRINT:tx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:tx_max:MAX:%5.1lf%s Max,", - "GPRINT:tx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:tx_avg_sum:LAST:(ca. %4.0lf%s Total)", - "LINE1:rx_avg#" .. self.palette.FullBlue .. ":RX", - #"GPRINT:rx_min:MIN:%5.1lf %s Min,", - "GPRINT:rx_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rx_max:MAX:%5.1lf%s Max,", - "GPRINT:rx_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:rx_avg_sum:LAST:(ca. %4.0lf%s Total)" - }, - - if_rx_errors = { - "-v", "Errors/s", - "DEF:min={file}:value:MIN", - "DEF:avg={file}:value:AVERAGE", - "DEF:max={file}:value:MAX", - "CDEF:mytime=avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg,UN,0,avg,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":Errors/s", - "GPRINT:avg:AVERAGE:%3.1lf%s Avg,", - "GPRINT:max:MAX:%3.1lf%s Max,", - "GPRINT:avg:LAST:%3.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %2.0lf%s Total)" - }, - - ipt_bytes = { - "-v", "Bits/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "CDEF:mytime=avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:avg_sample=avg_raw,UN,0,avg_raw,IF,sample_len,*", - "CDEF:avg_sum=PREV,UN,0,PREV,IF,avg_sample,+", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bits/s", - #"GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l", - "GPRINT:avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - ipt_packets = { - "-v", "Packets/s", - "DEF:min_raw={file}:value:MIN", - "DEF:avg_raw={file}:value:AVERAGE", - "DEF:max_raw={file}:value:MAX", - "CDEF:min=min_raw,8,*", - "CDEF:avg=avg_raw,8,*", - "CDEF:max=max_raw,8,*", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Packets/s", - "GPRINT:min:MIN:%5.1lf %s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - irq = { - "-v", "Issues/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - load = { - "-v", "System load", - "DEF:s_avg={file}:shortterm:AVERAGE", - "DEF:s_min={file}:shortterm:MIN", - "DEF:s_max={file}:shortterm:MAX", - "DEF:m_avg={file}:midterm:AVERAGE", - "DEF:m_min={file}:midterm:MIN", - "DEF:m_max={file}:midterm:MAX", - "DEF:l_avg={file}:longterm:AVERAGE", - "DEF:l_min={file}:longterm:MIN", - "DEF:l_max={file}:longterm:MAX", - "AREA:s_max#" .. self.palette.HalfGreen, - "AREA:s_min#" .. self.palette.Canvas, - "LINE1:s_avg#" .. self.palette.FullGreen .. ": 1m average", - "GPRINT:s_min:MIN:%4.2lf Min,", - "GPRINT:s_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:s_max:MAX:%4.2lf Max,", - "GPRINT:s_avg:LAST:%4.2lf Last\n", - "LINE1:m_avg#" .. self.palette.FullBlue .. ": 5m average", - "GPRINT:m_min:MIN:%4.2lf Min,", - "GPRINT:m_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:m_max:MAX:%4.2lf Max,", - "GPRINT:m_avg:LAST:%4.2lf Last\n", - "LINE1:l_avg#" .. self.palette.FullRed .. ":15m average", - "GPRINT:l_min:MIN:%4.2lf Min,", - "GPRINT:l_avg:AVERAGE:%4.2lf Avg,", - "GPRINT:l_max:MAX:%4.2lf Max,", - "GPRINT:l_avg:LAST:%4.2lf Last\\l" - }, - - load_percent = { - "DEF:avg={file}:percent:AVERAGE", - "DEF:min={file}:percent:MIN", - "DEF:max={file}:percent:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Load", - "GPRINT:min:MIN:%5.1lf%s%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", - "GPRINT:max:MAX:%5.1lf%s%% Max,", - "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" - }, - - mails = { - "DEF:rawgood={file}:good:AVERAGE", - "DEF:rawspam={file}:spam:AVERAGE", - "CDEF:good=rawgood,UN,0,rawgood,IF", - "CDEF:spam=rawspam,UN,0,rawspam,IF", - "CDEF:negspam=spam,-1,*", - "AREA:good#" .. self.palette.HalfGreen, - "LINE1:good#" .. self.palette.FullGreen .. ":Good mails", - "GPRINT:good:AVERAGE:%4.1lf Avg,", - "GPRINT:good:MAX:%4.1lf Max,", - "GPRINT:good:LAST:%4.1lf Last\n", - "AREA:negspam#" .. self.palette.HalfRed, - "LINE1:negspam#" .. self.palette.FullRed .. ":Spam mails", - "GPRINT:spam:AVERAGE:%4.1lf Avg,", - "GPRINT:spam:MAX:%4.1lf Max,", - "GPRINT:spam:LAST:%4.1lf Last\\l", - "HRULE:0#000000" - }, - - memory = { - "-b", "1024", "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Memory", - "GPRINT:min:MIN:%5.1lf%sbyte Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sbyte Avg,", - "GPRINT:max:MAX:%5.1lf%sbyte Max,", - "GPRINT:avg:LAST:%5.1lf%sbyte Last\\l" - }, - - old_memory = { - "DEF:used_avg={file}:used:AVERAGE", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:buffers_avg={file}:buffers:AVERAGE", - "DEF:cached_avg={file}:cached:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:free_min={file}:free:MIN", - "DEF:buffers_min={file}:buffers:MIN", - "DEF:cached_min={file}:cached:MIN", - "DEF:used_max={file}:used:MAX", - "DEF:free_max={file}:free:MAX", - "DEF:buffers_max={file}:buffers:MAX", - "DEF:cached_max={file}:cached:MAX", - "CDEF:cached_avg_nn=cached_avg,UN,0,cached_avg,IF", - "CDEF:buffers_avg_nn=buffers_avg,UN,0,buffers_avg,IF", - "CDEF:free_cached_buffers_used=free_avg,cached_avg_nn,+,buffers_avg_nn,+,used_avg,+", - "CDEF:cached_buffers_used=cached_avg,buffers_avg_nn,+,used_avg,+", - "CDEF:buffers_used=buffers_avg,used_avg,+", - "AREA:free_cached_buffers_used#" .. self.palette.HalfGreen, - "AREA:cached_buffers_used#" .. self.palette.HalfBlue, - "AREA:buffers_used#" .. self.palette.HalfYellow, - "AREA:used_avg#" .. self.palette.HalfRed, - "LINE1:free_cached_buffers_used#" .. self.palette.FullGreen .. ":Free ", - "GPRINT:free_min:MIN:%5.1lf%s Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:free_max:MAX:%5.1lf%s Max,", - "GPRINT:free_avg:LAST:%5.1lf%s Last\n", - "LINE1:cached_buffers_used#" .. self.palette.FullBlue .. ":Page cache ", - "GPRINT:cached_min:MIN:%5.1lf%s Min,", - "GPRINT:cached_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cached_max:MAX:%5.1lf%s Max,", - "GPRINT:cached_avg:LAST:%5.1lf%s Last\n", - "LINE1:buffers_used#" .. self.palette.FullYellow .. ":Buffer cache", - "GPRINT:buffers_min:MIN:%5.1lf%s Min,", - "GPRINT:buffers_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:buffers_max:MAX:%5.1lf%s Max,", - "GPRINT:buffers_avg:LAST:%5.1lf%s Last\n", - "LINE1:used_avg#" .. self.palette.FullRed .. ":Used ", - "GPRINT:used_min:MIN:%5.1lf%s Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:used_max:MAX:%5.1lf%s Max,", - "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" - }, - - mysql_commands = { - "-v", "Issues/s", - "DEF:val_avg={file}:value:AVERAGE", - "DEF:val_min={file}:value:MIN", - "DEF:val_max={file}:value:MAX", - "AREA:val_max#" .. self.palette.HalfBlue, - "AREA:val_min#" .. self.palette.Canvas, - "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:val_min:MIN:%5.2lf Min,", - "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:val_max:MAX:%5.2lf Max,", - "GPRINT:val_avg:LAST:%5.2lf Last\\l" - }, - - mysql_handler = { - "-v", "Issues/s", - "DEF:val_avg={file}:value:AVERAGE", - "DEF:val_min={file}:value:MIN", - "DEF:val_max={file}:value:MAX", - "AREA:val_max#" .. self.palette.HalfBlue, - "AREA:val_min#" .. self.palette.Canvas, - "LINE1:val_avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:val_min:MIN:%5.2lf Min,", - "GPRINT:val_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:val_max:MAX:%5.2lf Max,", - "GPRINT:val_avg:LAST:%5.2lf Last\\l" - }, - - mysql_octets = { - "-v", "Bits/s", - "DEF:out_min={file}:tx:MIN", - "DEF:out_avg={file}:tx:AVERAGE", - "DEF:out_max={file}:tx:MAX", - "DEF:inc_min={file}:rx:MIN", - "DEF:inc_avg={file}:rx:AVERAGE", - "DEF:inc_max={file}:rx:MAX", - "CDEF:mytime=out_avg,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg,UN,0,out_avg,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg,UN,0,inc_avg,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "CDEF:out_bit_min=out_min,8,*", - "CDEF:out_bit_avg=out_avg,8,*", - "CDEF:out_bit_max=out_max,8,*", - "CDEF:inc_bit_min=inc_min,8,*", - "CDEF:inc_bit_avg=inc_avg,8,*", - "CDEF:inc_bit_max=inc_max,8,*", - "CDEF:overlap=out_bit_avg,inc_bit_avg,GT,inc_bit_avg,out_bit_avg,IF", - "AREA:out_bit_avg#" .. self.palette.HalfGreen, - "AREA:inc_bit_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_bit_avg#" .. self.palette.FullGreen .. ":Written", - "GPRINT:out_bit_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_bit_max:MAX:%5.1lf%s Max,", - "GPRINT:out_bit_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)", - "LINE1:inc_bit_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:inc_bit_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_bit_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_bit_avg:LAST:%5.1lf%s Last\\l", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)" - }, - - mysql_qcache = { - "-v", "Queries/s", - "DEF:hits_min={file}:hits:MIN", - "DEF:hits_avg={file}:hits:AVERAGE", - "DEF:hits_max={file}:hits:MAX", - "DEF:inserts_min={file}:inserts:MIN", - "DEF:inserts_avg={file}:inserts:AVERAGE", - "DEF:inserts_max={file}:inserts:MAX", - "DEF:not_cached_min={file}:not_cached:MIN", - "DEF:not_cached_avg={file}:not_cached:AVERAGE", - "DEF:not_cached_max={file}:not_cached:MAX", - "DEF:lowmem_prunes_min={file}:lowmem_prunes:MIN", - "DEF:lowmem_prunes_avg={file}:lowmem_prunes:AVERAGE", - "DEF:lowmem_prunes_max={file}:lowmem_prunes:MAX", - "DEF:queries_min={file}:queries_in_cache:MIN", - "DEF:queries_avg={file}:queries_in_cache:AVERAGE", - "DEF:queries_max={file}:queries_in_cache:MAX", - "CDEF:unknown=queries_avg,UNKN,+", - "CDEF:not_cached_agg=hits_avg,inserts_avg,+,not_cached_avg,+", - "CDEF:inserts_agg=hits_avg,inserts_avg,+", - "CDEF:hits_agg=hits_avg", - "AREA:not_cached_agg#" .. self.palette.HalfYellow, - "AREA:inserts_agg#" .. self.palette.HalfBlue, - "AREA:hits_agg#" .. self.palette.HalfGreen, - "LINE1:not_cached_agg#" .. self.palette.FullYellow .. ":Not Cached ", - "GPRINT:not_cached_min:MIN:%5.2lf Min,", - "GPRINT:not_cached_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:not_cached_max:MAX:%5.2lf Max,", - "GPRINT:not_cached_avg:LAST:%5.2lf Last\\l", - "LINE1:inserts_agg#" .. self.palette.FullBlue .. ":Inserts ", - "GPRINT:inserts_min:MIN:%5.2lf Min,", - "GPRINT:inserts_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:inserts_max:MAX:%5.2lf Max,", - "GPRINT:inserts_avg:LAST:%5.2lf Last\\l", - "LINE1:hits_agg#" .. self.palette.FullGreen .. ":Hits ", - "GPRINT:hits_min:MIN:%5.2lf Min,", - "GPRINT:hits_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:hits_max:MAX:%5.2lf Max,", - "GPRINT:hits_avg:LAST:%5.2lf Last\\l", - "LINE1:lowmem_prunes_avg#" .. self.palette.FullRed .. ":Lowmem Prunes ", - "GPRINT:lowmem_prunes_min:MIN:%5.2lf Min,", - "GPRINT:lowmem_prunes_avg:AVERAGE:%5.2lf Avg,", - "GPRINT:lowmem_prunes_max:MAX:%5.2lf Max,", - "GPRINT:lowmem_prunes_avg:LAST:%5.2lf Last\\l", - "LINE1:unknown#" .. self.palette.Canvas .. ":Queries in cache", - "GPRINT:queries_min:MIN:%5.0lf Min,", - "GPRINT:queries_avg:AVERAGE:%5.0lf Avg,", - "GPRINT:queries_max:MAX:%5.0lf Max,", - "GPRINT:queries_avg:LAST:%5.0lf Last\\l" - }, - - mysql_threads = { - "-v", "Threads", - "DEF:running_min={file}:running:MIN", - "DEF:running_avg={file}:running:AVERAGE", - "DEF:running_max={file}:running:MAX", - "DEF:connected_min={file}:connected:MIN", - "DEF:connected_avg={file}:connected:AVERAGE", - "DEF:connected_max={file}:connected:MAX", - "DEF:cached_min={file}:cached:MIN", - "DEF:cached_avg={file}:cached:AVERAGE", - "DEF:cached_max={file}:cached:MAX", - "DEF:created_min={file}:created:MIN", - "DEF:created_avg={file}:created:AVERAGE", - "DEF:created_max={file}:created:MAX", - "CDEF:unknown=created_avg,UNKN,+", - "CDEF:cached_agg=connected_avg,cached_avg,+", - "AREA:cached_agg#" .. self.palette.HalfGreen, - "AREA:connected_avg#" .. self.palette.HalfBlue, - "AREA:running_avg#" .. self.palette.HalfRed, - "LINE1:cached_agg#" .. self.palette.FullGreen .. ":Cached ", - "GPRINT:cached_min:MIN:%5.1lf Min,", - "GPRINT:cached_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:cached_max:MAX:%5.1lf Max,", - "GPRINT:cached_avg:LAST:%5.1lf Last\\l", - "LINE1:connected_avg#" .. self.palette.FullBlue .. ":Connected", - "GPRINT:connected_min:MIN:%5.1lf Min,", - "GPRINT:connected_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:connected_max:MAX:%5.1lf Max,", - "GPRINT:connected_avg:LAST:%5.1lf Last\\l", - "LINE1:running_avg#" .. self.palette.FullRed .. ":Running ", - "GPRINT:running_min:MIN:%5.1lf Min,", - "GPRINT:running_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:running_max:MAX:%5.1lf Max,", - "GPRINT:running_avg:LAST:%5.1lf Last\\l", - "LINE1:unknown#" .. self.palette.Canvas .. ":Created ", - "GPRINT:created_min:MIN:%5.0lf Min,", - "GPRINT:created_avg:AVERAGE:%5.0lf Avg,", - "GPRINT:created_max:MAX:%5.0lf Max,", - "GPRINT:created_avg:LAST:%5.0lf Last\\l" - }, - - nfs_procedure = { - "-v", "Issues/s", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Issues/s", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - nfs3_procedures = { - "DEF:null_avg={file}:null:AVERAGE", - "DEF:getattr_avg={file}:getattr:AVERAGE", - "DEF:setattr_avg={file}:setattr:AVERAGE", - "DEF:lookup_avg={file}:lookup:AVERAGE", - "DEF:access_avg={file}:access:AVERAGE", - "DEF:readlink_avg={file}:readlink:AVERAGE", - "DEF:read_avg={file}:read:AVERAGE", - "DEF:write_avg={file}:write:AVERAGE", - "DEF:create_avg={file}:create:AVERAGE", - "DEF:mkdir_avg={file}:mkdir:AVERAGE", - "DEF:symlink_avg={file}:symlink:AVERAGE", - "DEF:mknod_avg={file}:mknod:AVERAGE", - "DEF:remove_avg={file}:remove:AVERAGE", - "DEF:rmdir_avg={file}:rmdir:AVERAGE", - "DEF:rename_avg={file}:rename:AVERAGE", - "DEF:link_avg={file}:link:AVERAGE", - "DEF:readdir_avg={file}:readdir:AVERAGE", - "DEF:readdirplus_avg={file}:readdirplus:AVERAGE", - "DEF:fsstat_avg={file}:fsstat:AVERAGE", - "DEF:fsinfo_avg={file}:fsinfo:AVERAGE", - "DEF:pathconf_avg={file}:pathconf:AVERAGE", - "DEF:commit_avg={file}:commit:AVERAGE", - "DEF:null_max={file}:null:MAX", - "DEF:getattr_max={file}:getattr:MAX", - "DEF:setattr_max={file}:setattr:MAX", - "DEF:lookup_max={file}:lookup:MAX", - "DEF:access_max={file}:access:MAX", - "DEF:readlink_max={file}:readlink:MAX", - "DEF:read_max={file}:read:MAX", - "DEF:write_max={file}:write:MAX", - "DEF:create_max={file}:create:MAX", - "DEF:mkdir_max={file}:mkdir:MAX", - "DEF:symlink_max={file}:symlink:MAX", - "DEF:mknod_max={file}:mknod:MAX", - "DEF:remove_max={file}:remove:MAX", - "DEF:rmdir_max={file}:rmdir:MAX", - "DEF:rename_max={file}:rename:MAX", - "DEF:link_max={file}:link:MAX", - "DEF:readdir_max={file}:readdir:MAX", - "DEF:readdirplus_max={file}:readdirplus:MAX", - "DEF:fsstat_max={file}:fsstat:MAX", - "DEF:fsinfo_max={file}:fsinfo:MAX", - "DEF:pathconf_max={file}:pathconf:MAX", - "DEF:commit_max={file}:commit:MAX", - "CDEF:other_avg=null_avg,readlink_avg,create_avg,mkdir_avg,symlink_avg,mknod_avg,remove_avg,rmdir_avg,rename_avg,link_avg,readdir_avg,readdirplus_avg,fsstat_avg,fsinfo_avg,pathconf_avg,+,+,+,+,+,+,+,+,+,+,+,+,+,+", - "CDEF:other_max=null_max,readlink_max,create_max,mkdir_max,symlink_max,mknod_max,remove_max,rmdir_max,rename_max,link_max,readdir_max,readdirplus_max,fsstat_max,fsinfo_max,pathconf_max,+,+,+,+,+,+,+,+,+,+,+,+,+,+", - "CDEF:stack_read=read_avg", - "CDEF:stack_getattr=stack_read,getattr_avg,+", - "CDEF:stack_access=stack_getattr,access_avg,+", - "CDEF:stack_lookup=stack_access,lookup_avg,+", - "CDEF:stack_write=stack_lookup,write_avg,+", - "CDEF:stack_commit=stack_write,commit_avg,+", - "CDEF:stack_setattr=stack_commit,setattr_avg,+", - "CDEF:stack_other=stack_setattr,other_avg,+", - "AREA:stack_other#" .. self.palette.HalfRed, - "AREA:stack_setattr#" .. self.palette.HalfGreen, - "AREA:stack_commit#" .. self.palette.HalfYellow, - "AREA:stack_write#" .. self.palette.HalfGreen, - "AREA:stack_lookup#" .. self.palette.HalfBlue, - "AREA:stack_access#" .. self.palette.HalfMagenta, - "AREA:stack_getattr#" .. self.palette.HalfCyan, - "AREA:stack_read#" .. self.palette.HalfBlue, - "LINE1:stack_other#" .. self.palette.FullRed .. ":Other ", - "GPRINT:other_max:MAX:%5.1lf Max,", - "GPRINT:other_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:other_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_setattr#" .. self.palette.FullGreen .. ":setattr", - "GPRINT:setattr_max:MAX:%5.1lf Max,", - "GPRINT:setattr_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:setattr_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_commit#" .. self.palette.FullYellow .. ":commit ", - "GPRINT:commit_max:MAX:%5.1lf Max,", - "GPRINT:commit_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:commit_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_write#" .. self.palette.FullGreen .. ":write ", - "GPRINT:write_max:MAX:%5.1lf Max,", - "GPRINT:write_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:write_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_lookup#" .. self.palette.FullBlue .. ":lookup ", - "GPRINT:lookup_max:MAX:%5.1lf Max,", - "GPRINT:lookup_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:lookup_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_access#" .. self.palette.FullMagenta .. ":access ", - "GPRINT:access_max:MAX:%5.1lf Max,", - "GPRINT:access_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:access_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_getattr#" .. self.palette.FullCyan .. ":getattr", - "GPRINT:getattr_max:MAX:%5.1lf Max,", - "GPRINT:getattr_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:getattr_avg:LAST:%5.1lf Last\\l", - "LINE1:stack_read#" .. self.palette.FullBlue .. ":read ", - "GPRINT:read_max:MAX:%5.1lf Max,", - "GPRINT:read_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:read_avg:LAST:%5.1lf Last\\l" - }, - - partition = { - "DEF:rbyte_avg={file}:rbytes:AVERAGE", - "DEF:rbyte_min={file}:rbytes:MIN", - "DEF:rbyte_max={file}:rbytes:MAX", - "DEF:wbyte_avg={file}:wbytes:AVERAGE", - "DEF:wbyte_min={file}:wbytes:MIN", - "DEF:wbyte_max={file}:wbytes:MAX", - "CDEF:overlap=wbyte_avg,rbyte_avg,GT,rbyte_avg,wbyte_avg,IF", - "AREA:wbyte_avg#" .. self.palette.HalfGreen, - "AREA:rbyte_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:wbyte_avg#" .. self.palette.FullGreen .. ":Write", - "GPRINT:wbyte_min:MIN:%5.1lf%s Min,", - "GPRINT:wbyte_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:wbyte_max:MAX:%5.1lf%s Max,", - "GPRINT:wbyte_avg:LAST:%5.1lf%s Last\\l", - "LINE1:rbyte_avg#" .. self.palette.FullBlue .. ":Read ", - "GPRINT:rbyte_min:MIN:%5.1lf%s Min,", - "GPRINT:rbyte_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:rbyte_max:MAX:%5.1lf%s Max,", - "GPRINT:rbyte_avg:LAST:%5.1lf%s Last\\l" - }, - - percent = { - "-v", "Percent", - "DEF:avg={file}:percent:AVERAGE", - "DEF:min={file}:percent:MIN", - "DEF:max={file}:percent:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Percent", - "GPRINT:min:MIN:%5.1lf%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%% Avg,", - "GPRINT:max:MAX:%5.1lf%% Max,", - "GPRINT:avg:LAST:%5.1lf%% Last\\l" - }, - - ping = { - "DEF:ping_avg={file}:ping:AVERAGE", - "DEF:ping_min={file}:ping:MIN", - "DEF:ping_max={file}:ping:MAX", - "AREA:ping_max#" .. self.palette.HalfBlue, - "AREA:ping_min#" .. self.palette.Canvas, - "LINE1:ping_avg#" .. self.palette.FullBlue .. ":Ping", - "GPRINT:ping_min:MIN:%4.1lf ms Min,", - "GPRINT:ping_avg:AVERAGE:%4.1lf ms Avg,", - "GPRINT:ping_max:MAX:%4.1lf ms Max,", - "GPRINT:ping_avg:LAST:%4.1lf ms Last\\l" - }, - - power = { - "-v", "Watt", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Watt", - "GPRINT:min:MIN:%5.1lf%sW Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sW Avg,", - "GPRINT:max:MAX:%5.1lf%sW Max,", - "GPRINT:avg:LAST:%5.1lf%sW Last\\l" - }, - - processes = { - "DEF:running_avg={file}:running:AVERAGE", - "DEF:running_min={file}:running:MIN", - "DEF:running_max={file}:running:MAX", - "DEF:sleeping_avg={file}:sleeping:AVERAGE", - "DEF:sleeping_min={file}:sleeping:MIN", - "DEF:sleeping_max={file}:sleeping:MAX", - "DEF:zombies_avg={file}:zombies:AVERAGE", - "DEF:zombies_min={file}:zombies:MIN", - "DEF:zombies_max={file}:zombies:MAX", - "DEF:stopped_avg={file}:stopped:AVERAGE", - "DEF:stopped_min={file}:stopped:MIN", - "DEF:stopped_max={file}:stopped:MAX", - "DEF:paging_avg={file}:paging:AVERAGE", - "DEF:paging_min={file}:paging:MIN", - "DEF:paging_max={file}:paging:MAX", - "DEF:blocked_avg={file}:blocked:AVERAGE", - "DEF:blocked_min={file}:blocked:MIN", - "DEF:blocked_max={file}:blocked:MAX", - "CDEF:paging_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,paging_avg,+,+,+,+,+", - "CDEF:blocked_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,blocked_avg,+,+,+,+", - "CDEF:zombies_acc=sleeping_avg,running_avg,stopped_avg,zombies_avg,+,+,+", - "CDEF:stopped_acc=sleeping_avg,running_avg,stopped_avg,+,+", - "CDEF:running_acc=sleeping_avg,running_avg,+", - "CDEF:sleeping_acc=sleeping_avg", - "AREA:paging_acc#" .. self.palette.HalfYellow, - "AREA:blocked_acc#" .. self.palette.HalfCyan, - "AREA:zombies_acc#" .. self.palette.HalfRed, - "AREA:stopped_acc#" .. self.palette.HalfMagenta, - "AREA:running_acc#" .. self.palette.HalfGreen, - "AREA:sleeping_acc#" .. self.palette.HalfBlue, - "LINE1:paging_acc#" .. self.palette.FullYellow .. ":Paging ", - "GPRINT:paging_min:MIN:%5.1lf Min,", - "GPRINT:paging_avg:AVERAGE:%5.1lf Average,", - "GPRINT:paging_max:MAX:%5.1lf Max,", - "GPRINT:paging_avg:LAST:%5.1lf Last\\l", - "LINE1:blocked_acc#" .. self.palette.FullCyan .. ":Blocked ", - "GPRINT:blocked_min:MIN:%5.1lf Min,", - "GPRINT:blocked_avg:AVERAGE:%5.1lf Average,", - "GPRINT:blocked_max:MAX:%5.1lf Max,", - "GPRINT:blocked_avg:LAST:%5.1lf Last\\l", - "LINE1:zombies_acc#" .. self.palette.FullRed .. ":Zombies ", - "GPRINT:zombies_min:MIN:%5.1lf Min,", - "GPRINT:zombies_avg:AVERAGE:%5.1lf Average,", - "GPRINT:zombies_max:MAX:%5.1lf Max,", - "GPRINT:zombies_avg:LAST:%5.1lf Last\\l", - "LINE1:stopped_acc#" .. self.palette.FullMagenta .. ":Stopped ", - "GPRINT:stopped_min:MIN:%5.1lf Min,", - "GPRINT:stopped_avg:AVERAGE:%5.1lf Average,", - "GPRINT:stopped_max:MAX:%5.1lf Max,", - "GPRINT:stopped_avg:LAST:%5.1lf Last\\l", - "LINE1:running_acc#" .. self.palette.FullGreen .. ":Running ", - "GPRINT:running_min:MIN:%5.1lf Min,", - "GPRINT:running_avg:AVERAGE:%5.1lf Average,", - "GPRINT:running_max:MAX:%5.1lf Max,", - "GPRINT:running_avg:LAST:%5.1lf Last\\l", - "LINE1:sleeping_acc#" .. self.palette.FullBlue .. ":Sleeping", - "GPRINT:sleeping_min:MIN:%5.1lf Min,", - "GPRINT:sleeping_avg:AVERAGE:%5.1lf Average,", - "GPRINT:sleeping_max:MAX:%5.1lf Max,", - "GPRINT:sleeping_avg:LAST:%5.1lf Last\\l" - }, - - ps_count = { - "-v", "Processes", - "DEF:procs_avg={file}:processes:AVERAGE", - "DEF:procs_min={file}:processes:MIN", - "DEF:procs_max={file}:processes:MAX", - "DEF:thrds_avg={file}:threads:AVERAGE", - "DEF:thrds_min={file}:threads:MIN", - "DEF:thrds_max={file}:threads:MAX", - "AREA:thrds_avg#" .. self.palette.HalfBlue, - "AREA:procs_avg#" .. self.palette.HalfRed, - "LINE1:thrds_avg#" .. self.palette.FullBlue .. ":Threads ", - "GPRINT:thrds_min:MIN:%5.1lf Min,", - "GPRINT:thrds_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:thrds_max:MAX:%5.1lf Max,", - "GPRINT:thrds_avg:LAST:%5.1lf Last\\l", - "LINE1:procs_avg#" .. self.palette.FullRed .. ":Processes", - "GPRINT:procs_min:MIN:%5.1lf Min,", - "GPRINT:procs_avg:AVERAGE:%5.1lf Avg,", - "GPRINT:procs_max:MAX:%5.1lf Max,", - "GPRINT:procs_avg:LAST:%5.1lf Last\\l" - }, - - ps_cputime = { - "-v", "Jiffies", - "DEF:user_avg_raw={file}:user:AVERAGE", - "DEF:user_min_raw={file}:user:MIN", - "DEF:user_max_raw={file}:user:MAX", - "DEF:syst_avg_raw={file}:syst:AVERAGE", - "DEF:syst_min_raw={file}:syst:MIN", - "DEF:syst_max_raw={file}:syst:MAX", - "CDEF:user_avg=user_avg_raw,1000000,/", - "CDEF:user_min=user_min_raw,1000000,/", - "CDEF:user_max=user_max_raw,1000000,/", - "CDEF:syst_avg=syst_avg_raw,1000000,/", - "CDEF:syst_min=syst_min_raw,1000000,/", - "CDEF:syst_max=syst_max_raw,1000000,/", - "CDEF:user_syst=syst_avg,UN,0,syst_avg,IF,user_avg,+", - "AREA:user_syst#" .. self.palette.HalfBlue, - "AREA:syst_avg#" .. self.palette.HalfRed, - "LINE1:user_syst#" .. self.palette.FullBlue .. ":User ", - "GPRINT:user_min:MIN:%5.1lf%s Min,", - "GPRINT:user_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:user_max:MAX:%5.1lf%s Max,", - "GPRINT:user_avg:LAST:%5.1lf%s Last\\l", - "LINE1:syst_avg#" .. self.palette.FullRed .. ":System", - "GPRINT:syst_min:MIN:%5.1lf%s Min,", - "GPRINT:syst_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:syst_max:MAX:%5.1lf%s Max,", - "GPRINT:syst_avg:LAST:%5.1lf%s Last\\l" - }, - - ps_pagefaults = { - "-v", "Pagefaults/s", - "DEF:minor_avg={file}:minflt:AVERAGE", - "DEF:minor_min={file}:minflt:MIN", - "DEF:minor_max={file}:minflt:MAX", - "DEF:major_avg={file}:majflt:AVERAGE", - "DEF:major_min={file}:majflt:MIN", - "DEF:major_max={file}:majflt:MAX", - "CDEF:minor_major=major_avg,UN,0,major_avg,IF,minor_avg,+", - "AREA:minor_major#" .. self.palette.HalfBlue, - "AREA:major_avg#" .. self.palette.HalfRed, - "LINE1:minor_major#" .. self.palette.FullBlue .. ":Minor", - "GPRINT:minor_min:MIN:%5.1lf%s Min,", - "GPRINT:minor_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:minor_max:MAX:%5.1lf%s Max,", - "GPRINT:minor_avg:LAST:%5.1lf%s Last\\l", - "LINE1:major_avg#" .. self.palette.FullRed .. ":Major", - "GPRINT:major_min:MIN:%5.1lf%s Min,", - "GPRINT:major_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:major_max:MAX:%5.1lf%s Max,", - "GPRINT:major_avg:LAST:%5.1lf%s Last\\l" - }, - - ps_rss = { - "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:avg#" .. self.palette.HalfBlue, - "LINE1:avg#" .. self.palette.FullBlue .. ":RSS", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - ps_state = { - "-v", "Processes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%6.2lf Min,", - "GPRINT:avg:AVERAGE:%6.2lf Avg,", - "GPRINT:max:MAX:%6.2lf Max,", - "GPRINT:avg:LAST:%6.2lf Last\\l" - }, - - signal_noise = { - "-v", "dBm", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Noise", - "GPRINT:min:MIN:%5.1lf%sdBm Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", - "GPRINT:max:MAX:%5.1lf%sdBm Max,", - "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" - }, - - signal_power = { - "-v", "dBm", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Power", - "GPRINT:min:MIN:%5.1lf%sdBm Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sdBm Avg,", - "GPRINT:max:MAX:%5.1lf%sdBm Max,", - "GPRINT:avg:LAST:%5.1lf%sdBm Last\\l" - }, - - signal_quality = { - "-v", "%", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Quality", - "GPRINT:min:MIN:%5.1lf%s%% Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s%% Avg,", - "GPRINT:max:MAX:%5.1lf%s%% Max,", - "GPRINT:avg:LAST:%5.1lf%s%% Last\\l" - }, - - swap = { - "-v", "Bytes", "-b", "1024", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Bytes", - "GPRINT:min:MIN:%6.2lf%sByte Min,", - "GPRINT:avg:AVERAGE:%6.2lf%sByte Avg,", - "GPRINT:max:MAX:%6.2lf%sByte Max,", - "GPRINT:avg:LAST:%6.2lf%sByte Last\\l" - }, - - old_swap = { - "DEF:used_avg={file}:used:AVERAGE", - "DEF:used_min={file}:used:MIN", - "DEF:used_max={file}:used:MAX", - "DEF:free_avg={file}:free:AVERAGE", - "DEF:free_min={file}:free:MIN", - "DEF:free_max={file}:free:MAX", - "DEF:cach_avg={file}:cached:AVERAGE", - "DEF:cach_min={file}:cached:MIN", - "DEF:cach_max={file}:cached:MAX", - "DEF:resv_avg={file}:resv:AVERAGE", - "DEF:resv_min={file}:resv:MIN", - "DEF:resv_max={file}:resv:MAX", - "CDEF:cach_avg_notnull=cach_avg,UN,0,cach_avg,IF", - "CDEF:resv_avg_notnull=resv_avg,UN,0,resv_avg,IF", - "CDEF:used_acc=used_avg", - "CDEF:resv_acc=used_acc,resv_avg_notnull,+", - "CDEF:cach_acc=resv_acc,cach_avg_notnull,+", - "CDEF:free_acc=cach_acc,free_avg,+", - "AREA:free_acc#" .. self.palette.HalfGreen, - "AREA:cach_acc#" .. self.palette.HalfBlue, - "AREA:resv_acc#" .. self.palette.HalfYellow, - "AREA:used_acc#" .. self.palette.HalfRed, - "LINE1:free_acc#" .. self.palette.FullGreen .. ":Free ", - "GPRINT:free_min:MIN:%5.1lf%s Min,", - "GPRINT:free_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:free_max:MAX:%5.1lf%s Max,", - "GPRINT:free_avg:LAST:%5.1lf%s Last\n", - "LINE1:cach_acc#" .. self.palette.FullBlue .. ":Cached ", - "GPRINT:cach_min:MIN:%5.1lf%s Min,", - "GPRINT:cach_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cach_max:MAX:%5.1lf%s Max,", - "GPRINT:cach_avg:LAST:%5.1lf%s Last\\l", - "LINE1:resv_acc#" .. self.palette.FullYellow .. ":Reserved", - "GPRINT:resv_min:MIN:%5.1lf%s Min,", - "GPRINT:resv_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:resv_max:MAX:%5.1lf%s Max,", - "GPRINT:resv_avg:LAST:%5.1lf%s Last\n", - "LINE1:used_acc#" .. self.palette.FullRed .. ":Used ", - "GPRINT:used_min:MIN:%5.1lf%s Min,", - "GPRINT:used_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:used_max:MAX:%5.1lf%s Max,", - "GPRINT:used_avg:LAST:%5.1lf%s Last\\l" - }, - - tcp_connections = { - "-v", "Connections", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Connections", - "GPRINT:min:MIN:%4.1lf Min,", - "GPRINT:avg:AVERAGE:%4.1lf Avg,", - "GPRINT:max:MAX:%4.1lf Max,", - "GPRINT:avg:LAST:%4.1lf Last\\l" - }, - - temperature = { - "-v", "Celsius", - "DEF:temp_avg={file}:value:AVERAGE", - "DEF:temp_min={file}:value:MIN", - "DEF:temp_max={file}:value:MAX", - "CDEF:average=temp_avg,0.2,*,PREV,UN,temp_avg,PREV,IF,0.8,*,+", - "AREA:temp_max#" .. self.palette.HalfRed, - "AREA:temp_min#" .. self.palette.Canvas, - "LINE1:temp_avg#" .. self.palette.FullRed .. ":Temperature", - "GPRINT:temp_min:MIN:%4.1lf Min,", - "GPRINT:temp_avg:AVERAGE:%4.1lf Avg,", - "GPRINT:temp_max:MAX:%4.1lf Max,", - "GPRINT:temp_avg:LAST:%4.1lf Last\\l" - }, - - timeleft = { - "-v", "Minutes", - "DEF:avg={file}:timeleft:AVERAGE", - "DEF:min={file}:timeleft:MIN", - "DEF:max={file}:timeleft:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Time left [min]", - "GPRINT:min:MIN:%5.1lf%s Min,", - "GPRINT:avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:max:MAX:%5.1lf%s Max,", - "GPRINT:avg:LAST:%5.1lf%s Last\\l" - }, - - time_offset = { - "DEF:s_avg={file}:seconds:AVERAGE", - "DEF:s_min={file}:seconds:MIN", - "DEF:s_max={file}:seconds:MAX", - "AREA:s_max#" .. self.palette.HalfBlue, - "AREA:s_min#" .. self.palette.Canvas, - "LINE1:s_avg#" .. self.palette.FullBlue .. ":{inst}", - "GPRINT:s_min:MIN:%7.3lf%s Min,", - "GPRINT:s_avg:AVERAGE:%7.3lf%s Avg,", - "GPRINT:s_max:MAX:%7.3lf%s Max,", - "GPRINT:s_avg:LAST:%7.3lf%s Last\\l" - }, - - if_octets = { - "-v", "Bits/s", "-l", "0", - "DEF:out_min_raw={file}:tx:MIN", - "DEF:out_avg_raw={file}:tx:AVERAGE", - "DEF:out_max_raw={file}:tx:MAX", - "DEF:inc_min_raw={file}:rx:MIN", - "DEF:inc_avg_raw={file}:rx:AVERAGE", - "DEF:inc_max_raw={file}:rx:MAX", - "CDEF:out_min=out_min_raw,8,*", - "CDEF:out_avg=out_avg_raw,8,*", - "CDEF:out_max=out_max_raw,8,*", - "CDEF:inc_min=inc_min_raw,8,*", - "CDEF:inc_avg=inc_avg_raw,8,*", - "CDEF:inc_max=inc_max_raw,8,*", - "CDEF:overlap=out_avg,inc_avg,GT,inc_avg,out_avg,IF", - "CDEF:mytime=out_avg_raw,TIME,TIME,IF", - "CDEF:sample_len_raw=mytime,PREV(mytime),-", - "CDEF:sample_len=sample_len_raw,UN,0,sample_len_raw,IF", - "CDEF:out_avg_sample=out_avg_raw,UN,0,out_avg_raw,IF,sample_len,*", - "CDEF:out_avg_sum=PREV,UN,0,PREV,IF,out_avg_sample,+", - "CDEF:inc_avg_sample=inc_avg_raw,UN,0,inc_avg_raw,IF,sample_len,*", - "CDEF:inc_avg_sum=PREV,UN,0,PREV,IF,inc_avg_sample,+", - "AREA:out_avg#" .. self.palette.HalfGreen, - "AREA:inc_avg#" .. self.palette.HalfBlue, - "AREA:overlap#" .. self.palette.HalfBlueGreen, - "LINE1:out_avg#" .. self.palette.FullGreen .. ":Outgoing", - "GPRINT:out_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:out_max:MAX:%5.1lf%s Max,", - "GPRINT:out_avg:LAST:%5.1lf%s Last", - "GPRINT:out_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l", - "LINE1:inc_avg#" .. self.palette.FullBlue .. ":Incoming", - --"GPRINT:inc_min:MIN:%5.1lf %s Min,", - "GPRINT:inc_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:inc_max:MAX:%5.1lf%s Max,", - "GPRINT:inc_avg:LAST:%5.1lf%s Last", - "GPRINT:inc_avg_sum:LAST:(ca. %5.1lf%sB Total)\\l" - }, - - cpufreq = { - "DEF:cpufreq_avg={file}:value:AVERAGE", - "DEF:cpufreq_min={file}:value:MIN", - "DEF:cpufreq_max={file}:value:MAX", - "AREA:cpufreq_max#" .. self.palette.HalfBlue, - "AREA:cpufreq_min#" .. self.palette.Canvas, - "LINE1:cpufreq_avg#" .. self.palette.FullBlue .. ":Frequency", - "GPRINT:cpufreq_min:MIN:%5.1lf%s Min,", - "GPRINT:cpufreq_avg:AVERAGE:%5.1lf%s Avg,", - "GPRINT:cpufreq_max:MAX:%5.1lf%s Max,", - "GPRINT:cpufreq_avg:LAST:%5.1lf%s Last\\l" - }, - - multimeter = { - "DEF:multimeter_avg={file}:value:AVERAGE", - "DEF:multimeter_min={file}:value:MIN", - "DEF:multimeter_max={file}:value:MAX", - "AREA:multimeter_max#" .. self.palette.HalfBlue, - "AREA:multimeter_min#" .. self.palette.Canvas, - "LINE1:multimeter_avg#" .. self.palette.FullBlue .. ":Multimeter", - "GPRINT:multimeter_min:MIN:%4.1lf Min,", - "GPRINT:multimeter_avg:AVERAGE:%4.1lf Average,", - "GPRINT:multimeter_max:MAX:%4.1lf Max,", - "GPRINT:multimeter_avg:LAST:%4.1lf Last\\l" - }, - - users = { - "-v", "Users", - "DEF:users_avg={file}:users:AVERAGE", - "DEF:users_min={file}:users:MIN", - "DEF:users_max={file}:users:MAX", - "AREA:users_max#" .. self.palette.HalfBlue, - "AREA:users_min#" .. self.palette.Canvas, - "LINE1:users_avg#" .. self.palette.FullBlue .. ":Users", - "GPRINT:users_min:MIN:%4.1lf Min,", - "GPRINT:users_avg:AVERAGE:%4.1lf Average,", - "GPRINT:users_max:MAX:%4.1lf Max,", - "GPRINT:users_avg:LAST:%4.1lf Last\\l" - }, - - voltage = { - "-v", "Voltage", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Voltage", - "GPRINT:min:MIN:%5.1lf%sV Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sV Avg,", - "GPRINT:max:MAX:%5.1lf%sV Max,", - "GPRINT:avg:LAST:%5.1lf%sV Last\\l" - }, - - vs_threads = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Threads", - "GPRINT:min:MIN:%5.1lf Min,", - "GPRINT:avg:AVERAGE:%5.1lf Avg.,", - "GPRINT:max:MAX:%5.1lf Max,", - "GPRINT:avg:LAST:%5.1lf Last\\l", - }, - - vs_memory = { - "-b", "1024", "-v", "Bytes", - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":", - "GPRINT:min:MIN:%5.1lf%sbytes Min,", - "GPRINT:avg:AVERAGE:%5.1lf%sbytes Avg.,", - "GPRINT:max:MAX:%5.1lf%sbytes Max,", - "GPRINT:avg:LAST:%5.1lf%sbytes Last\\l", - }, - - vs_processes = { - "DEF:avg={file}:value:AVERAGE", - "DEF:min={file}:value:MIN", - "DEF:max={file}:value:MAX", - "AREA:max#" .. self.palette.HalfBlue, - "AREA:min#" .. self.palette.Canvas, - "LINE1:avg#" .. self.palette.FullBlue .. ":Processes", - "GPRINT:min:MIN:%5.1lf Min,", - "GPRINT:avg:AVERAGE:%5.1lf Avg.,", - "GPRINT:max:MAX:%5.1lf Max,", - "GPRINT:avg:LAST:%5.1lf Last\\l", - }, - } -end - diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/cpu/cpu.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/cpu/cpu.lua deleted file mode 100644 index 2626d276d..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/cpu/cpu.lua +++ /dev/null @@ -1,31 +0,0 @@ -module("luci.statistics.rrdtool.definitions.cpu.cpu",package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance, dtype ) - - dtype_instances = { "idle", "nice", "system", "user" } - - opts = { } - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) - opts.title = host .. ": Prozessorauslastung" - opts.rrd = { "-v", "Percent" } - opts.colors = { - idle = 'ffffff', - nice = '00e000', - user = '0000ff', - wait = 'ffb000', - system = 'ff0000', - softirq = 'ff00ff', - interrupt = 'a000a0', - steal = '000000' - } - - for i, inst in ipairs(dtype_instances) do - opts.sources[i] = { - name = inst, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } - end - - return opts -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/iptables/ipt_packets.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/iptables/ipt_packets.lua deleted file mode 100644 index b16add995..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/iptables/ipt_packets.lua +++ /dev/null @@ -1,26 +0,0 @@ -module("luci.statistics.rrdtool.definitions.iptables.ipt_packets", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance, dtype ) - - dtype_instances = graph.tree:data_instances( plugin, plugin_instance, dtype ) - opts = { } - - for i, inst in ipairs(dtype_instances) do - - opts[i] = { } - opts[i].image = graph:mkpngpath( host, plugin, plugin_instance, dtype, inst ) - opts[i].title = host .. ": Firewall - " .. inst:gsub("_"," ") - opts[i].rrd = { "-v", "Pakete/s" } - - opts[i].colors = { - - } - - opts[i].sources = { { - name = inst, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } } - end - - return opts -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/netlink.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/netlink.lua deleted file mode 100644 index 3cee6abc0..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/netlink.lua +++ /dev/null @@ -1,163 +0,0 @@ -module("luci.statistics.rrdtool.definitions.netlink", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance ) - - local diagram_list = { } - - -- diagram names - local dtypes_names = { - "Pakete", - "Paketkollisionen", - "Paketfehler", - "Verkehr", - "RX-Fehler", - "TX-Fehler" - } - - -- diagram units - local dtypes_units = { - "Pakete/s", - "Kollisionen/s", - "Fehler/s", -- (?) - "Bytes/s", - "Fehler/s", - "Fehler/s" - } - - -- data source overrides - local dtypes_sources = { - if_errors = { "rx", "tx" }, -- if_errors has rx and tx - if_octets = { "rx", "tx" } -- if_octets has rx and tx - } - - -- diagram data types - local dtypes_list = { - - -- diagram 1: combined interface packet statistics - { - if_dropped = { "" }, -- packets/s - if_multicast = { "" }, -- packets/s - if_packets = { "" } -- packets/s - }, - - -- diagram 2: interface collision statistics - { - if_collisions = { "" } -- collisions/s - }, - - -- diagram 3: interface error statistics - { - if_errors = { "" } -- errors/s (?) - }, - - -- diagram 4: interface traffic statistics - { - if_octets = { "" } -- bytes/s - }, - - -- diagram 5: interface rx error statistics - { - if_rx_errors = { -- errors/s - "length", "missed", "over", "crc", "fifo", "frame" - } - }, - - -- diagram 6: interface tx error statistics - { - if_tx_errors = { -- errors/s - "aborted", "carrier", "fifo", "heartbeat", "window" - } - } - } - - -- diagram colors - local dtypes_colors = { - - -- diagram 1 - { - if_dropped = "ff0000", - if_multicast = "0000ff", - if_packets = "00ff00" - }, - - -- diagram 2 - { - if_collisions = "ff0000" - }, - - -- diagram 3 - { - if_errors__tx_ = "ff0000", - if_errors__rx_ = "ff5500" - }, - - -- diagram 4 - { - if_octets__tx_ = "00ff00", - if_octets__rx_ = "0000ff" - }, - - -- diagram 5 - { - length = "0000ff", - missed = "ff5500", - over = "ff0066", - crc = "ff0000", - fifo = "00ff00", - frame = "ffff00" - }, - - -- diagram 6 - { - aborted = "ff0000", - carrier = "ffff00", - fifo = "00ff00", - heartbeat = "0000ff", - window = "8800ff" - } - } - - - for i, name in ipairs(dtypes_names) do - - local dtypes = dtypes_list[i] - local opts = { } - - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, "netlink" .. i ) - opts.title = host .. ": Netlink Statistiken - " .. name .. " auf " .. plugin_instance - opts.rrd = { "-v", dtypes_units[i] } - opts.colors = dtypes_colors[i] - - for dtype, dinstances in pairs(dtypes) do - for i, inst in ipairs(dinstances) do - - local name = inst - if name:len() == 0 then name = dtype end - - -- check for data source override - if dtypes_sources[dtype] then - - -- has override - for i, ds in ipairs(dtypes_sources[dtype]) do - table.insert( opts.sources, { - ds = ds, -- override - name = name .. " (" .. ds .. ")", - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } ) - end - else - -- no override, assume single "value" data source - table.insert( opts.sources, { - name = name, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } ) - end - end - end - - table.insert( diagram_list, opts ) - end - - return diagram_list -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/ping/ping.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/ping/ping.lua deleted file mode 100644 index b041c015d..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/ping/ping.lua +++ /dev/null @@ -1,23 +0,0 @@ -module("luci.statistics.rrdtool.definitions.ping.ping", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance, dtype ) - - dtype_instances = graph.tree:data_instances( plugin, plugin_instance, dtype ) - - opts = { } - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) - opts.title = host .. ": Pingzeiten" - opts.rrd = { "-v", "Millisekunden" } - opts.colors = { } - - for i, inst in ipairs(dtype_instances) do - opts.sources[i] = { - ds = "ping", - name = inst, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } - end - - return opts -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/processes/ps_state.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/processes/ps_state.lua deleted file mode 100644 index 07cbe1d4a..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/processes/ps_state.lua +++ /dev/null @@ -1,31 +0,0 @@ -module("luci.statistics.rrdtool.definitions.processes.ps_state", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance, dtype ) - - dtype_instances = { - "sleeping", "running", "paging", "blocked", "stopped", "zombies" - } - - opts = { } - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) - opts.title = host .. ": Prozesse" - opts.rrd = { "-v", "Anzahl" } - opts.colors = { - sleeping = "008080", - running = "008000", - paging = "ffff00", - blocked = "ff5000", - stopped = "555555", - zombies = "ff0000" - } - - for i, inst in ipairs(dtype_instances) do - opts.sources[i] = { - name = inst, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, "ps_state", inst ) - } - end - - return opts -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua deleted file mode 100644 index 049357494..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/tcpconns/tcp_connections.lua +++ /dev/null @@ -1,27 +0,0 @@ -module("luci.statistics.rrdtool.definitions.tcpconns.tcp_connections", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance, dtype ) - - dtype_instances = { - "SYN_SENT", "SYN_RECV", "LISTEN", "ESTABLISHED", "LAST_ACK", "TIME_WAIT", - "CLOSING", "CLOSE_WAIT", "CLOSED", "FIN_WAIT1", "FIN_WAIT2" - } - - opts = { } - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, dtype ) - opts.title = host .. ": TCP-Verbindungen - Port " .. plugin_instance - opts.rrd = { "-v", "Anzahl" } - opts.colors = { - - } - - for i, inst in ipairs(dtype_instances) do - opts.sources[i] = { - name = inst, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype, inst ) - } - end - - return opts -end diff --git a/applications/luci-statistics/src/statistics/rrdtool/definitions/wireless.lua b/applications/luci-statistics/src/statistics/rrdtool/definitions/wireless.lua deleted file mode 100644 index e315ca521..000000000 --- a/applications/luci-statistics/src/statistics/rrdtool/definitions/wireless.lua +++ /dev/null @@ -1,25 +0,0 @@ -module("luci.statistics.rrdtool.definitions.wireless", package.seeall) - -function rrdargs( graph, host, plugin, plugin_instance ) - - dtypes = { "signal_power", "signal_noise" } - - opts = { } - opts.sources = { } - opts.image = graph:mkpngpath( host, plugin, plugin_instance, "wireless" ) - opts.title = host .. ": WLAN Signal" - opts.rrd = { "-v", "dBm" } - opts.colors = { - signal_power = '0000ff', - signal_noise = 'ff0000' - } - - for i, dtype in ipairs(dtypes) do - opts.sources[i] = { - name = dtype, - rrd = graph:mkrrdpath( host, plugin, plugin_instance, dtype ) - } - end - - return opts -end diff --git a/applications/luci-statistics/src/view/admin_statistics/index.htm b/applications/luci-statistics/src/view/admin_statistics/index.htm deleted file mode 100644 index 2c1befa50..000000000 --- a/applications/luci-statistics/src/view/admin_statistics/index.htm +++ /dev/null @@ -1,8 +0,0 @@ -<%+header%> - -

<%:stat Statistiken%>

- -

<%:stat_desc Die Statistiken bauen auf Collectd auf und nutzen -RRD Tool um Graphen aus den erfassten Daten zu rendern.%>

- -<%+footer%> diff --git a/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm b/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm deleted file mode 100644 index d3aa87eb1..000000000 --- a/applications/luci-statistics/src/view/admin_statistics/networkplugins.htm +++ /dev/null @@ -1,18 +0,0 @@ -<%+header%> - -

<%:stat_networkplugins Netzwerkplugins%>

- -

<%:stat_networkplugins_desc Netzwerkplugins sammeln Werte über offene TCP-Verbindung, allgemeines Verkehrsaufkommen -auf verschiedenen Schnittstellen, DNS-Verkehr u.v.m.%>

- -

<%:stat_networkplugins_installed Installierte Netzwerkplugins:%> -

    - <% for plugin, desc in pairs(plugins) do %> - <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> -
  • <%=desc%>
  • - <% end %> - <% end %> -
-

- -<%+footer%> diff --git a/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm b/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm deleted file mode 100644 index 5a8a76045..000000000 --- a/applications/luci-statistics/src/view/admin_statistics/outputplugins.htm +++ /dev/null @@ -1,19 +0,0 @@ -<%+header%> - -

<%:stat_outputplugins Ausgabeplugins%>

- -

<%:stat_outputplugins_desc Ausgabeplugins stellen verschiedene Möglichkeiten zur Speicherung -der Daten bereit. Es können auch mehrere Plugins gleichzeitig aktiviert werden um beispielsweise -die gesammelten Werte in RRD-Datenbanken zu sichern und zusätzlich über das Netzwerk zu versenden.%>

- -

<%:stat_outputplugins_installed Installierte Ausgabeplugins:%> -

    - <% for plugin, desc in pairs(plugins) do %> - <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> -
  • <%=desc%>
  • - <% end %> - <% end %> -
-

- -<%+footer%> diff --git a/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm b/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm deleted file mode 100644 index 2a32bf5ca..000000000 --- a/applications/luci-statistics/src/view/admin_statistics/systemplugins.htm +++ /dev/null @@ -1,18 +0,0 @@ -<%+header%> - -

<%:stat_systemplugins Systemplugins%>

- -

<%:stat_systemplugins_desc Systemplugins sammeln Werte über den aktuellen Systemzustand und den Ressourcenverbrauch -auf dem Gerät.%>

- -

<%:stat_systemplugins_installed Installierte Systemplugins:%> -

    - <% for plugin, desc in pairs(plugins) do %> - <% if luci.fs.isfile("/usr/lib/collectd/" .. plugin .. ".so") then %> -
  • <%=desc%>
  • - <% end %> - <% end %> -
-

- -<%+footer%> diff --git a/applications/luci-statistics/src/view/public_statistics/graph.htm b/applications/luci-statistics/src/view/public_statistics/graph.htm deleted file mode 100644 index 093d76d0e..000000000 --- a/applications/luci-statistics/src/view/public_statistics/graph.htm +++ /dev/null @@ -1,9 +0,0 @@ -<%+header%> - -

Statistik

- -<% for i, img in ipairs(images) do %> - " /> -<% end %> - -<%+footer%> diff --git a/build/module.mk b/build/module.mk index 8932f5761..287314696 100644 --- a/build/module.mk +++ b/build/module.mk @@ -8,7 +8,7 @@ source: source-module source-module: mkdir -p dist$(LUCI_INSTALLDIR) cp root/* dist -R 2>/dev/null || true - cp src/* dist$(LUCI_INSTALLDIR) -R 2>/dev/null || true + cp luasrc/* dist$(LUCI_INSTALLDIR) -R 2>/dev/null || true for i in $$(find dist -name .svn); do rm $$i -rf; done compile-module: source-module diff --git a/i18n/english/luasrc/i18n/cbi.en b/i18n/english/luasrc/i18n/cbi.en new file mode 100644 index 000000000..6069cec45 --- /dev/null +++ b/i18n/english/luasrc/i18n/cbi.en @@ -0,0 +1,4 @@ +cbi_add = "Add entry" +cbi_del = "Remove entry" +cbi_invalid = "Error: Invalid input value" +cbi_addopt = "-- Field --" \ No newline at end of file diff --git a/i18n/english/src/i18n/cbi.en b/i18n/english/src/i18n/cbi.en deleted file mode 100644 index 6069cec45..000000000 --- a/i18n/english/src/i18n/cbi.en +++ /dev/null @@ -1,4 +0,0 @@ -cbi_add = "Add entry" -cbi_del = "Remove entry" -cbi_invalid = "Error: Invalid input value" -cbi_addopt = "-- Field --" \ No newline at end of file diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua new file mode 100644 index 000000000..b7097b5d9 --- /dev/null +++ b/libs/cbi/luasrc/cbi.lua @@ -0,0 +1,747 @@ +--[[ +LuCI - Configuration Bind Interface + +Description: +Offers an interface for binding confiugration values to certain +data types. Supports value and range validation and basic dependencies. + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.cbi", package.seeall) + +require("luci.template") +require("luci.util") +require("luci.http") +require("luci.model.uci") + +local class = luci.util.class +local instanceof = luci.util.instanceof + +-- Loads a CBI map from given file, creating an environment and returns it +function load(cbimap) + require("luci.fs") + require("luci.i18n") + require("luci.config") + require("luci.sys") + + local cbidir = luci.sys.libpath() .. "/model/cbi/" + local func, err = loadfile(cbidir..cbimap..".lua") + + if not func then + return nil + end + + luci.i18n.loadc("cbi") + + luci.util.resfenv(func) + luci.util.updfenv(func, luci.cbi) + luci.util.extfenv(func, "translate", luci.i18n.translate) + + local map = func() + + if not instanceof(map, Map) then + error("CBI map returns no valid map object!") + return nil + end + + return map +end + +-- Node pseudo abstract class +Node = class() + +function Node.__init__(self, title, description) + self.children = {} + self.title = title or "" + self.description = description or "" + self.template = "cbi/node" +end + +-- Append child nodes +function Node.append(self, obj) + table.insert(self.children, obj) +end + +-- Parse this node and its children +function Node.parse(self, ...) + for k, child in ipairs(self.children) do + child:parse(...) + end +end + +-- Render this node +function Node.render(self, scope) + scope = scope or {} + scope.self = self + + luci.template.render(self.template, scope) +end + +-- Render the children +function Node.render_children(self, ...) + for k, node in ipairs(self.children) do + node:render(...) + end +end + + +--[[ +A simple template element +]]-- +Template = class(Node) + +function Template.__init__(self, template) + Node.__init__(self) + self.template = template +end + + +--[[ +Map - A map describing a configuration file +]]-- +Map = class(Node) + +function Map.__init__(self, config, ...) + Node.__init__(self, ...) + self.config = config + self.template = "cbi/map" + self.uci = luci.model.uci.Session() + self.ucidata, self.uciorder = self.uci:sections(self.config) + if not self.ucidata or not self.uciorder then + error("Unable to read UCI data: " .. self.config) + end +end + +-- Use optimized UCI writing +function Map.parse(self, ...) + self.uci:t_load(self.config) + Node.parse(self, ...) + self.uci:t_save(self.config) +end + +-- Creates a child section +function Map.section(self, class, ...) + if instanceof(class, AbstractSection) then + local obj = class(self, ...) + self:append(obj) + return obj + else + error("class must be a descendent of AbstractSection") + end +end + +-- UCI add +function Map.add(self, sectiontype) + local name = self.uci:t_add(self.config, sectiontype) + if name then + self.ucidata[name] = {} + self.ucidata[name][".type"] = sectiontype + table.insert(self.uciorder, name) + end + return name +end + +-- UCI set +function Map.set(self, section, option, value) + local stat = self.uci:t_set(self.config, section, option, value) + if stat then + local val = self.uci:t_get(self.config, section, option) + if option then + self.ucidata[section][option] = val + else + if not self.ucidata[section] then + self.ucidata[section] = {} + end + self.ucidata[section][".type"] = val + table.insert(self.uciorder, section) + end + end + return stat +end + +-- UCI del +function Map.del(self, section, option) + local stat = self.uci:t_del(self.config, section, option) + if stat then + if option then + self.ucidata[section][option] = nil + else + self.ucidata[section] = nil + for i, k in ipairs(self.uciorder) do + if section == k then + table.remove(self.uciorder, i) + end + end + end + end + return stat +end + +-- UCI get (cached) +function Map.get(self, section, option) + if not section then + return self.ucidata, self.uciorder + elseif option and self.ucidata[section] then + return self.ucidata[section][option] + else + return self.ucidata[section] + end +end + + +--[[ +AbstractSection +]]-- +AbstractSection = class(Node) + +function AbstractSection.__init__(self, map, sectiontype, ...) + Node.__init__(self, ...) + self.sectiontype = sectiontype + self.map = map + self.config = map.config + self.optionals = {} + + self.optional = true + self.addremove = false + self.dynamic = false +end + +-- Appends a new option +function AbstractSection.option(self, class, ...) + if instanceof(class, AbstractValue) then + local obj = class(self.map, ...) + self:append(obj) + return obj + else + error("class must be a descendent of AbstractValue") + end +end + +-- Parse optional options +function AbstractSection.parse_optionals(self, section) + if not self.optional then + return + end + + self.optionals[section] = {} + + local field = luci.http.formvalue("cbi.opt."..self.config.."."..section) + for k,v in ipairs(self.children) do + if v.optional and not v:cfgvalue(section) then + if field == v.option then + field = nil + else + table.insert(self.optionals[section], v) + end + end + end + + if field and #field > 0 and self.dynamic then + self:add_dynamic(field) + end +end + +-- Add a dynamic option +function AbstractSection.add_dynamic(self, field, optional) + local o = self:option(Value, field, field) + o.optional = optional +end + +-- Parse all dynamic options +function AbstractSection.parse_dynamic(self, section) + if not self.dynamic then + return + end + + local arr = luci.util.clone(self:cfgvalue(section)) + local form = luci.http.formvaluetable("cbid."..self.config.."."..section) + for k, v in pairs(form) do + arr[k] = v + end + + for key,val in pairs(arr) do + local create = true + + for i,c in ipairs(self.children) do + if c.option == key then + create = false + end + end + + if create and key:sub(1, 1) ~= "." then + self:add_dynamic(key, true) + end + end +end + +-- Returns the section's UCI table +function AbstractSection.cfgvalue(self, section) + return self.map:get(section) +end + +-- Removes the section +function AbstractSection.remove(self, section) + return self.map:del(section) +end + +-- Creates the section +function AbstractSection.create(self, section) + return self.map:set(section, nil, self.sectiontype) +end + + + +--[[ +NamedSection - A fixed configuration section defined by its name +]]-- +NamedSection = class(AbstractSection) + +function NamedSection.__init__(self, map, section, ...) + AbstractSection.__init__(self, map, ...) + self.template = "cbi/nsection" + + self.section = section + self.addremove = false +end + +function NamedSection.parse(self) + local s = self.section + local active = self:cfgvalue(s) + + + if self.addremove then + local path = self.config.."."..s + if active then -- Remove the section + if luci.http.formvalue("cbi.rns."..path) and self:remove(s) then + return + end + else -- Create and apply default values + if luci.http.formvalue("cbi.cns."..path) and self:create(s) then + for k,v in pairs(self.children) do + v:write(s, v.default) + end + end + end + end + + if active then + AbstractSection.parse_dynamic(self, s) + if luci.http.formvalue("cbi.submit") then + Node.parse(self, s) + end + AbstractSection.parse_optionals(self, s) + end +end + + +--[[ +TypedSection - A (set of) configuration section(s) defined by the type + addremove: Defines whether the user can add/remove sections of this type + anonymous: Allow creating anonymous sections + validate: a validation function returning nil if the section is invalid +]]-- +TypedSection = class(AbstractSection) + +function TypedSection.__init__(self, ...) + AbstractSection.__init__(self, ...) + self.template = "cbi/tsection" + self.deps = {} + self.excludes = {} + + self.anonymous = false +end + +-- Return all matching UCI sections for this TypedSection +function TypedSection.cfgsections(self) + local sections = {} + local map, order = self.map:get() + + for i, k in ipairs(order) do + if map[k][".type"] == self.sectiontype then + if self:checkscope(k) then + table.insert(sections, k) + end + end + end + + return sections +end + +-- Creates a new section of this type with the given name (or anonymous) +function TypedSection.create(self, name) + if name then + self.map:set(name, nil, self.sectiontype) + else + name = self.map:add(self.sectiontype) + end + + for k,v in pairs(self.children) do + if v.default then + self.map:set(name, v.option, v.default) + end + end +end + +-- Limits scope to sections that have certain option => value pairs +function TypedSection.depends(self, option, value) + table.insert(self.deps, {option=option, value=value}) +end + +-- Excludes several sections by name +function TypedSection.exclude(self, field) + self.excludes[field] = true +end + +function TypedSection.parse(self) + if self.addremove then + -- Create + local crval = "cbi.cts." .. self.config .. "." .. self.sectiontype + local name = luci.http.formvalue(crval) + if self.anonymous then + if name then + self:create() + end + else + if name then + -- Ignore if it already exists + if self:cfgvalue(name) then + name = nil; + end + + name = self:checkscope(name) + + if not name then + self.err_invalid = true + end + + if name and name:len() > 0 then + self:create(name) + end + end + end + + -- Remove + crval = "cbi.rts." .. self.config + name = luci.http.formvaluetable(crval) + for k,v in pairs(name) do + if self:cfgvalue(k) and self:checkscope(k) then + self:remove(k) + end + end + end + + for i, k in ipairs(self:cfgsections()) do + AbstractSection.parse_dynamic(self, k) + if luci.http.formvalue("cbi.submit") then + Node.parse(self, k) + end + AbstractSection.parse_optionals(self, k) + end +end + +-- Verifies scope of sections +function TypedSection.checkscope(self, section) + -- Check if we are not excluded + if self.excludes[section] then + return nil + end + + -- Check if at least one dependency is met + if #self.deps > 0 and self:cfgvalue(section) then + local stat = false + + for k, v in ipairs(self.deps) do + if self:cfgvalue(section)[v.option] == v.value then + stat = true + end + end + + if not stat then + return nil + end + end + + return self:validate(section) +end + + +-- Dummy validate function +function TypedSection.validate(self, section) + return section +end + + +--[[ +AbstractValue - An abstract Value Type + null: Value can be empty + valid: A function returning the value if it is valid otherwise nil + depends: A table of option => value pairs of which one must be true + default: The default value + size: The size of the input fields + rmempty: Unset value if empty + optional: This value is optional (see AbstractSection.optionals) +]]-- +AbstractValue = class(Node) + +function AbstractValue.__init__(self, map, option, ...) + Node.__init__(self, ...) + self.option = option + self.map = map + self.config = map.config + self.tag_invalid = {} + self.deps = {} + + self.rmempty = false + self.default = nil + self.size = nil + self.optional = false +end + +-- Add a dependencie to another section field +function AbstractValue.depends(self, field, value) + table.insert(self.deps, {field=field, value=value}) +end + +-- Return whether this object should be created +function AbstractValue.formcreated(self, section) + local key = "cbi.opt."..self.config.."."..section + return (luci.http.formvalue(key) == self.option) +end + +-- Returns the formvalue for this object +function AbstractValue.formvalue(self, section) + local key = "cbid."..self.map.config.."."..section.."."..self.option + return luci.http.formvalue(key) +end + +function AbstractValue.parse(self, section) + local fvalue = self:formvalue(section) + + if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI + fvalue = self:validate(fvalue) + if not fvalue then + self.tag_invalid[section] = true + end + if fvalue and not (fvalue == self:cfgvalue(section)) then + self:write(section, fvalue) + end + else -- Unset the UCI or error + if self.rmempty or self.optional then + self:remove(section) + end + end +end + +-- Render if this value exists or if it is mandatory +function AbstractValue.render(self, s, scope) + if not self.optional or self:cfgvalue(s) or self:formcreated(s) then + scope = scope or {} + scope.section = s + Node.render(self, scope) + end +end + +-- Return the UCI value of this object +function AbstractValue.cfgvalue(self, section) + return self.map:get(section, self.option) +end + +-- Validate the form value +function AbstractValue.validate(self, value) + return value +end + +-- Write to UCI +function AbstractValue.write(self, section, value) + return self.map:set(section, self.option, value) +end + +-- Remove from UCI +function AbstractValue.remove(self, section) + return self.map:del(section, self.option) +end + + + + +--[[ +Value - A one-line value + maxlength: The maximum length + isnumber: The value must be a valid (floating point) number + isinteger: The value must be a valid integer + ispositive: The value must be positive (and a number) +]]-- +Value = class(AbstractValue) + +function Value.__init__(self, ...) + AbstractValue.__init__(self, ...) + self.template = "cbi/value" + + self.maxlength = nil + self.isnumber = false + self.isinteger = false +end + +-- This validation is a bit more complex +function Value.validate(self, val) + if self.maxlength and tostring(val):len() > self.maxlength then + val = nil + end + + return luci.util.validate(val, self.isnumber, self.isinteger) +end + + +-- DummyValue - This does nothing except being there +DummyValue = class(AbstractValue) + +function DummyValue.__init__(self, map, ...) + AbstractValue.__init__(self, map, ...) + self.template = "cbi/dvalue" + self.value = nil +end + +function DummyValue.parse(self) + +end + +function DummyValue.render(self, s) + luci.template.render(self.template, {self=self, section=s}) +end + + +--[[ +Flag - A flag being enabled or disabled +]]-- +Flag = class(AbstractValue) + +function Flag.__init__(self, ...) + AbstractValue.__init__(self, ...) + self.template = "cbi/fvalue" + + self.enabled = "1" + self.disabled = "0" +end + +-- A flag can only have two states: set or unset +function Flag.parse(self, section) + local fvalue = self:formvalue(section) + + if fvalue then + fvalue = self.enabled + else + fvalue = self.disabled + end + + if fvalue == self.enabled or (not self.optional and not self.rmempty) then + if not(fvalue == self:cfgvalue(section)) then + self:write(section, fvalue) + end + else + self:remove(section) + end +end + + + +--[[ +ListValue - A one-line value predefined in a list + widget: The widget that will be used (select, radio) +]]-- +ListValue = class(AbstractValue) + +function ListValue.__init__(self, ...) + AbstractValue.__init__(self, ...) + self.template = "cbi/lvalue" + self.keylist = {} + self.vallist = {} + + self.size = 1 + self.widget = "select" +end + +function ListValue.value(self, key, val) + val = val or key + table.insert(self.keylist, tostring(key)) + table.insert(self.vallist, tostring(val)) +end + +function ListValue.validate(self, val) + if luci.util.contains(self.keylist, val) then + return val + else + return nil + end +end + + + +--[[ +MultiValue - Multiple delimited values + widget: The widget that will be used (select, checkbox) + delimiter: The delimiter that will separate the values (default: " ") +]]-- +MultiValue = class(AbstractValue) + +function MultiValue.__init__(self, ...) + AbstractValue.__init__(self, ...) + self.template = "cbi/mvalue" + self.keylist = {} + self.vallist = {} + + self.widget = "checkbox" + self.delimiter = " " +end + +function MultiValue.value(self, key, val) + val = val or key + table.insert(self.keylist, tostring(key)) + table.insert(self.vallist, tostring(val)) +end + +function MultiValue.valuelist(self, section) + local val = self:cfgvalue(section) + + if not(type(val) == "string") then + return {} + end + + return luci.util.split(val, self.delimiter) +end + +function MultiValue.validate(self, val) + if not(type(val) == "string") then + return nil + end + + local result = "" + + for value in val:gmatch("[^\n]+") do + if luci.util.contains(self.keylist, value) then + result = result .. self.delimiter .. value + end + end + + if result:len() > 0 then + return result:sub(self.delimiter:len() + 1) + else + return nil + end +end \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/dvalue.htm b/libs/cbi/luasrc/view/cbi/dvalue.htm new file mode 100644 index 000000000..f54667def --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/dvalue.htm @@ -0,0 +1,12 @@ +<%+cbi/valueheader%> +<% if self.value then + if type(self.value) == "function" then %> + <%=self:value(section)%> +<% else %> + <%=self.value%> +<% end +else %> + <%=self:cfgvalue(section)%> +<% end %> +  +<%+cbi/valuefooter%> diff --git a/libs/cbi/luasrc/view/cbi/footer.htm b/libs/cbi/luasrc/view/cbi/footer.htm new file mode 100644 index 000000000..2acf710cd --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/footer.htm @@ -0,0 +1,7 @@ +
+ + + +
+ +<%+footer%> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm new file mode 100644 index 000000000..6151a3a66 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm @@ -0,0 +1,8 @@ +
<%=self.description%> 
+ + <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> + + <% if #self.deps > 0 then %><% end %> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/full_valueheader.htm b/libs/cbi/luasrc/view/cbi/full_valueheader.htm new file mode 100644 index 000000000..062efa2dd --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/full_valueheader.htm @@ -0,0 +1,3 @@ +
"> +
<%=self.title%>
+
\ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/fvalue.htm b/libs/cbi/luasrc/view/cbi/fvalue.htm new file mode 100644 index 000000000..b609f1d4f --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/fvalue.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> + " name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" /> +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/header.htm b/libs/cbi/luasrc/view/cbi/header.htm new file mode 100644 index 000000000..4229aaf0d --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/header.htm @@ -0,0 +1,7 @@ +<%+header%> +
+
+ + + +
diff --git a/libs/cbi/luasrc/view/cbi/lvalue.htm b/libs/cbi/luasrc/view/cbi/lvalue.htm new file mode 100644 index 000000000..f1ae5a093 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/lvalue.htm @@ -0,0 +1,16 @@ +<%+cbi/valueheader%> +<% if self.widget == "select" then %> + +<% elseif self.widget == "radio" then + local c = 0; + for i, key in pairs(self.keylist) do + c = c + 1%> + <%=self.vallist[i]%>"<% if self:cfgvalue(section) == key then %> checked="checked"<% end %> value="<%=key%>" /> +<% if c == self.size then c = 0 %>
+<% end end %> +<% end %> +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/map.htm b/libs/cbi/luasrc/view/cbi/map.htm new file mode 100644 index 000000000..835393c1c --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/map.htm @@ -0,0 +1,6 @@ +
+

<%=self.title%>

+
<%=self.description%>
+<% self:render_children() %> +
+
diff --git a/libs/cbi/luasrc/view/cbi/mvalue.htm b/libs/cbi/luasrc/view/cbi/mvalue.htm new file mode 100644 index 000000000..bed66e569 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/mvalue.htm @@ -0,0 +1,19 @@ +<% +local v = self:valuelist(section) +%> +<%+cbi/valueheader%> +<% if self.widget == "select" then %> + +<% elseif self.widget == "checkbox" then + local c = 0; + for i, key in pairs(self.keylist) do + c = c + 1%> + <%=self.vallist[i]%>[]"<% if luci.util.contains(v, key) then %> checked="checked"<% end %> value="<%=key%>" /> +<% if c == self.size then c = 0 %>
+<% end end %> +<% end %> +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/nsection.htm b/libs/cbi/luasrc/view/cbi/nsection.htm new file mode 100644 index 000000000..fff597ad0 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/nsection.htm @@ -0,0 +1,20 @@ +<% if self:cfgvalue(self.section) then +section = self.section %> +
+

<%=self.title%>

+
<%=self.description%>
+ <% if self.addremove then %>
+ +
<% end %> +
+<%+cbi/ucisection%> +
+
+
+<% elseif self.addremove then %> +
+

<%=self.title%>

+
<%=self.description%>
+ +
+<% end %> diff --git a/libs/cbi/luasrc/view/cbi/tblsection.htm b/libs/cbi/luasrc/view/cbi/tblsection.htm new file mode 100644 index 000000000..df16efbed --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/tblsection.htm @@ -0,0 +1,39 @@ +
+

<%=self.title%>

+
<%=self.description%>
+
+
+<% for i, k in pairs(self.children) do %> +
<%=k.title%>
+<% end %> +
+
+<% for i, k in pairs(self.children) do %> +
<%=k.description%>
+<% end %> +
+<% for i, k in ipairs(self:cfgsections()) do%> + <% if not self.anonymous then %>

<%=k%>

<% end %> +<% +section = k +scope = {valueheader = "cbi/tiny_valueheader", valuefooter = "cbi/tiny_valuefooter"} +%> +
+<%+cbi/ucisection%> + <% if self.addremove then %>
+ +
<% end %> +
+<% end %> +<% if self.addremove then %> +
+ <% if self.anonymous then %> + + <% else %> + + + <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> +
+
+<% end %> +
diff --git a/libs/cbi/luasrc/view/cbi/tiny_valuefooter.htm b/libs/cbi/luasrc/view/cbi/tiny_valuefooter.htm new file mode 100644 index 000000000..e65ebb6c0 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/tiny_valuefooter.htm @@ -0,0 +1,6 @@ + <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> +
+ <% if #self.deps > 0 then %><% end %> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/tiny_valueheader.htm b/libs/cbi/luasrc/view/cbi/tiny_valueheader.htm new file mode 100644 index 000000000..b9b26bd6a --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/tiny_valueheader.htm @@ -0,0 +1 @@ +
"> diff --git a/libs/cbi/luasrc/view/cbi/tsection.htm b/libs/cbi/luasrc/view/cbi/tsection.htm new file mode 100644 index 000000000..37b18b5d4 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/tsection.htm @@ -0,0 +1,25 @@ +
+

<%=self.title%>

+
<%=self.description%>
+<% for i, k in ipairs(self:cfgsections()) do%> + <% if self.addremove then %>
+ +
<% end %> + <% if not self.anonymous then %>

<%=k%>

<% end %> +<% section = k %> +
+<%+cbi/ucisection%> +
+
+<% end %> +<% if self.addremove then %> +
+ <% if self.anonymous then %> + + <% else %> + + + <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> +
+<% end %> +
diff --git a/libs/cbi/luasrc/view/cbi/ucisection.htm b/libs/cbi/luasrc/view/cbi/ucisection.htm new file mode 100644 index 000000000..0abc37e7c --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/ucisection.htm @@ -0,0 +1,20 @@ +<% self:render_children(section, scope or {}) %> + <% if #self.optionals[section] > 0 or self.dynamic then %> +
+ <% if self.dynamic then %> + + <% else %> + + + <% end %> + +
+ <% end %> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/value.htm b/libs/cbi/luasrc/view/cbi/value.htm new file mode 100644 index 000000000..31bf38f77 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/value.htm @@ -0,0 +1,3 @@ +<%+cbi/valueheader%> + size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" id="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=self:cfgvalue(section)%>" /> +<%+cbi/valuefooter%> diff --git a/libs/cbi/luasrc/view/cbi/valuefooter.htm b/libs/cbi/luasrc/view/cbi/valuefooter.htm new file mode 100644 index 000000000..bc9d1b127 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/valuefooter.htm @@ -0,0 +1,5 @@ +<% if valuefooter then + include(valuefooter) +else + include("cbi/full_valuefooter") +end %> \ No newline at end of file diff --git a/libs/cbi/luasrc/view/cbi/valueheader.htm b/libs/cbi/luasrc/view/cbi/valueheader.htm new file mode 100644 index 000000000..8d9802f57 --- /dev/null +++ b/libs/cbi/luasrc/view/cbi/valueheader.htm @@ -0,0 +1,5 @@ +<% if valueheader then + include(valueheader) +else + include("cbi/full_valueheader") +end %> \ No newline at end of file diff --git a/libs/cbi/src/cbi.lua b/libs/cbi/src/cbi.lua deleted file mode 100644 index b7097b5d9..000000000 --- a/libs/cbi/src/cbi.lua +++ /dev/null @@ -1,747 +0,0 @@ ---[[ -LuCI - Configuration Bind Interface - -Description: -Offers an interface for binding confiugration values to certain -data types. Supports value and range validation and basic dependencies. - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.cbi", package.seeall) - -require("luci.template") -require("luci.util") -require("luci.http") -require("luci.model.uci") - -local class = luci.util.class -local instanceof = luci.util.instanceof - --- Loads a CBI map from given file, creating an environment and returns it -function load(cbimap) - require("luci.fs") - require("luci.i18n") - require("luci.config") - require("luci.sys") - - local cbidir = luci.sys.libpath() .. "/model/cbi/" - local func, err = loadfile(cbidir..cbimap..".lua") - - if not func then - return nil - end - - luci.i18n.loadc("cbi") - - luci.util.resfenv(func) - luci.util.updfenv(func, luci.cbi) - luci.util.extfenv(func, "translate", luci.i18n.translate) - - local map = func() - - if not instanceof(map, Map) then - error("CBI map returns no valid map object!") - return nil - end - - return map -end - --- Node pseudo abstract class -Node = class() - -function Node.__init__(self, title, description) - self.children = {} - self.title = title or "" - self.description = description or "" - self.template = "cbi/node" -end - --- Append child nodes -function Node.append(self, obj) - table.insert(self.children, obj) -end - --- Parse this node and its children -function Node.parse(self, ...) - for k, child in ipairs(self.children) do - child:parse(...) - end -end - --- Render this node -function Node.render(self, scope) - scope = scope or {} - scope.self = self - - luci.template.render(self.template, scope) -end - --- Render the children -function Node.render_children(self, ...) - for k, node in ipairs(self.children) do - node:render(...) - end -end - - ---[[ -A simple template element -]]-- -Template = class(Node) - -function Template.__init__(self, template) - Node.__init__(self) - self.template = template -end - - ---[[ -Map - A map describing a configuration file -]]-- -Map = class(Node) - -function Map.__init__(self, config, ...) - Node.__init__(self, ...) - self.config = config - self.template = "cbi/map" - self.uci = luci.model.uci.Session() - self.ucidata, self.uciorder = self.uci:sections(self.config) - if not self.ucidata or not self.uciorder then - error("Unable to read UCI data: " .. self.config) - end -end - --- Use optimized UCI writing -function Map.parse(self, ...) - self.uci:t_load(self.config) - Node.parse(self, ...) - self.uci:t_save(self.config) -end - --- Creates a child section -function Map.section(self, class, ...) - if instanceof(class, AbstractSection) then - local obj = class(self, ...) - self:append(obj) - return obj - else - error("class must be a descendent of AbstractSection") - end -end - --- UCI add -function Map.add(self, sectiontype) - local name = self.uci:t_add(self.config, sectiontype) - if name then - self.ucidata[name] = {} - self.ucidata[name][".type"] = sectiontype - table.insert(self.uciorder, name) - end - return name -end - --- UCI set -function Map.set(self, section, option, value) - local stat = self.uci:t_set(self.config, section, option, value) - if stat then - local val = self.uci:t_get(self.config, section, option) - if option then - self.ucidata[section][option] = val - else - if not self.ucidata[section] then - self.ucidata[section] = {} - end - self.ucidata[section][".type"] = val - table.insert(self.uciorder, section) - end - end - return stat -end - --- UCI del -function Map.del(self, section, option) - local stat = self.uci:t_del(self.config, section, option) - if stat then - if option then - self.ucidata[section][option] = nil - else - self.ucidata[section] = nil - for i, k in ipairs(self.uciorder) do - if section == k then - table.remove(self.uciorder, i) - end - end - end - end - return stat -end - --- UCI get (cached) -function Map.get(self, section, option) - if not section then - return self.ucidata, self.uciorder - elseif option and self.ucidata[section] then - return self.ucidata[section][option] - else - return self.ucidata[section] - end -end - - ---[[ -AbstractSection -]]-- -AbstractSection = class(Node) - -function AbstractSection.__init__(self, map, sectiontype, ...) - Node.__init__(self, ...) - self.sectiontype = sectiontype - self.map = map - self.config = map.config - self.optionals = {} - - self.optional = true - self.addremove = false - self.dynamic = false -end - --- Appends a new option -function AbstractSection.option(self, class, ...) - if instanceof(class, AbstractValue) then - local obj = class(self.map, ...) - self:append(obj) - return obj - else - error("class must be a descendent of AbstractValue") - end -end - --- Parse optional options -function AbstractSection.parse_optionals(self, section) - if not self.optional then - return - end - - self.optionals[section] = {} - - local field = luci.http.formvalue("cbi.opt."..self.config.."."..section) - for k,v in ipairs(self.children) do - if v.optional and not v:cfgvalue(section) then - if field == v.option then - field = nil - else - table.insert(self.optionals[section], v) - end - end - end - - if field and #field > 0 and self.dynamic then - self:add_dynamic(field) - end -end - --- Add a dynamic option -function AbstractSection.add_dynamic(self, field, optional) - local o = self:option(Value, field, field) - o.optional = optional -end - --- Parse all dynamic options -function AbstractSection.parse_dynamic(self, section) - if not self.dynamic then - return - end - - local arr = luci.util.clone(self:cfgvalue(section)) - local form = luci.http.formvaluetable("cbid."..self.config.."."..section) - for k, v in pairs(form) do - arr[k] = v - end - - for key,val in pairs(arr) do - local create = true - - for i,c in ipairs(self.children) do - if c.option == key then - create = false - end - end - - if create and key:sub(1, 1) ~= "." then - self:add_dynamic(key, true) - end - end -end - --- Returns the section's UCI table -function AbstractSection.cfgvalue(self, section) - return self.map:get(section) -end - --- Removes the section -function AbstractSection.remove(self, section) - return self.map:del(section) -end - --- Creates the section -function AbstractSection.create(self, section) - return self.map:set(section, nil, self.sectiontype) -end - - - ---[[ -NamedSection - A fixed configuration section defined by its name -]]-- -NamedSection = class(AbstractSection) - -function NamedSection.__init__(self, map, section, ...) - AbstractSection.__init__(self, map, ...) - self.template = "cbi/nsection" - - self.section = section - self.addremove = false -end - -function NamedSection.parse(self) - local s = self.section - local active = self:cfgvalue(s) - - - if self.addremove then - local path = self.config.."."..s - if active then -- Remove the section - if luci.http.formvalue("cbi.rns."..path) and self:remove(s) then - return - end - else -- Create and apply default values - if luci.http.formvalue("cbi.cns."..path) and self:create(s) then - for k,v in pairs(self.children) do - v:write(s, v.default) - end - end - end - end - - if active then - AbstractSection.parse_dynamic(self, s) - if luci.http.formvalue("cbi.submit") then - Node.parse(self, s) - end - AbstractSection.parse_optionals(self, s) - end -end - - ---[[ -TypedSection - A (set of) configuration section(s) defined by the type - addremove: Defines whether the user can add/remove sections of this type - anonymous: Allow creating anonymous sections - validate: a validation function returning nil if the section is invalid -]]-- -TypedSection = class(AbstractSection) - -function TypedSection.__init__(self, ...) - AbstractSection.__init__(self, ...) - self.template = "cbi/tsection" - self.deps = {} - self.excludes = {} - - self.anonymous = false -end - --- Return all matching UCI sections for this TypedSection -function TypedSection.cfgsections(self) - local sections = {} - local map, order = self.map:get() - - for i, k in ipairs(order) do - if map[k][".type"] == self.sectiontype then - if self:checkscope(k) then - table.insert(sections, k) - end - end - end - - return sections -end - --- Creates a new section of this type with the given name (or anonymous) -function TypedSection.create(self, name) - if name then - self.map:set(name, nil, self.sectiontype) - else - name = self.map:add(self.sectiontype) - end - - for k,v in pairs(self.children) do - if v.default then - self.map:set(name, v.option, v.default) - end - end -end - --- Limits scope to sections that have certain option => value pairs -function TypedSection.depends(self, option, value) - table.insert(self.deps, {option=option, value=value}) -end - --- Excludes several sections by name -function TypedSection.exclude(self, field) - self.excludes[field] = true -end - -function TypedSection.parse(self) - if self.addremove then - -- Create - local crval = "cbi.cts." .. self.config .. "." .. self.sectiontype - local name = luci.http.formvalue(crval) - if self.anonymous then - if name then - self:create() - end - else - if name then - -- Ignore if it already exists - if self:cfgvalue(name) then - name = nil; - end - - name = self:checkscope(name) - - if not name then - self.err_invalid = true - end - - if name and name:len() > 0 then - self:create(name) - end - end - end - - -- Remove - crval = "cbi.rts." .. self.config - name = luci.http.formvaluetable(crval) - for k,v in pairs(name) do - if self:cfgvalue(k) and self:checkscope(k) then - self:remove(k) - end - end - end - - for i, k in ipairs(self:cfgsections()) do - AbstractSection.parse_dynamic(self, k) - if luci.http.formvalue("cbi.submit") then - Node.parse(self, k) - end - AbstractSection.parse_optionals(self, k) - end -end - --- Verifies scope of sections -function TypedSection.checkscope(self, section) - -- Check if we are not excluded - if self.excludes[section] then - return nil - end - - -- Check if at least one dependency is met - if #self.deps > 0 and self:cfgvalue(section) then - local stat = false - - for k, v in ipairs(self.deps) do - if self:cfgvalue(section)[v.option] == v.value then - stat = true - end - end - - if not stat then - return nil - end - end - - return self:validate(section) -end - - --- Dummy validate function -function TypedSection.validate(self, section) - return section -end - - ---[[ -AbstractValue - An abstract Value Type - null: Value can be empty - valid: A function returning the value if it is valid otherwise nil - depends: A table of option => value pairs of which one must be true - default: The default value - size: The size of the input fields - rmempty: Unset value if empty - optional: This value is optional (see AbstractSection.optionals) -]]-- -AbstractValue = class(Node) - -function AbstractValue.__init__(self, map, option, ...) - Node.__init__(self, ...) - self.option = option - self.map = map - self.config = map.config - self.tag_invalid = {} - self.deps = {} - - self.rmempty = false - self.default = nil - self.size = nil - self.optional = false -end - --- Add a dependencie to another section field -function AbstractValue.depends(self, field, value) - table.insert(self.deps, {field=field, value=value}) -end - --- Return whether this object should be created -function AbstractValue.formcreated(self, section) - local key = "cbi.opt."..self.config.."."..section - return (luci.http.formvalue(key) == self.option) -end - --- Returns the formvalue for this object -function AbstractValue.formvalue(self, section) - local key = "cbid."..self.map.config.."."..section.."."..self.option - return luci.http.formvalue(key) -end - -function AbstractValue.parse(self, section) - local fvalue = self:formvalue(section) - - if fvalue and fvalue ~= "" then -- If we have a form value, write it to UCI - fvalue = self:validate(fvalue) - if not fvalue then - self.tag_invalid[section] = true - end - if fvalue and not (fvalue == self:cfgvalue(section)) then - self:write(section, fvalue) - end - else -- Unset the UCI or error - if self.rmempty or self.optional then - self:remove(section) - end - end -end - --- Render if this value exists or if it is mandatory -function AbstractValue.render(self, s, scope) - if not self.optional or self:cfgvalue(s) or self:formcreated(s) then - scope = scope or {} - scope.section = s - Node.render(self, scope) - end -end - --- Return the UCI value of this object -function AbstractValue.cfgvalue(self, section) - return self.map:get(section, self.option) -end - --- Validate the form value -function AbstractValue.validate(self, value) - return value -end - --- Write to UCI -function AbstractValue.write(self, section, value) - return self.map:set(section, self.option, value) -end - --- Remove from UCI -function AbstractValue.remove(self, section) - return self.map:del(section, self.option) -end - - - - ---[[ -Value - A one-line value - maxlength: The maximum length - isnumber: The value must be a valid (floating point) number - isinteger: The value must be a valid integer - ispositive: The value must be positive (and a number) -]]-- -Value = class(AbstractValue) - -function Value.__init__(self, ...) - AbstractValue.__init__(self, ...) - self.template = "cbi/value" - - self.maxlength = nil - self.isnumber = false - self.isinteger = false -end - --- This validation is a bit more complex -function Value.validate(self, val) - if self.maxlength and tostring(val):len() > self.maxlength then - val = nil - end - - return luci.util.validate(val, self.isnumber, self.isinteger) -end - - --- DummyValue - This does nothing except being there -DummyValue = class(AbstractValue) - -function DummyValue.__init__(self, map, ...) - AbstractValue.__init__(self, map, ...) - self.template = "cbi/dvalue" - self.value = nil -end - -function DummyValue.parse(self) - -end - -function DummyValue.render(self, s) - luci.template.render(self.template, {self=self, section=s}) -end - - ---[[ -Flag - A flag being enabled or disabled -]]-- -Flag = class(AbstractValue) - -function Flag.__init__(self, ...) - AbstractValue.__init__(self, ...) - self.template = "cbi/fvalue" - - self.enabled = "1" - self.disabled = "0" -end - --- A flag can only have two states: set or unset -function Flag.parse(self, section) - local fvalue = self:formvalue(section) - - if fvalue then - fvalue = self.enabled - else - fvalue = self.disabled - end - - if fvalue == self.enabled or (not self.optional and not self.rmempty) then - if not(fvalue == self:cfgvalue(section)) then - self:write(section, fvalue) - end - else - self:remove(section) - end -end - - - ---[[ -ListValue - A one-line value predefined in a list - widget: The widget that will be used (select, radio) -]]-- -ListValue = class(AbstractValue) - -function ListValue.__init__(self, ...) - AbstractValue.__init__(self, ...) - self.template = "cbi/lvalue" - self.keylist = {} - self.vallist = {} - - self.size = 1 - self.widget = "select" -end - -function ListValue.value(self, key, val) - val = val or key - table.insert(self.keylist, tostring(key)) - table.insert(self.vallist, tostring(val)) -end - -function ListValue.validate(self, val) - if luci.util.contains(self.keylist, val) then - return val - else - return nil - end -end - - - ---[[ -MultiValue - Multiple delimited values - widget: The widget that will be used (select, checkbox) - delimiter: The delimiter that will separate the values (default: " ") -]]-- -MultiValue = class(AbstractValue) - -function MultiValue.__init__(self, ...) - AbstractValue.__init__(self, ...) - self.template = "cbi/mvalue" - self.keylist = {} - self.vallist = {} - - self.widget = "checkbox" - self.delimiter = " " -end - -function MultiValue.value(self, key, val) - val = val or key - table.insert(self.keylist, tostring(key)) - table.insert(self.vallist, tostring(val)) -end - -function MultiValue.valuelist(self, section) - local val = self:cfgvalue(section) - - if not(type(val) == "string") then - return {} - end - - return luci.util.split(val, self.delimiter) -end - -function MultiValue.validate(self, val) - if not(type(val) == "string") then - return nil - end - - local result = "" - - for value in val:gmatch("[^\n]+") do - if luci.util.contains(self.keylist, value) then - result = result .. self.delimiter .. value - end - end - - if result:len() > 0 then - return result:sub(self.delimiter:len() + 1) - else - return nil - end -end \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/dvalue.htm b/libs/cbi/src/view/cbi/dvalue.htm deleted file mode 100644 index f54667def..000000000 --- a/libs/cbi/src/view/cbi/dvalue.htm +++ /dev/null @@ -1,12 +0,0 @@ -<%+cbi/valueheader%> -<% if self.value then - if type(self.value) == "function" then %> - <%=self:value(section)%> -<% else %> - <%=self.value%> -<% end -else %> - <%=self:cfgvalue(section)%> -<% end %> -  -<%+cbi/valuefooter%> diff --git a/libs/cbi/src/view/cbi/footer.htm b/libs/cbi/src/view/cbi/footer.htm deleted file mode 100644 index 2acf710cd..000000000 --- a/libs/cbi/src/view/cbi/footer.htm +++ /dev/null @@ -1,7 +0,0 @@ -
- - - -
- -<%+footer%> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/full_valuefooter.htm b/libs/cbi/src/view/cbi/full_valuefooter.htm deleted file mode 100644 index 6151a3a66..000000000 --- a/libs/cbi/src/view/cbi/full_valuefooter.htm +++ /dev/null @@ -1,8 +0,0 @@ -
<%=self.description%> 
-
- <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
- <% if #self.deps > 0 then %><% end %> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/full_valueheader.htm b/libs/cbi/src/view/cbi/full_valueheader.htm deleted file mode 100644 index 062efa2dd..000000000 --- a/libs/cbi/src/view/cbi/full_valueheader.htm +++ /dev/null @@ -1,3 +0,0 @@ -
"> -
<%=self.title%>
-
\ No newline at end of file diff --git a/libs/cbi/src/view/cbi/fvalue.htm b/libs/cbi/src/view/cbi/fvalue.htm deleted file mode 100644 index b609f1d4f..000000000 --- a/libs/cbi/src/view/cbi/fvalue.htm +++ /dev/null @@ -1,3 +0,0 @@ -<%+cbi/valueheader%> - " name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" /> -<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/header.htm b/libs/cbi/src/view/cbi/header.htm deleted file mode 100644 index 4229aaf0d..000000000 --- a/libs/cbi/src/view/cbi/header.htm +++ /dev/null @@ -1,7 +0,0 @@ -<%+header%> -
-
- - - -
diff --git a/libs/cbi/src/view/cbi/lvalue.htm b/libs/cbi/src/view/cbi/lvalue.htm deleted file mode 100644 index f1ae5a093..000000000 --- a/libs/cbi/src/view/cbi/lvalue.htm +++ /dev/null @@ -1,16 +0,0 @@ -<%+cbi/valueheader%> -<% if self.widget == "select" then %> - -<% elseif self.widget == "radio" then - local c = 0; - for i, key in pairs(self.keylist) do - c = c + 1%> - <%=self.vallist[i]%>"<% if self:cfgvalue(section) == key then %> checked="checked"<% end %> value="<%=key%>" /> -<% if c == self.size then c = 0 %>
-<% end end %> -<% end %> -<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/map.htm b/libs/cbi/src/view/cbi/map.htm deleted file mode 100644 index 835393c1c..000000000 --- a/libs/cbi/src/view/cbi/map.htm +++ /dev/null @@ -1,6 +0,0 @@ -
-

<%=self.title%>

-
<%=self.description%>
-<% self:render_children() %> -
-
diff --git a/libs/cbi/src/view/cbi/mvalue.htm b/libs/cbi/src/view/cbi/mvalue.htm deleted file mode 100644 index bed66e569..000000000 --- a/libs/cbi/src/view/cbi/mvalue.htm +++ /dev/null @@ -1,19 +0,0 @@ -<% -local v = self:valuelist(section) -%> -<%+cbi/valueheader%> -<% if self.widget == "select" then %> - -<% elseif self.widget == "checkbox" then - local c = 0; - for i, key in pairs(self.keylist) do - c = c + 1%> - <%=self.vallist[i]%>[]"<% if luci.util.contains(v, key) then %> checked="checked"<% end %> value="<%=key%>" /> -<% if c == self.size then c = 0 %>
-<% end end %> -<% end %> -<%+cbi/valuefooter%> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/nsection.htm b/libs/cbi/src/view/cbi/nsection.htm deleted file mode 100644 index fff597ad0..000000000 --- a/libs/cbi/src/view/cbi/nsection.htm +++ /dev/null @@ -1,20 +0,0 @@ -<% if self:cfgvalue(self.section) then -section = self.section %> -
-

<%=self.title%>

-
<%=self.description%>
- <% if self.addremove then %>
- -
<% end %> -
-<%+cbi/ucisection%> -
-
-
-<% elseif self.addremove then %> -
-

<%=self.title%>

-
<%=self.description%>
- -
-<% end %> diff --git a/libs/cbi/src/view/cbi/tblsection.htm b/libs/cbi/src/view/cbi/tblsection.htm deleted file mode 100644 index df16efbed..000000000 --- a/libs/cbi/src/view/cbi/tblsection.htm +++ /dev/null @@ -1,39 +0,0 @@ -
-

<%=self.title%>

-
<%=self.description%>
-
-
-<% for i, k in pairs(self.children) do %> -
<%=k.title%>
-<% end %> -
-
-<% for i, k in pairs(self.children) do %> -
<%=k.description%>
-<% end %> -
-<% for i, k in ipairs(self:cfgsections()) do%> - <% if not self.anonymous then %>

<%=k%>

<% end %> -<% -section = k -scope = {valueheader = "cbi/tiny_valueheader", valuefooter = "cbi/tiny_valuefooter"} -%> -
-<%+cbi/ucisection%> - <% if self.addremove then %>
- -
<% end %> -
-<% end %> -<% if self.addremove then %> -
- <% if self.anonymous then %> - - <% else %> - - - <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
-
-<% end %> -
diff --git a/libs/cbi/src/view/cbi/tiny_valuefooter.htm b/libs/cbi/src/view/cbi/tiny_valuefooter.htm deleted file mode 100644 index e65ebb6c0..000000000 --- a/libs/cbi/src/view/cbi/tiny_valuefooter.htm +++ /dev/null @@ -1,6 +0,0 @@ - <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
- <% if #self.deps > 0 then %><% end %> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/tiny_valueheader.htm b/libs/cbi/src/view/cbi/tiny_valueheader.htm deleted file mode 100644 index b9b26bd6a..000000000 --- a/libs/cbi/src/view/cbi/tiny_valueheader.htm +++ /dev/null @@ -1 +0,0 @@ -
"> diff --git a/libs/cbi/src/view/cbi/tsection.htm b/libs/cbi/src/view/cbi/tsection.htm deleted file mode 100644 index 37b18b5d4..000000000 --- a/libs/cbi/src/view/cbi/tsection.htm +++ /dev/null @@ -1,25 +0,0 @@ -
-

<%=self.title%>

-
<%=self.description%>
-<% for i, k in ipairs(self:cfgsections()) do%> - <% if self.addremove then %>
- -
<% end %> - <% if not self.anonymous then %>

<%=k%>

<% end %> -<% section = k %> -
-<%+cbi/ucisection%> -
-
-<% end %> -<% if self.addremove then %> -
- <% if self.anonymous then %> - - <% else %> - - - <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
-<% end %> -
diff --git a/libs/cbi/src/view/cbi/ucisection.htm b/libs/cbi/src/view/cbi/ucisection.htm deleted file mode 100644 index 0abc37e7c..000000000 --- a/libs/cbi/src/view/cbi/ucisection.htm +++ /dev/null @@ -1,20 +0,0 @@ -<% self:render_children(section, scope or {}) %> - <% if #self.optionals[section] > 0 or self.dynamic then %> -
- <% if self.dynamic then %> - - <% else %> - - - <% end %> - -
- <% end %> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/value.htm b/libs/cbi/src/view/cbi/value.htm deleted file mode 100644 index 31bf38f77..000000000 --- a/libs/cbi/src/view/cbi/value.htm +++ /dev/null @@ -1,3 +0,0 @@ -<%+cbi/valueheader%> - size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" id="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=self:cfgvalue(section)%>" /> -<%+cbi/valuefooter%> diff --git a/libs/cbi/src/view/cbi/valuefooter.htm b/libs/cbi/src/view/cbi/valuefooter.htm deleted file mode 100644 index bc9d1b127..000000000 --- a/libs/cbi/src/view/cbi/valuefooter.htm +++ /dev/null @@ -1,5 +0,0 @@ -<% if valuefooter then - include(valuefooter) -else - include("cbi/full_valuefooter") -end %> \ No newline at end of file diff --git a/libs/cbi/src/view/cbi/valueheader.htm b/libs/cbi/src/view/cbi/valueheader.htm deleted file mode 100644 index 8d9802f57..000000000 --- a/libs/cbi/src/view/cbi/valueheader.htm +++ /dev/null @@ -1,5 +0,0 @@ -<% if valueheader then - include(valueheader) -else - include("cbi/full_valueheader") -end %> \ No newline at end of file diff --git a/libs/core/luasrc/bits.lua b/libs/core/luasrc/bits.lua new file mode 100644 index 000000000..13b4c3066 --- /dev/null +++ b/libs/core/luasrc/bits.lua @@ -0,0 +1,542 @@ +--[[ +/* + * Copyright (c) 2007 Tim Kelly/Dialectronics + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +--]] + +--[[ +/* + * Copyright (c) 2007 Tim Kelly/Dialectronics + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to permit + * persons to whom the Software is furnished to do so, subject to the + * following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT + * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR + * THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +--]] + +module("luci.bits", package.seeall); + +local hex2bin = { + ["0"] = "0000", + ["1"] = "0001", + ["2"] = "0010", + ["3"] = "0011", + ["4"] = "0100", + ["5"] = "0101", + ["6"] = "0110", + ["7"] = "0111", + ["8"] = "1000", + ["9"] = "1001", + ["a"] = "1010", + ["b"] = "1011", + ["c"] = "1100", + ["d"] = "1101", + ["e"] = "1110", + ["f"] = "1111" + } + + + +local bin2hex = { + ["0000"] = "0", + ["0001"] = "1", + ["0010"] = "2", + ["0011"] = "3", + ["0100"] = "4", + ["0101"] = "5", + ["0110"] = "6", + ["0111"] = "7", + ["1000"] = "8", + ["1001"] = "9", + ["1010"] = "A", + ["1011"] = "B", + ["1100"] = "C", + ["1101"] = "D", + ["1110"] = "E", + ["1111"] = "F" + } + +--[[ +local dec2hex = { + ["0"] = "0", + ["1"] = "1", + ["2"] = "2", + ["3"] = "3", + ["4"] = "4", + ["5"] = "5", + ["6"] = "6", + ["7"] = "7", + ["8"] = "8", + ["9"] = "9", + ["10"] = "A", + ["11"] = "B", + ["12"] = "C", + ["13"] = "D", + ["14"] = "E", + ["15"] = "F" + } +--]] + + +-- These functions are big-endian and take up to 32 bits + +-- Hex2Bin +-- Bin2Hex +-- Hex2Dec +-- Dec2Hex +-- Bin2Dec +-- Dec2Bin + + +function Hex2Bin(s) + +-- s -> hexadecimal string + +local ret = "" +local i = 0 + + + for i in string.gfind(s, ".") do + i = string.lower(i) + + ret = ret..hex2bin[i] + + end + + return ret +end + + +function Bin2Hex(s) + +-- s -> binary string + +local l = 0 +local h = "" +local b = "" +local rem + +l = string.len(s) +rem = l % 4 +l = l-1 +h = "" + + -- need to prepend zeros to eliminate mod 4 + if (rem > 0) then + s = string.rep("0", 4 - rem)..s + end + + for i = 1, l, 4 do + b = string.sub(s, i, i+3) + h = h..bin2hex[b] + end + + return h + +end + + +function Bin2Dec(s) + +-- s -> binary string + +local num = 0 +local ex = string.len(s) - 1 +local l = 0 + + l = ex + 1 + for i = 1, l do + b = string.sub(s, i, i) + if b == "1" then + num = num + 2^ex + end + ex = ex - 1 + end + + return string.format("%u", num) + +end + + + +function Dec2Bin(s, num) + +-- s -> Base10 string +-- num -> string length to extend to + +local n + + if (num == nil) then + n = 0 + else + n = num + end + + s = string.format("%x", s) + + s = Hex2Bin(s) + + while string.len(s) < n do + s = "0"..s + end + + return s + +end + + + + +function Hex2Dec(s) + +-- s -> hexadecimal string + +local s = Hex2Bin(s) + + return Bin2Dec(s) + +end + + + +function Dec2Hex(s) + +-- s -> Base10 string + + s = string.format("%x", s) + + return s + +end + + + + +-- These functions are big-endian and will extend to 32 bits + +-- BMAnd +-- BMNAnd +-- BMOr +-- BMXOr +-- BMNot + + +function BMAnd(v, m) + +-- v -> hex string to be masked +-- m -> hex string mask + +-- s -> hex string as masked + +-- bv -> binary string of v +-- bm -> binary string mask + +local bv = Hex2Bin(v) +local bm = Hex2Bin(m) + +local i = 0 +local s = "" + + while (string.len(bv) < 32) do + bv = "0000"..bv + end + + while (string.len(bm) < 32) do + bm = "0000"..bm + end + + + for i = 1, 32 do + cv = string.sub(bv, i, i) + cm = string.sub(bm, i, i) + if cv == cm then + if cv == "1" then + s = s.."1" + else + s = s.."0" + end + else + s = s.."0" + + end + end + + return Bin2Hex(s) + +end + + +function BMNAnd(v, m) + +-- v -> hex string to be masked +-- m -> hex string mask + +-- s -> hex string as masked + +-- bv -> binary string of v +-- bm -> binary string mask + +local bv = Hex2Bin(v) +local bm = Hex2Bin(m) + +local i = 0 +local s = "" + + while (string.len(bv) < 32) do + bv = "0000"..bv + end + + while (string.len(bm) < 32) do + bm = "0000"..bm + end + + + for i = 1, 32 do + cv = string.sub(bv, i, i) + cm = string.sub(bm, i, i) + if cv == cm then + if cv == "1" then + s = s.."0" + else + s = s.."1" + end + else + s = s.."1" + + end + end + + return Bin2Hex(s) + +end + + + +function BMOr(v, m) + +-- v -> hex string to be masked +-- m -> hex string mask + +-- s -> hex string as masked + +-- bv -> binary string of v +-- bm -> binary string mask + +local bv = Hex2Bin(v) +local bm = Hex2Bin(m) + +local i = 0 +local s = "" + + while (string.len(bv) < 32) do + bv = "0000"..bv + end + + while (string.len(bm) < 32) do + bm = "0000"..bm + end + + + for i = 1, 32 do + cv = string.sub(bv, i, i) + cm = string.sub(bm, i, i) + if cv == "1" then + s = s.."1" + elseif cm == "1" then + s = s.."1" + else + s = s.."0" + end + end + + return Bin2Hex(s) + +end + +function BMXOr(v, m) + +-- v -> hex string to be masked +-- m -> hex string mask + +-- s -> hex string as masked + +-- bv -> binary string of v +-- bm -> binary string mask + +local bv = Hex2Bin(v) +local bm = Hex2Bin(m) + +local i = 0 +local s = "" + + while (string.len(bv) < 32) do + bv = "0000"..bv + end + + while (string.len(bm) < 32) do + bm = "0000"..bm + end + + + for i = 1, 32 do + cv = string.sub(bv, i, i) + cm = string.sub(bm, i, i) + if cv == "1" then + if cm == "0" then + s = s.."1" + else + s = s.."0" + end + elseif cm == "1" then + if cv == "0" then + s = s.."1" + else + s = s.."0" + end + else + -- cv and cm == "0" + s = s.."0" + end + end + + return Bin2Hex(s) + +end + + +function BMNot(v, m) + +-- v -> hex string to be masked +-- m -> hex string mask + +-- s -> hex string as masked + +-- bv -> binary string of v +-- bm -> binary string mask + +local bv = Hex2Bin(v) +local bm = Hex2Bin(m) + +local i = 0 +local s = "" + + while (string.len(bv) < 32) do + bv = "0000"..bv + end + + while (string.len(bm) < 32) do + bm = "0000"..bm + end + + + for i = 1, 32 do + cv = string.sub(bv, i, i) + cm = string.sub(bm, i, i) + if cm == "1" then + if cv == "1" then + -- turn off + s = s.."0" + else + -- turn on + s = s.."1" + end + else + -- leave untouched + s = s..cv + + end + end + + return Bin2Hex(s) + +end + + +-- these functions shift right and left, adding zeros to lost or gained bits +-- returned values are 32 bits long + +-- BShRight(v, nb) +-- BShLeft(v, nb) + + +function BShRight(v, nb) + +-- v -> hexstring value to be shifted +-- nb -> number of bits to shift to the right + +-- s -> binary string of v + +local s = Hex2Bin(v) + + while (string.len(s) < 32) do + s = "0000"..s + end + + s = string.sub(s, 1, 32 - nb) + + while (string.len(s) < 32) do + s = "0"..s + end + + return Bin2Hex(s) + +end + +function BShLeft(v, nb) + +-- v -> hexstring value to be shifted +-- nb -> number of bits to shift to the right + +-- s -> binary string of v + +local s = Hex2Bin(v) + + while (string.len(s) < 32) do + s = "0000"..s + end + + s = string.sub(s, nb + 1, 32) + + while (string.len(s) < 32) do + s = s.."0" + end + + return Bin2Hex(s) + +end \ No newline at end of file diff --git a/libs/core/luasrc/debug.lua b/libs/core/luasrc/debug.lua new file mode 100644 index 000000000..a56400f34 --- /dev/null +++ b/libs/core/luasrc/debug.lua @@ -0,0 +1,2 @@ +module("luci.debug", package.seeall) +__file__ = debug.getinfo(1, 'S').source:sub(2) \ No newline at end of file diff --git a/libs/core/luasrc/fs.lua b/libs/core/luasrc/fs.lua new file mode 100644 index 000000000..5c1f2a051 --- /dev/null +++ b/libs/core/luasrc/fs.lua @@ -0,0 +1,129 @@ +--[[ +LuCI - Filesystem tools + +Description: +A module offering often needed filesystem manipulation functions + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.fs", package.seeall) + +require("posix") + +-- Glob +glob = posix.glob + +-- Checks whether a file exists +function isfile(filename) + local fp = io.open(filename, "r") + if fp then fp:close() end + return fp ~= nil +end + +-- Returns the content of file +function readfile(filename) + local fp, err = io.open(filename) + + if fp == nil then + return nil, err + end + + local data = fp:read("*a") + fp:close() + return data +end + +-- Writes given data to a file +function writefile(filename, data) + local fp, err = io.open(filename, "w") + + if fp == nil then + return nil, err + end + + fp:write(data) + fp:close() + + return true +end + +-- Returns the file modification date/time of "path" +function mtime(path) + return posix.stat(path, "mtime") +end + +-- basename wrapper +basename = posix.basename + +-- dirname wrapper +dirname = posix.dirname + +-- dir wrapper +dir = posix.dir + +-- wrapper for posix.mkdir +function mkdir(path, recursive) + if recursive then + local base = "." + + if path:sub(1,1) == "/" then + base = "" + path = path:gsub("^/+","") + end + + for elem in path:gmatch("([^/]+)/*") do + base = base .. "/" .. elem + + local stat = posix.stat( base ) + + if not stat then + local stat, errmsg, errno = posix.mkdir( base ) + + if type(stat) ~= "number" or stat ~= 0 then + return stat, errmsg, errno + end + else + if stat.type ~= "directory" then + return nil, base .. ": File exists", 17 + end + end + end + + return 0 + else + return posix.mkdir( path ) + end +end + +-- Alias for posix.rmdir +rmdir = posix.rmdir + +-- Alias for posix.stat +stat = posix.stat + +-- Alias for posix.chmod +chmod = posix.chmod + +-- Alias for posix.link +link = posix.link + +-- Alias for posix.unlink +unlink = posix.unlink diff --git a/libs/core/luasrc/init.lua b/libs/core/luasrc/init.lua new file mode 100644 index 000000000..ce52d0aad --- /dev/null +++ b/libs/core/luasrc/init.lua @@ -0,0 +1,29 @@ +--[[ +LuCI - Lua Configuration Interface + +Description: +Main class + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci", package.seeall) + +__version__ = "0.5" +__appname__ = "LuCI" diff --git a/libs/core/luasrc/model/ipkg.lua b/libs/core/luasrc/model/ipkg.lua new file mode 100644 index 000000000..e95a2620a --- /dev/null +++ b/libs/core/luasrc/model/ipkg.lua @@ -0,0 +1,140 @@ +--[[ +LuCI - IPKG wrapper library + +Description: +Wrapper for the ipkg Package manager + +Any return value of false or nil can be interpreted as an error + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.model.ipkg", package.seeall) +require("luci.sys") +require("luci.util") + +ipkg = "ipkg" + +-- Returns repository information +function info(pkg) + return _lookup("info", pkg) +end + +-- Returns a table with status information +function status(pkg) + return _lookup("status", pkg) +end + +-- Installs packages +function install(...) + return _action("install", ...) +end + +-- Returns whether a package is installed +function installed(pkg, ...) + local p = status(...)[pkg] + return (p and p.Status and p.Status.installed) +end + +-- Removes packages +function remove(...) + return _action("remove", ...) +end + +-- Updates package lists +function update() + return _action("update") +end + +-- Upgrades installed packages +function upgrade() + return _action("upgrade") +end + + +-- Internal action function +function _action(cmd, ...) + local pkg = "" + arg.n = nil + for k, v in pairs(arg) do + pkg = pkg .. " '" .. v:gsub("'", "") .. "'" + end + + local c = ipkg.." "..cmd.." "..pkg.." >/dev/null 2>&1" + local r = os.execute(c) + return (r == 0), r +end + +-- Internal lookup function +function _lookup(act, pkg) + local cmd = ipkg .. " " .. act + if pkg then + cmd = cmd .. " '" .. pkg:gsub("'", "") .. "'" + end + + return _parselist(luci.sys.exec(cmd .. " 2>/dev/null")) +end + +-- Internal parser function +function _parselist(rawdata) + if type(rawdata) ~= "string" then + error("IPKG: Invalid rawdata given") + end + + rawdata = luci.util.split(rawdata) + local data = {} + local c = {} + local l = nil + + for k, line in pairs(rawdata) do + if line:sub(1, 1) ~= " " then + local split = luci.util.split(line, ":", 1) + local key = nil + local val = nil + + if split[1] then + key = luci.util.trim(split[1]) + end + + if split[2] then + val = luci.util.trim(split[2]) + end + + if key and val then + if key == "Package" then + c = {Package = val} + data[val] = c + elseif key == "Status" then + c.Status = {} + for i, j in pairs(luci.util.split(val, " ")) do + c.Status[j] = true + end + else + c[key] = val + end + l = key + end + else + -- Multi-line field + c[l] = c[l] .. "\n" .. line:sub(2) + end + end + + return data +end \ No newline at end of file diff --git a/libs/core/luasrc/model/uci.lua b/libs/core/luasrc/model/uci.lua new file mode 100644 index 000000000..39354bed1 --- /dev/null +++ b/libs/core/luasrc/model/uci.lua @@ -0,0 +1,92 @@ +--[[ +LuCI - UCI mpdel + +Description: +Generalized UCI model + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.model.uci", package.seeall) + +-- Default savedir +savedir = "/tmp/.uci" + +-- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper +if pcall(require, "uci") then + Session = require("luci.model.uci.libuci").Session +else + Session = require("luci.model.uci.wrapper").Session +end + +-- The default Session +local default = Session() +local state = Session("/var/state") + +-- The state Session +function StateSession() + return state +end + + +-- Wrapper for "uci add" +function add(...) + return default:add(...) +end + + +-- Wrapper for "uci changes" +function changes(...) + return default:changes(...) +end + +-- Wrapper for "uci commit" +function commit(...) + return default:commit(...) +end + + +-- Wrapper for "uci del" +function del(...) + return default:del(...) +end + + +-- Wrapper for "uci get" +function get(...) + return default:get(...) +end + + +-- Wrapper for "uci revert" +function revert(...) + return default:revert(...) +end + + +-- Wrapper for "uci show" +function sections(...) + return default:sections(...) +end + + +-- Wrapper for "uci set" +function set(...) + return default:set(...) +end \ No newline at end of file diff --git a/libs/core/luasrc/model/uci/libuci.lua b/libs/core/luasrc/model/uci/libuci.lua new file mode 100644 index 000000000..9a1112500 --- /dev/null +++ b/libs/core/luasrc/model/uci/libuci.lua @@ -0,0 +1,193 @@ +--[[ +LuCI - UCI libuci wrapper + +Description: +Wrapper for the libuci Lua bindings + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.model.uci.libuci", package.seeall) + +require("uci") +require("luci.util") +require("luci.sys") + +-- Session class +Session = luci.util.class() + +-- Session constructor +function Session.__init__(self, savedir) + self.ucicmd = savedir and "uci -P " .. savedir or "uci" + self.savedir = savedir or luci.model.uci.savedir +end + +function Session.add(self, config, section_type) + return self:_uci("add " .. _path(config) .. " " .. _path(section_type)) +end + +function Session.changes(self, config) + return self:_uci("changes " .. _path(config)) +end + +function Session.commit(self, config) + self:t_load(config) + return self:t_commit(config) +end + +function Session.del(self, config, section, option) + return self:_uci2("del " .. _path(config, section, option)) +end + +function Session.get(self, config, section, option) + self:t_load(config) + return self:t_get(config, section, option) +end + +function Session.revert(self, config) + self:t_load(config) + return self:t_revert(config) +end + +function Session.sections(self, config) + self:t_load(config) + return self:t_sections(config) +end + +function Session.set(self, config, section, option, value) + self:t_load(config) + return self:t_set(config, section, option, value) and self:t_save(config) +end + +function Session.synchronize(self) + return uci.set_savedir(self.savedir) +end + + +-- UCI-Transactions + +function Session.t_load(self, config) + return self:synchronize() and uci.load(config) +end + +function Session.t_save(self, config) + return uci.save(config) +end + +function Session.t_add(self, config, type) + self:t_save(config) + local r = self:add(config, type) + self:t_load(config) + return r +end + +function Session.t_commit(self, config) + return uci.commit(config) +end + +function Session.t_del(self, config, section, option) + self:t_save(config) + local r = self:del(config, section, option) + self:t_load(config) + return r +end + +function Session.t_get(self, config, section, option) + if option then + return uci.get(config, section, option) + else + return uci.get(config, section) + end +end + +function Session.t_revert(self, config) + return uci.revert(config) +end + +function Session.t_sections(self, config) + local raw = uci.get_all(config) + if not raw then + return nil + end + + local s = {} + local o = {} + + for i, sec in ipairs(raw) do + table.insert(o, sec.name) + + s[sec.name] = sec.options + s[sec.name][".type"] = sec.type + end + + return s, o +end + +function Session.t_set(self, config, section, option, value) + if option then + return uci.set(config.."."..section.."."..option.."="..value) + else + return uci.set(config.."."..section.."="..value) + end +end + +-- Internal functions -- + + +function Session._uci(self, cmd) + local res = luci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd) + + if res:len() == 0 then + return nil + else + return res:sub(1, res:len()-1) + end +end + +function Session._uci2(self, cmd) + local res = luci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd) + + if res:len() > 0 then + return false, res + else + return true + end +end + +-- Build path (config.section.option=value) and prevent command injection +function _path(...) + local result = "" + + -- Not using ipairs because it is not reliable in case of nil arguments + arg.n = nil + for k,v in pairs(arg) do + if v then + v = tostring(v) + if k == 1 then + result = "'" .. v:gsub("['.]", "") .. "'" + elseif k < 4 then + result = result .. ".'" .. v:gsub("['.]", "") .. "'" + elseif k == 4 then + result = result .. "='" .. v:gsub("'", "") .. "'" + end + end + end + return result +end \ No newline at end of file diff --git a/libs/core/luasrc/model/uci/wrapper.lua b/libs/core/luasrc/model/uci/wrapper.lua new file mode 100644 index 000000000..e063b272c --- /dev/null +++ b/libs/core/luasrc/model/uci/wrapper.lua @@ -0,0 +1,171 @@ +--[[ +LuCI - UCI wrapper library + +Description: +Wrapper for the /sbin/uci application, syntax of implemented functions +is comparable to the syntax of the uci application + +Any return value of false or nil can be interpreted as an error + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.model.uci.wrapper", package.seeall) + +require("luci.util") +require("luci.sys") + +-- Session class +Session = luci.util.class() + +-- Session constructor +function Session.__init__(self, savedir) + self.ucicmd = savedir and "uci -P " .. savedir or "uci" +end + +function Session.add(self, config, section_type) + return self:_uci("add " .. _path(config) .. " " .. _path(section_type)) +end + +function Session.changes(self, config) + return self:_uci("changes " .. _path(config)) +end + +function Session.commit(self, config) + return self:_uci2("commit " .. _path(config)) +end + +function Session.del(self, config, section, option) + return self:_uci2("del " .. _path(config, section, option)) +end + +function Session.get(self, config, section, option) + return self:_uci("get " .. _path(config, section, option)) +end + +function Session.revert(self, config) + return self:_uci2("revert " .. _path(config)) +end + +function Session.sections(self, config) + if not config then + return nil + end + + local r1, r2 = self:_uci3("show " .. _path(config)) + if type(r1) == "table" then + return r1, r2 + else + return nil, r2 + end +end + +function Session.set(self, config, section, option, value) + return self:_uci2("set " .. _path(config, section, option, value)) +end + +function Session.synchronize(self) end + +-- Dummy transaction functions + +function Session.t_load(self) end +function Session.t_save(self) end + +Session.t_add = Session.add +Session.t_commit = Session.commit +Session.t_del = Session.del +Session.t_get = Session.get +Session.t_revert = Session.revert +Session.t_sections = Session.sections +Session.t_set = Session.set + + + + + +-- Internal functions -- + + +function Session._uci(self, cmd) + local res = luci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd) + + if res:len() == 0 then + return nil + else + return res:sub(1, res:len()-1) + end +end + +function Session._uci2(self, cmd) + local res = luci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd) + + if res:len() > 0 then + return false, res + else + return true + end +end + +function Session._uci3(self, cmd) + local res = luci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd) + if res[1] and res[1]:sub(1, self.ucicmd:len()+1) == self.ucicmd..":" then + return nil, res[1] + end + + local tbl = {} + local ord = {} + + for k,line in pairs(res) do + c, s, t = line:match("^([^.]-)%.([^.]-)=(.-)$") + if c then + tbl[s] = {} + table.insert(ord, s) + tbl[s][".type"] = t + end + + c, s, o, v = line:match("^([^.]-)%.([^.]-)%.([^.]-)=(.-)$") + if c then + tbl[s][o] = v + end + end + + return tbl, ord +end + +-- Build path (config.section.option=value) and prevent command injection +function _path(...) + local result = "" + + -- Not using ipairs because it is not reliable in case of nil arguments + arg.n = nil + for k,v in pairs(arg) do + if v then + v = tostring(v) + if k == 1 then + result = "'" .. v:gsub("['.]", "") .. "'" + elseif k < 4 then + result = result .. ".'" .. v:gsub("['.]", "") .. "'" + elseif k == 4 then + result = result .. "='" .. v:gsub("'", "") .. "'" + end + end + end + return result +end \ No newline at end of file diff --git a/libs/core/luasrc/sys.lua b/libs/core/luasrc/sys.lua new file mode 100644 index 000000000..0399d0e5f --- /dev/null +++ b/libs/core/luasrc/sys.lua @@ -0,0 +1,371 @@ +--[[ +LuCI - System library + +Description: +Utilities for interaction with the Linux system + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.sys", package.seeall) +require("posix") +require("luci.bits") +require("luci.util") +require("luci.fs") + +-- Returns whether a system is bigendian +function bigendian() + local fp = io.open("/bin/sh") + fp:seek("set", 5) + local be = (fp:read(1):byte() ~= 1) + fp:close() + return be +end + +-- Runs "command" and returns its output +function exec(command) + local pp = io.popen(command) + local data = pp:read("*a") + pp:close() + + return data +end + +-- Runs "command" and returns its output as a array of lines +function execl(command) + local pp = io.popen(command) + local line = "" + local data = {} + + while true do + line = pp:read() + if (line == nil) then break end + table.insert(data, line) + end + pp:close() + + return data +end + +-- Uses "luci-flash" to flash a new image file to the system +function flash(image, kpattern) + local cmd = "luci-flash " + if kpattern then + cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' " + end + cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1" + + return os.execute(cmd) +end + +-- Returns the hostname +function hostname() + return io.lines("/proc/sys/kernel/hostname")() +end + +-- Returns the contents of a documented referred by an URL +function httpget(url) + return exec("wget -qO- '"..url:gsub("'", "").."'") +end + +-- Returns the FFLuci-Basedir +function libpath() + return luci.fs.dirname(require("luci.debug").__file__) +end + +-- Returns the load average +function loadavg() + local loadavg = io.lines("/proc/loadavg")() + return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$") +end + +-- Reboots the system +function reboot() + return os.execute("reboot >/dev/null 2>&1") +end + +-- Returns the system type, cpu name, and installed physical memory +function sysinfo() + local c1 = "cat /proc/cpuinfo|grep system\\ typ|cut -d: -f2 2>/dev/null" + local c2 = "uname -m 2>/dev/null" + local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null" + local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null" + local c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null" + + local s = luci.util.trim(exec(c1)) + local m = "" + local r = "" + + if s == "" then + s = luci.util.trim(exec(c2)) + m = luci.util.trim(exec(c3)) + else + m = luci.util.trim(exec(c4)) + end + + r = luci.util.trim(exec(c5)) + + return s, m, r +end + +-- Reads the syslog +function syslog() + return exec("logread") +end + + +group = {} +group.getgroup = posix.getgroup + +net = {} +-- Returns the ARP-Table +function net.arptable() + return _parse_delimited_table(io.lines("/proc/net/arp"), "%s%s+") +end + +-- Returns whether an IP-Adress belongs to a certain net +function net.belongs(ip, ipnet, prefix) + return (net.ip4bin(ip):sub(1, prefix) == net.ip4bin(ipnet):sub(1, prefix)) +end + +-- Detect the default route +function net.defaultroute() + local routes = net.routes() + local route = nil + + for i, r in pairs(luci.sys.net.routes()) do + if r.Destination == "00000000" and (not route or route.Metric > r.Metric) then + route = r + end + end + + return route +end + +-- Returns all available network interfaces +function net.devices() + local devices = {} + for line in io.lines("/proc/net/dev") do + table.insert(devices, line:match(" *(.-):")) + end + return devices +end + +-- Returns the MAC-Address belonging to the given IP-Address +function net.ip4mac(ip) + local mac = nil + + for i, l in ipairs(net.arptable()) do + if l["IP address"] == ip then + mac = l["HW address"] + end + end + + return mac +end + +-- Returns the prefix to a given netmask +function net.mask4prefix(mask) + local bin = net.ip4bin(mask) + + if not bin then + return nil + end + + return #luci.util.split(bin, "1")-1 +end + +-- Returns the kernel routing table +function net.routes() + return _parse_delimited_table(io.lines("/proc/net/route")) +end + +-- Returns the numeric IP to a given hexstring +function net.hexip4(hex, be) + if #hex ~= 8 then + return nil + end + + be = be or bigendian() + + local hexdec = luci.bits.Hex2Dec + + local ip = "" + if be then + ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "." + ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "." + ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "." + ip = ip .. tostring(hexdec(hex:sub(7,8))) + else + ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "." + ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "." + ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "." + ip = ip .. tostring(hexdec(hex:sub(1,2))) + end + + return ip +end + +-- Returns the binary IP to a given IP +function net.ip4bin(ip) + local parts = luci.util.split(ip, '.') + if #parts ~= 4 then + return nil + end + + local decbin = luci.bits.Dec2Bin + + local bin = "" + bin = bin .. decbin(parts[1], 8) + bin = bin .. decbin(parts[2], 8) + bin = bin .. decbin(parts[3], 8) + bin = bin .. decbin(parts[4], 8) + + return bin +end + +-- Tests whether a host is pingable +function net.pingtest(host) + return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1") +end + + +process = {} +process.info = posix.getpid + +-- Sets the gid of a process +function process.setgroup(pid, gid) + return posix.setpid("g", pid, gid) +end + +-- Sets the uid of a process +function process.setuser(pid, uid) + return posix.setpid("u", pid, uid) +end + +user = {} +-- returns user information to a given uid +user.getuser = posix.getpasswd + +-- Changes the user password of given user +function user.setpasswd(user, pwd) + if pwd then + pwd = pwd:gsub("'", "") + end + + if user then + user = user:gsub("'", "") + end + + local cmd = "(echo '"..pwd.."';sleep 1;echo '"..pwd.."')|" + cmd = cmd .. "passwd '"..user.."' >/dev/null 2>&1" + return os.execute(cmd) +end + + +wifi = {} + +function wifi.getiwconfig() + local cnt = exec("/usr/sbin/iwconfig 2>/dev/null") + local iwc = {} + + for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do + local k = l:match("^(.-) ") + l = l:gsub("^(.-) +", "", 1) + if k then + iwc[k] = _parse_mixed_record(l) + end + end + + return iwc +end + +function wifi.iwscan() + local cnt = exec("iwlist scan 2>/dev/null") + local iws = {} + + for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do + local k = l:match("^(.-) ") + l = l:gsub("^[^\n]+", "", 1) + l = luci.util.trim(l) + if k then + iws[k] = {} + for j, c in pairs(luci.util.split(l, "\n Cell")) do + c = c:gsub("^(.-)- ", "", 1) + c = luci.util.split(c, "\n", 7) + c = table.concat(c, "\n", 1) + table.insert(iws[k], _parse_mixed_record(c)) + end + end + end + + return iws +end + + +-- Internal functions + +function _parse_delimited_table(iter, delimiter) + delimiter = delimiter or "%s+" + + local data = {} + local trim = luci.util.trim + local split = luci.util.split + + local keys = split(trim(iter()), delimiter, nil, true) + for i, j in pairs(keys) do + keys[i] = trim(keys[i]) + end + + for line in iter do + local row = {} + line = trim(line) + if #line > 0 then + for i, j in pairs(split(line, delimiter, nil, true)) do + if keys[i] then + row[keys[i]] = j + end + end + end + table.insert(data, row) + end + + return data +end + +function _parse_mixed_record(cnt) + local data = {} + + for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n")) do + for j, f in pairs(luci.util.split(luci.util.trim(l), " ")) do + local k, x, v = f:match('([^%s][^:=]+) *([:=]*) *"*([^\n"]*)"*') + + if k then + if x == "" then + table.insert(data, k) + else + data[k] = v + end + end + end + end + + return data +end \ No newline at end of file diff --git a/libs/core/luasrc/sys/iptparser.lua b/libs/core/luasrc/sys/iptparser.lua new file mode 100644 index 000000000..6450c3072 --- /dev/null +++ b/libs/core/luasrc/sys/iptparser.lua @@ -0,0 +1,245 @@ +--[[ +LuCI - Iptables parser and query library + +Copyright 2008 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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +$Id$ + +]]-- + +module("luci.sys.iptparser", package.seeall) +require("luci.sys") +require("luci.util") + + +IptParser = luci.util.class() + +--[[ +IptParser.__init__( ... ) + +The class constructor, initializes the internal lookup table. +]]-- + +function IptParser.__init__( self, ... ) + self._rules = { } + self._chain = nil + self:_parse_rules() +end + + +--[[ +IptParser.find( args ) + +Find all firewall rules that match the given criteria. Expects a table with search criteria as only argument. +If args is nil or an empty table then all rules will be returned. + +The following keys in the args table are recognized: + + - table Match rules that are located within the given table + - chain Match rules that are located within the given chain + - target Match rules with the given target + - protocol Match rules that match the given protocol, rules with protocol "all" are always matched + - source Match rules with the given source, rules with source "0.0.0.0/0" are always matched + - destination Match rules with the given destination, rules with destination "0.0.0.0/0" are always matched + - inputif Match rules with the given input interface, rules with input interface "*" (=all) are always matched + - outputif Match rules with the given output interface, rules with output interface "*" (=all) are always matched + - flags Match rules that match the given flags, current supported values are "-f" (--fragment) and "!f" (! --fragment) + - options Match rules containing all given options + +The return value is a list of tables representing the matched rules. +Each rule table contains the following fields: + + - index The index number of the rule + - table The table where the rule is located, can be one of "filter", "nat" or "mangle" + - chain The chain where the rule is located, e.g. "INPUT" or "postrouting_wan" + - target The rule target, e.g. "REJECT" or "DROP" + - protocol The matching protocols, e.g. "all" or "tcp" + - flags Special rule options ("--", "-f" or "!f") + - inputif Input interface of the rule, e.g. "eth0.0" or "*" for all interfaces + - outputif Output interface of the rule, e.g. "eth0.0" or "*" for all interfaces + - source The source ip range, e.g. "0.0.0.0/0" + - destination The destination ip range, e.g. "0.0.0.0/0" + - options A list of specific options of the rule, e.g. { "reject-with", "tcp-reset" } + - packets The number of packets matched by the rule + - bytes The number of total bytes matched by the rule + +Example: + +ip = luci.sys.iptparser.IptParser() +result = ip.find( { + target="REJECT", + protocol="tcp", + options={ "reject-with", "tcp-reset" } +} ) + +This will match all rules with target "-j REJECT", protocol "-p tcp" (or "-p all") and the option "--reject-with tcp-reset". + +]]-- + +function IptParser.find( self, args ) + + local args = args or { } + local rv = { } + + for i, rule in ipairs(self._rules) do + local match = true + + -- match table + if not ( not args.table or args.table == rule.table ) then + match = false + end + + -- match chain + if not ( match == true and ( not args.chain or args.chain == rule.chain ) ) then + match = false + end + + -- match target + if not ( match == true and ( not args.target or args.target == rule.target ) ) then + match = false + end + + -- match protocol + if not ( match == true and ( not args.protocol or rule.protocol == "all" or args.protocol == rule.protocol ) ) then + match = false + end + + -- match source (XXX: implement ipcalc stuff so that 192.168.1.0/24 matches 0.0.0.0/0 etc.) + if not ( match == true and ( not args.source or rule.source == "0.0.0.0/0" or rule.source == args.source ) ) then + match = false + end + + -- match destination (XXX: implement ipcalc stuff so that 192.168.1.0/24 matches 0.0.0.0/0 etc.) + if not ( match == true and ( not args.destination or rule.destination == "0.0.0.0/0" or rule.destination == args.destination ) ) then + match = false + end + + -- match input interface + if not ( match == true and ( not args.inputif or rule.inputif == "*" or args.inputif == rule.inputif ) ) then + match = false + end + + -- match output interface + if not ( match == true and ( not args.outputif or rule.outputif == "*" or args.outputif == rule.outputif ) ) then + match = false + end + + -- match flags (the "opt" column) + if not ( match == true and ( not args.flags or rule.flags == args.flags ) ) then + match = false + end + + -- match specific options + if not ( match == true and ( not args.options or self:_match_options( rule.options, args.options ) ) ) then + match = false + end + + + -- insert match + if match == true then + table.insert( rv, rule ) + end + end + + return rv +end + + +--[[ +IptParser.resync() + +Rebuild the internal lookup table, for example when rules have changed through external commands. +]]-- + +function IptParser.resync( self ) + self._rules = { } + self._chain = nil + self:_parse_rules() +end + + +--[[ +IptParser._parse_rules() + +[internal] Parse iptables output from all tables. +]]-- + +function IptParser._parse_rules( self ) + + for i, tbl in ipairs({ "filter", "nat", "mangle" }) do + + for i, rule in ipairs(luci.sys.execl("iptables -t " .. tbl .. " --line-numbers -nxvL")) do + + if rule:find( "Chain " ) == 1 then + + self._chain = rule:gsub("Chain ([^%s]*) .*", "%1") + + else + if rule:find("%d") == 1 then + + local rule_parts = luci.util.split( rule, "%s+", nil, true ) + local rule_details = { } + + rule_details["table"] = tbl + rule_details["chain"] = self._chain + rule_details["index"] = tonumber(rule_parts[1]) + rule_details["packets"] = tonumber(rule_parts[2]) + rule_details["bytes"] = tonumber(rule_parts[3]) + rule_details["target"] = rule_parts[4] + rule_details["protocol"] = rule_parts[5] + rule_details["flags"] = rule_parts[6] + rule_details["inputif"] = rule_parts[7] + rule_details["outputif"] = rule_parts[8] + rule_details["source"] = rule_parts[9] + rule_details["destination"] = rule_parts[10] + rule_details["options"] = { } + + for i = 11, #rule_parts - 1 do + rule_details["options"][i-10] = rule_parts[i] + end + + table.insert( self._rules, rule_details ) + end + end + end + end + + self._chain = nil +end + + +--[[ +IptParser._match_options( optlist1, optlist2 ) + +[internal] Return true if optlist1 contains all elements of optlist2. Return false in all other cases. +]]-- + +function IptParser._match_options( self, o1, o2 ) + + -- construct a hashtable of first options list to speed up lookups + local oh = { } + for i, opt in ipairs( o1 ) do oh[opt] = true end + + -- iterate over second options list + -- each string in o2 must be also present in o1 + -- if o2 contains a string which is not found in o1 then return false + for i, opt in ipairs( o2 ) do + if not oh[opt] then + return false + end + end + + return true +end diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua new file mode 100644 index 000000000..0559fff6f --- /dev/null +++ b/libs/core/luasrc/util.lua @@ -0,0 +1,215 @@ +--[[ +LuCI - Utility library + +Description: +Several common useful Lua functions + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.util", package.seeall) + + +-- Lua simplified Python-style OO class support emulation +function class(base) + local class = {} + + local create = function(class, ...) + local inst = {} + setmetatable(inst, {__index = class}) + + if inst.__init__ then + local stat, err = pcall(inst.__init__, inst, ...) + if not stat then + error(err) + end + end + + return inst + end + + local classmeta = {__call = create} + + if base then + classmeta.__index = base + end + + setmetatable(class, classmeta) + return class +end + + +-- Clones an object (deep on-demand) +function clone(object, deep) + local copy = {} + + for k, v in pairs(object) do + if deep and type(v) == "table" then + v = clone(v, deep) + end + copy[k] = v + end + + setmetatable(copy, getmetatable(object)) + + return copy +end + + +-- Combines two or more numerically indexed tables into one +function combine(...) + local result = {} + for i, a in ipairs(arg) do + for j, v in ipairs(a) do + table.insert(result, v) + end + end + return result +end + + +-- Checks whether a table has an object "value" in it +function contains(table, value) + for k,v in pairs(table) do + if value == v then + return true + end + end + return false +end + + +-- Dumps a table to stdout (useful for testing and debugging) +function dumptable(t, i) + i = i or 0 + for k,v in pairs(t) do + print(string.rep("\t", i) .. k, v) + if type(v) == "table" then + dumptable(v, i+1) + end + end +end + + +-- Escapes all occurences of c in s +function escape(s, c) + c = c or "\\" + return s:gsub(c, "\\" .. c) +end + + +-- Populate obj in the scope of f as key +function extfenv(f, key, obj) + local scope = getfenv(f) + scope[key] = obj +end + + +-- Checks whether an object is an instanceof class +function instanceof(object, class) + local meta = getmetatable(object) + while meta and meta.__index do + if meta.__index == class then + return true + end + meta = getmetatable(meta.__index) + end + return false +end + + +-- Creates valid XML PCDATA from a string +function pcdata(value) + value = value:gsub("&", "&") + value = value:gsub('"', """) + value = value:gsub("'", "'") + value = value:gsub("<", "<") + return value:gsub(">", ">") +end + + +-- Resets the scope of f doing a shallow copy of its scope into a new table +function resfenv(f) + setfenv(f, clone(getfenv(f))) +end + + +-- Splits a string into an array +function split(str, pat, max, regex) + pat = pat or "\n" + max = max or #str + + local t = {} + local c = 1 + + if #str == 0 then + return {""} + end + + if #pat == 0 then + return nil + end + + if max == 0 then + return str + end + + repeat + local s, e = str:find(pat, c, not regex) + table.insert(t, str:sub(c, s and s - 1)) + max = max - 1 + c = e and e + 1 or #str + 1 + until not s or max < 0 + + return t +end + +-- Removes whitespace from beginning and end of a string +function trim(str) + local s = str:gsub("^%s*(.-)%s*$", "%1") + return s +end + +-- Updates given table with new values +function update(t, updates) + for k, v in pairs(updates) do + t[k] = v + end +end + + +-- Updates the scope of f with "extscope" +function updfenv(f, extscope) + update(getfenv(f), extscope) +end + + +-- Validates a variable +function validate(value, cast_number, cast_int) + if cast_number or cast_int then + value = tonumber(value) + end + + if cast_int and value and not(value % 1 == 0) then + value = nil + end + + return value +end \ No newline at end of file diff --git a/libs/core/src/bits.lua b/libs/core/src/bits.lua deleted file mode 100644 index 13b4c3066..000000000 --- a/libs/core/src/bits.lua +++ /dev/null @@ -1,542 +0,0 @@ ---[[ -/* - * Copyright (c) 2007 Tim Kelly/Dialectronics - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT - * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - ---]] - ---[[ -/* - * Copyright (c) 2007 Tim Kelly/Dialectronics - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to permit - * persons to whom the Software is furnished to do so, subject to the - * following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT - * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR - * THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - ---]] - -module("luci.bits", package.seeall); - -local hex2bin = { - ["0"] = "0000", - ["1"] = "0001", - ["2"] = "0010", - ["3"] = "0011", - ["4"] = "0100", - ["5"] = "0101", - ["6"] = "0110", - ["7"] = "0111", - ["8"] = "1000", - ["9"] = "1001", - ["a"] = "1010", - ["b"] = "1011", - ["c"] = "1100", - ["d"] = "1101", - ["e"] = "1110", - ["f"] = "1111" - } - - - -local bin2hex = { - ["0000"] = "0", - ["0001"] = "1", - ["0010"] = "2", - ["0011"] = "3", - ["0100"] = "4", - ["0101"] = "5", - ["0110"] = "6", - ["0111"] = "7", - ["1000"] = "8", - ["1001"] = "9", - ["1010"] = "A", - ["1011"] = "B", - ["1100"] = "C", - ["1101"] = "D", - ["1110"] = "E", - ["1111"] = "F" - } - ---[[ -local dec2hex = { - ["0"] = "0", - ["1"] = "1", - ["2"] = "2", - ["3"] = "3", - ["4"] = "4", - ["5"] = "5", - ["6"] = "6", - ["7"] = "7", - ["8"] = "8", - ["9"] = "9", - ["10"] = "A", - ["11"] = "B", - ["12"] = "C", - ["13"] = "D", - ["14"] = "E", - ["15"] = "F" - } ---]] - - --- These functions are big-endian and take up to 32 bits - --- Hex2Bin --- Bin2Hex --- Hex2Dec --- Dec2Hex --- Bin2Dec --- Dec2Bin - - -function Hex2Bin(s) - --- s -> hexadecimal string - -local ret = "" -local i = 0 - - - for i in string.gfind(s, ".") do - i = string.lower(i) - - ret = ret..hex2bin[i] - - end - - return ret -end - - -function Bin2Hex(s) - --- s -> binary string - -local l = 0 -local h = "" -local b = "" -local rem - -l = string.len(s) -rem = l % 4 -l = l-1 -h = "" - - -- need to prepend zeros to eliminate mod 4 - if (rem > 0) then - s = string.rep("0", 4 - rem)..s - end - - for i = 1, l, 4 do - b = string.sub(s, i, i+3) - h = h..bin2hex[b] - end - - return h - -end - - -function Bin2Dec(s) - --- s -> binary string - -local num = 0 -local ex = string.len(s) - 1 -local l = 0 - - l = ex + 1 - for i = 1, l do - b = string.sub(s, i, i) - if b == "1" then - num = num + 2^ex - end - ex = ex - 1 - end - - return string.format("%u", num) - -end - - - -function Dec2Bin(s, num) - --- s -> Base10 string --- num -> string length to extend to - -local n - - if (num == nil) then - n = 0 - else - n = num - end - - s = string.format("%x", s) - - s = Hex2Bin(s) - - while string.len(s) < n do - s = "0"..s - end - - return s - -end - - - - -function Hex2Dec(s) - --- s -> hexadecimal string - -local s = Hex2Bin(s) - - return Bin2Dec(s) - -end - - - -function Dec2Hex(s) - --- s -> Base10 string - - s = string.format("%x", s) - - return s - -end - - - - --- These functions are big-endian and will extend to 32 bits - --- BMAnd --- BMNAnd --- BMOr --- BMXOr --- BMNot - - -function BMAnd(v, m) - --- v -> hex string to be masked --- m -> hex string mask - --- s -> hex string as masked - --- bv -> binary string of v --- bm -> binary string mask - -local bv = Hex2Bin(v) -local bm = Hex2Bin(m) - -local i = 0 -local s = "" - - while (string.len(bv) < 32) do - bv = "0000"..bv - end - - while (string.len(bm) < 32) do - bm = "0000"..bm - end - - - for i = 1, 32 do - cv = string.sub(bv, i, i) - cm = string.sub(bm, i, i) - if cv == cm then - if cv == "1" then - s = s.."1" - else - s = s.."0" - end - else - s = s.."0" - - end - end - - return Bin2Hex(s) - -end - - -function BMNAnd(v, m) - --- v -> hex string to be masked --- m -> hex string mask - --- s -> hex string as masked - --- bv -> binary string of v --- bm -> binary string mask - -local bv = Hex2Bin(v) -local bm = Hex2Bin(m) - -local i = 0 -local s = "" - - while (string.len(bv) < 32) do - bv = "0000"..bv - end - - while (string.len(bm) < 32) do - bm = "0000"..bm - end - - - for i = 1, 32 do - cv = string.sub(bv, i, i) - cm = string.sub(bm, i, i) - if cv == cm then - if cv == "1" then - s = s.."0" - else - s = s.."1" - end - else - s = s.."1" - - end - end - - return Bin2Hex(s) - -end - - - -function BMOr(v, m) - --- v -> hex string to be masked --- m -> hex string mask - --- s -> hex string as masked - --- bv -> binary string of v --- bm -> binary string mask - -local bv = Hex2Bin(v) -local bm = Hex2Bin(m) - -local i = 0 -local s = "" - - while (string.len(bv) < 32) do - bv = "0000"..bv - end - - while (string.len(bm) < 32) do - bm = "0000"..bm - end - - - for i = 1, 32 do - cv = string.sub(bv, i, i) - cm = string.sub(bm, i, i) - if cv == "1" then - s = s.."1" - elseif cm == "1" then - s = s.."1" - else - s = s.."0" - end - end - - return Bin2Hex(s) - -end - -function BMXOr(v, m) - --- v -> hex string to be masked --- m -> hex string mask - --- s -> hex string as masked - --- bv -> binary string of v --- bm -> binary string mask - -local bv = Hex2Bin(v) -local bm = Hex2Bin(m) - -local i = 0 -local s = "" - - while (string.len(bv) < 32) do - bv = "0000"..bv - end - - while (string.len(bm) < 32) do - bm = "0000"..bm - end - - - for i = 1, 32 do - cv = string.sub(bv, i, i) - cm = string.sub(bm, i, i) - if cv == "1" then - if cm == "0" then - s = s.."1" - else - s = s.."0" - end - elseif cm == "1" then - if cv == "0" then - s = s.."1" - else - s = s.."0" - end - else - -- cv and cm == "0" - s = s.."0" - end - end - - return Bin2Hex(s) - -end - - -function BMNot(v, m) - --- v -> hex string to be masked --- m -> hex string mask - --- s -> hex string as masked - --- bv -> binary string of v --- bm -> binary string mask - -local bv = Hex2Bin(v) -local bm = Hex2Bin(m) - -local i = 0 -local s = "" - - while (string.len(bv) < 32) do - bv = "0000"..bv - end - - while (string.len(bm) < 32) do - bm = "0000"..bm - end - - - for i = 1, 32 do - cv = string.sub(bv, i, i) - cm = string.sub(bm, i, i) - if cm == "1" then - if cv == "1" then - -- turn off - s = s.."0" - else - -- turn on - s = s.."1" - end - else - -- leave untouched - s = s..cv - - end - end - - return Bin2Hex(s) - -end - - --- these functions shift right and left, adding zeros to lost or gained bits --- returned values are 32 bits long - --- BShRight(v, nb) --- BShLeft(v, nb) - - -function BShRight(v, nb) - --- v -> hexstring value to be shifted --- nb -> number of bits to shift to the right - --- s -> binary string of v - -local s = Hex2Bin(v) - - while (string.len(s) < 32) do - s = "0000"..s - end - - s = string.sub(s, 1, 32 - nb) - - while (string.len(s) < 32) do - s = "0"..s - end - - return Bin2Hex(s) - -end - -function BShLeft(v, nb) - --- v -> hexstring value to be shifted --- nb -> number of bits to shift to the right - --- s -> binary string of v - -local s = Hex2Bin(v) - - while (string.len(s) < 32) do - s = "0000"..s - end - - s = string.sub(s, nb + 1, 32) - - while (string.len(s) < 32) do - s = s.."0" - end - - return Bin2Hex(s) - -end \ No newline at end of file diff --git a/libs/core/src/debug.lua b/libs/core/src/debug.lua deleted file mode 100644 index a56400f34..000000000 --- a/libs/core/src/debug.lua +++ /dev/null @@ -1,2 +0,0 @@ -module("luci.debug", package.seeall) -__file__ = debug.getinfo(1, 'S').source:sub(2) \ No newline at end of file diff --git a/libs/core/src/fs.lua b/libs/core/src/fs.lua deleted file mode 100644 index 5c1f2a051..000000000 --- a/libs/core/src/fs.lua +++ /dev/null @@ -1,129 +0,0 @@ ---[[ -LuCI - Filesystem tools - -Description: -A module offering often needed filesystem manipulation functions - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.fs", package.seeall) - -require("posix") - --- Glob -glob = posix.glob - --- Checks whether a file exists -function isfile(filename) - local fp = io.open(filename, "r") - if fp then fp:close() end - return fp ~= nil -end - --- Returns the content of file -function readfile(filename) - local fp, err = io.open(filename) - - if fp == nil then - return nil, err - end - - local data = fp:read("*a") - fp:close() - return data -end - --- Writes given data to a file -function writefile(filename, data) - local fp, err = io.open(filename, "w") - - if fp == nil then - return nil, err - end - - fp:write(data) - fp:close() - - return true -end - --- Returns the file modification date/time of "path" -function mtime(path) - return posix.stat(path, "mtime") -end - --- basename wrapper -basename = posix.basename - --- dirname wrapper -dirname = posix.dirname - --- dir wrapper -dir = posix.dir - --- wrapper for posix.mkdir -function mkdir(path, recursive) - if recursive then - local base = "." - - if path:sub(1,1) == "/" then - base = "" - path = path:gsub("^/+","") - end - - for elem in path:gmatch("([^/]+)/*") do - base = base .. "/" .. elem - - local stat = posix.stat( base ) - - if not stat then - local stat, errmsg, errno = posix.mkdir( base ) - - if type(stat) ~= "number" or stat ~= 0 then - return stat, errmsg, errno - end - else - if stat.type ~= "directory" then - return nil, base .. ": File exists", 17 - end - end - end - - return 0 - else - return posix.mkdir( path ) - end -end - --- Alias for posix.rmdir -rmdir = posix.rmdir - --- Alias for posix.stat -stat = posix.stat - --- Alias for posix.chmod -chmod = posix.chmod - --- Alias for posix.link -link = posix.link - --- Alias for posix.unlink -unlink = posix.unlink diff --git a/libs/core/src/init.lua b/libs/core/src/init.lua deleted file mode 100644 index ce52d0aad..000000000 --- a/libs/core/src/init.lua +++ /dev/null @@ -1,29 +0,0 @@ ---[[ -LuCI - Lua Configuration Interface - -Description: -Main class - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci", package.seeall) - -__version__ = "0.5" -__appname__ = "LuCI" diff --git a/libs/core/src/model/ipkg.lua b/libs/core/src/model/ipkg.lua deleted file mode 100644 index e95a2620a..000000000 --- a/libs/core/src/model/ipkg.lua +++ /dev/null @@ -1,140 +0,0 @@ ---[[ -LuCI - IPKG wrapper library - -Description: -Wrapper for the ipkg Package manager - -Any return value of false or nil can be interpreted as an error - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.model.ipkg", package.seeall) -require("luci.sys") -require("luci.util") - -ipkg = "ipkg" - --- Returns repository information -function info(pkg) - return _lookup("info", pkg) -end - --- Returns a table with status information -function status(pkg) - return _lookup("status", pkg) -end - --- Installs packages -function install(...) - return _action("install", ...) -end - --- Returns whether a package is installed -function installed(pkg, ...) - local p = status(...)[pkg] - return (p and p.Status and p.Status.installed) -end - --- Removes packages -function remove(...) - return _action("remove", ...) -end - --- Updates package lists -function update() - return _action("update") -end - --- Upgrades installed packages -function upgrade() - return _action("upgrade") -end - - --- Internal action function -function _action(cmd, ...) - local pkg = "" - arg.n = nil - for k, v in pairs(arg) do - pkg = pkg .. " '" .. v:gsub("'", "") .. "'" - end - - local c = ipkg.." "..cmd.." "..pkg.." >/dev/null 2>&1" - local r = os.execute(c) - return (r == 0), r -end - --- Internal lookup function -function _lookup(act, pkg) - local cmd = ipkg .. " " .. act - if pkg then - cmd = cmd .. " '" .. pkg:gsub("'", "") .. "'" - end - - return _parselist(luci.sys.exec(cmd .. " 2>/dev/null")) -end - --- Internal parser function -function _parselist(rawdata) - if type(rawdata) ~= "string" then - error("IPKG: Invalid rawdata given") - end - - rawdata = luci.util.split(rawdata) - local data = {} - local c = {} - local l = nil - - for k, line in pairs(rawdata) do - if line:sub(1, 1) ~= " " then - local split = luci.util.split(line, ":", 1) - local key = nil - local val = nil - - if split[1] then - key = luci.util.trim(split[1]) - end - - if split[2] then - val = luci.util.trim(split[2]) - end - - if key and val then - if key == "Package" then - c = {Package = val} - data[val] = c - elseif key == "Status" then - c.Status = {} - for i, j in pairs(luci.util.split(val, " ")) do - c.Status[j] = true - end - else - c[key] = val - end - l = key - end - else - -- Multi-line field - c[l] = c[l] .. "\n" .. line:sub(2) - end - end - - return data -end \ No newline at end of file diff --git a/libs/core/src/model/uci.lua b/libs/core/src/model/uci.lua deleted file mode 100644 index 39354bed1..000000000 --- a/libs/core/src/model/uci.lua +++ /dev/null @@ -1,92 +0,0 @@ ---[[ -LuCI - UCI mpdel - -Description: -Generalized UCI model - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.model.uci", package.seeall) - --- Default savedir -savedir = "/tmp/.uci" - --- Test whether to load libuci-Wrapper or /sbin/uci-Wrapper -if pcall(require, "uci") then - Session = require("luci.model.uci.libuci").Session -else - Session = require("luci.model.uci.wrapper").Session -end - --- The default Session -local default = Session() -local state = Session("/var/state") - --- The state Session -function StateSession() - return state -end - - --- Wrapper for "uci add" -function add(...) - return default:add(...) -end - - --- Wrapper for "uci changes" -function changes(...) - return default:changes(...) -end - --- Wrapper for "uci commit" -function commit(...) - return default:commit(...) -end - - --- Wrapper for "uci del" -function del(...) - return default:del(...) -end - - --- Wrapper for "uci get" -function get(...) - return default:get(...) -end - - --- Wrapper for "uci revert" -function revert(...) - return default:revert(...) -end - - --- Wrapper for "uci show" -function sections(...) - return default:sections(...) -end - - --- Wrapper for "uci set" -function set(...) - return default:set(...) -end \ No newline at end of file diff --git a/libs/core/src/model/uci/libuci.lua b/libs/core/src/model/uci/libuci.lua deleted file mode 100644 index 9a1112500..000000000 --- a/libs/core/src/model/uci/libuci.lua +++ /dev/null @@ -1,193 +0,0 @@ ---[[ -LuCI - UCI libuci wrapper - -Description: -Wrapper for the libuci Lua bindings - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.model.uci.libuci", package.seeall) - -require("uci") -require("luci.util") -require("luci.sys") - --- Session class -Session = luci.util.class() - --- Session constructor -function Session.__init__(self, savedir) - self.ucicmd = savedir and "uci -P " .. savedir or "uci" - self.savedir = savedir or luci.model.uci.savedir -end - -function Session.add(self, config, section_type) - return self:_uci("add " .. _path(config) .. " " .. _path(section_type)) -end - -function Session.changes(self, config) - return self:_uci("changes " .. _path(config)) -end - -function Session.commit(self, config) - self:t_load(config) - return self:t_commit(config) -end - -function Session.del(self, config, section, option) - return self:_uci2("del " .. _path(config, section, option)) -end - -function Session.get(self, config, section, option) - self:t_load(config) - return self:t_get(config, section, option) -end - -function Session.revert(self, config) - self:t_load(config) - return self:t_revert(config) -end - -function Session.sections(self, config) - self:t_load(config) - return self:t_sections(config) -end - -function Session.set(self, config, section, option, value) - self:t_load(config) - return self:t_set(config, section, option, value) and self:t_save(config) -end - -function Session.synchronize(self) - return uci.set_savedir(self.savedir) -end - - --- UCI-Transactions - -function Session.t_load(self, config) - return self:synchronize() and uci.load(config) -end - -function Session.t_save(self, config) - return uci.save(config) -end - -function Session.t_add(self, config, type) - self:t_save(config) - local r = self:add(config, type) - self:t_load(config) - return r -end - -function Session.t_commit(self, config) - return uci.commit(config) -end - -function Session.t_del(self, config, section, option) - self:t_save(config) - local r = self:del(config, section, option) - self:t_load(config) - return r -end - -function Session.t_get(self, config, section, option) - if option then - return uci.get(config, section, option) - else - return uci.get(config, section) - end -end - -function Session.t_revert(self, config) - return uci.revert(config) -end - -function Session.t_sections(self, config) - local raw = uci.get_all(config) - if not raw then - return nil - end - - local s = {} - local o = {} - - for i, sec in ipairs(raw) do - table.insert(o, sec.name) - - s[sec.name] = sec.options - s[sec.name][".type"] = sec.type - end - - return s, o -end - -function Session.t_set(self, config, section, option, value) - if option then - return uci.set(config.."."..section.."."..option.."="..value) - else - return uci.set(config.."."..section.."="..value) - end -end - --- Internal functions -- - - -function Session._uci(self, cmd) - local res = luci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd) - - if res:len() == 0 then - return nil - else - return res:sub(1, res:len()-1) - end -end - -function Session._uci2(self, cmd) - local res = luci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd) - - if res:len() > 0 then - return false, res - else - return true - end -end - --- Build path (config.section.option=value) and prevent command injection -function _path(...) - local result = "" - - -- Not using ipairs because it is not reliable in case of nil arguments - arg.n = nil - for k,v in pairs(arg) do - if v then - v = tostring(v) - if k == 1 then - result = "'" .. v:gsub("['.]", "") .. "'" - elseif k < 4 then - result = result .. ".'" .. v:gsub("['.]", "") .. "'" - elseif k == 4 then - result = result .. "='" .. v:gsub("'", "") .. "'" - end - end - end - return result -end \ No newline at end of file diff --git a/libs/core/src/model/uci/wrapper.lua b/libs/core/src/model/uci/wrapper.lua deleted file mode 100644 index e063b272c..000000000 --- a/libs/core/src/model/uci/wrapper.lua +++ /dev/null @@ -1,171 +0,0 @@ ---[[ -LuCI - UCI wrapper library - -Description: -Wrapper for the /sbin/uci application, syntax of implemented functions -is comparable to the syntax of the uci application - -Any return value of false or nil can be interpreted as an error - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.model.uci.wrapper", package.seeall) - -require("luci.util") -require("luci.sys") - --- Session class -Session = luci.util.class() - --- Session constructor -function Session.__init__(self, savedir) - self.ucicmd = savedir and "uci -P " .. savedir or "uci" -end - -function Session.add(self, config, section_type) - return self:_uci("add " .. _path(config) .. " " .. _path(section_type)) -end - -function Session.changes(self, config) - return self:_uci("changes " .. _path(config)) -end - -function Session.commit(self, config) - return self:_uci2("commit " .. _path(config)) -end - -function Session.del(self, config, section, option) - return self:_uci2("del " .. _path(config, section, option)) -end - -function Session.get(self, config, section, option) - return self:_uci("get " .. _path(config, section, option)) -end - -function Session.revert(self, config) - return self:_uci2("revert " .. _path(config)) -end - -function Session.sections(self, config) - if not config then - return nil - end - - local r1, r2 = self:_uci3("show " .. _path(config)) - if type(r1) == "table" then - return r1, r2 - else - return nil, r2 - end -end - -function Session.set(self, config, section, option, value) - return self:_uci2("set " .. _path(config, section, option, value)) -end - -function Session.synchronize(self) end - --- Dummy transaction functions - -function Session.t_load(self) end -function Session.t_save(self) end - -Session.t_add = Session.add -Session.t_commit = Session.commit -Session.t_del = Session.del -Session.t_get = Session.get -Session.t_revert = Session.revert -Session.t_sections = Session.sections -Session.t_set = Session.set - - - - - --- Internal functions -- - - -function Session._uci(self, cmd) - local res = luci.sys.exec(self.ucicmd .. " 2>/dev/null " .. cmd) - - if res:len() == 0 then - return nil - else - return res:sub(1, res:len()-1) - end -end - -function Session._uci2(self, cmd) - local res = luci.sys.exec(self.ucicmd .. " 2>&1 " .. cmd) - - if res:len() > 0 then - return false, res - else - return true - end -end - -function Session._uci3(self, cmd) - local res = luci.sys.execl(self.ucicmd .. " 2>&1 " .. cmd) - if res[1] and res[1]:sub(1, self.ucicmd:len()+1) == self.ucicmd..":" then - return nil, res[1] - end - - local tbl = {} - local ord = {} - - for k,line in pairs(res) do - c, s, t = line:match("^([^.]-)%.([^.]-)=(.-)$") - if c then - tbl[s] = {} - table.insert(ord, s) - tbl[s][".type"] = t - end - - c, s, o, v = line:match("^([^.]-)%.([^.]-)%.([^.]-)=(.-)$") - if c then - tbl[s][o] = v - end - end - - return tbl, ord -end - --- Build path (config.section.option=value) and prevent command injection -function _path(...) - local result = "" - - -- Not using ipairs because it is not reliable in case of nil arguments - arg.n = nil - for k,v in pairs(arg) do - if v then - v = tostring(v) - if k == 1 then - result = "'" .. v:gsub("['.]", "") .. "'" - elseif k < 4 then - result = result .. ".'" .. v:gsub("['.]", "") .. "'" - elseif k == 4 then - result = result .. "='" .. v:gsub("'", "") .. "'" - end - end - end - return result -end \ No newline at end of file diff --git a/libs/core/src/sys.lua b/libs/core/src/sys.lua deleted file mode 100644 index 0399d0e5f..000000000 --- a/libs/core/src/sys.lua +++ /dev/null @@ -1,371 +0,0 @@ ---[[ -LuCI - System library - -Description: -Utilities for interaction with the Linux system - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.sys", package.seeall) -require("posix") -require("luci.bits") -require("luci.util") -require("luci.fs") - --- Returns whether a system is bigendian -function bigendian() - local fp = io.open("/bin/sh") - fp:seek("set", 5) - local be = (fp:read(1):byte() ~= 1) - fp:close() - return be -end - --- Runs "command" and returns its output -function exec(command) - local pp = io.popen(command) - local data = pp:read("*a") - pp:close() - - return data -end - --- Runs "command" and returns its output as a array of lines -function execl(command) - local pp = io.popen(command) - local line = "" - local data = {} - - while true do - line = pp:read() - if (line == nil) then break end - table.insert(data, line) - end - pp:close() - - return data -end - --- Uses "luci-flash" to flash a new image file to the system -function flash(image, kpattern) - local cmd = "luci-flash " - if kpattern then - cmd = cmd .. "-k '" .. kpattern:gsub("'", "") .. "' " - end - cmd = cmd .. "'" .. image:gsub("'", "") .. "' >/dev/null 2>&1" - - return os.execute(cmd) -end - --- Returns the hostname -function hostname() - return io.lines("/proc/sys/kernel/hostname")() -end - --- Returns the contents of a documented referred by an URL -function httpget(url) - return exec("wget -qO- '"..url:gsub("'", "").."'") -end - --- Returns the FFLuci-Basedir -function libpath() - return luci.fs.dirname(require("luci.debug").__file__) -end - --- Returns the load average -function loadavg() - local loadavg = io.lines("/proc/loadavg")() - return loadavg:match("^(.-) (.-) (.-) (.-) (.-)$") -end - --- Reboots the system -function reboot() - return os.execute("reboot >/dev/null 2>&1") -end - --- Returns the system type, cpu name, and installed physical memory -function sysinfo() - local c1 = "cat /proc/cpuinfo|grep system\\ typ|cut -d: -f2 2>/dev/null" - local c2 = "uname -m 2>/dev/null" - local c3 = "cat /proc/cpuinfo|grep model\\ name|cut -d: -f2 2>/dev/null" - local c4 = "cat /proc/cpuinfo|grep cpu\\ model|cut -d: -f2 2>/dev/null" - local c5 = "cat /proc/meminfo|grep MemTotal|cut -d: -f2 2>/dev/null" - - local s = luci.util.trim(exec(c1)) - local m = "" - local r = "" - - if s == "" then - s = luci.util.trim(exec(c2)) - m = luci.util.trim(exec(c3)) - else - m = luci.util.trim(exec(c4)) - end - - r = luci.util.trim(exec(c5)) - - return s, m, r -end - --- Reads the syslog -function syslog() - return exec("logread") -end - - -group = {} -group.getgroup = posix.getgroup - -net = {} --- Returns the ARP-Table -function net.arptable() - return _parse_delimited_table(io.lines("/proc/net/arp"), "%s%s+") -end - --- Returns whether an IP-Adress belongs to a certain net -function net.belongs(ip, ipnet, prefix) - return (net.ip4bin(ip):sub(1, prefix) == net.ip4bin(ipnet):sub(1, prefix)) -end - --- Detect the default route -function net.defaultroute() - local routes = net.routes() - local route = nil - - for i, r in pairs(luci.sys.net.routes()) do - if r.Destination == "00000000" and (not route or route.Metric > r.Metric) then - route = r - end - end - - return route -end - --- Returns all available network interfaces -function net.devices() - local devices = {} - for line in io.lines("/proc/net/dev") do - table.insert(devices, line:match(" *(.-):")) - end - return devices -end - --- Returns the MAC-Address belonging to the given IP-Address -function net.ip4mac(ip) - local mac = nil - - for i, l in ipairs(net.arptable()) do - if l["IP address"] == ip then - mac = l["HW address"] - end - end - - return mac -end - --- Returns the prefix to a given netmask -function net.mask4prefix(mask) - local bin = net.ip4bin(mask) - - if not bin then - return nil - end - - return #luci.util.split(bin, "1")-1 -end - --- Returns the kernel routing table -function net.routes() - return _parse_delimited_table(io.lines("/proc/net/route")) -end - --- Returns the numeric IP to a given hexstring -function net.hexip4(hex, be) - if #hex ~= 8 then - return nil - end - - be = be or bigendian() - - local hexdec = luci.bits.Hex2Dec - - local ip = "" - if be then - ip = ip .. tostring(hexdec(hex:sub(1,2))) .. "." - ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "." - ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "." - ip = ip .. tostring(hexdec(hex:sub(7,8))) - else - ip = ip .. tostring(hexdec(hex:sub(7,8))) .. "." - ip = ip .. tostring(hexdec(hex:sub(5,6))) .. "." - ip = ip .. tostring(hexdec(hex:sub(3,4))) .. "." - ip = ip .. tostring(hexdec(hex:sub(1,2))) - end - - return ip -end - --- Returns the binary IP to a given IP -function net.ip4bin(ip) - local parts = luci.util.split(ip, '.') - if #parts ~= 4 then - return nil - end - - local decbin = luci.bits.Dec2Bin - - local bin = "" - bin = bin .. decbin(parts[1], 8) - bin = bin .. decbin(parts[2], 8) - bin = bin .. decbin(parts[3], 8) - bin = bin .. decbin(parts[4], 8) - - return bin -end - --- Tests whether a host is pingable -function net.pingtest(host) - return os.execute("ping -c1 '"..host:gsub("'", '').."' >/dev/null 2>&1") -end - - -process = {} -process.info = posix.getpid - --- Sets the gid of a process -function process.setgroup(pid, gid) - return posix.setpid("g", pid, gid) -end - --- Sets the uid of a process -function process.setuser(pid, uid) - return posix.setpid("u", pid, uid) -end - -user = {} --- returns user information to a given uid -user.getuser = posix.getpasswd - --- Changes the user password of given user -function user.setpasswd(user, pwd) - if pwd then - pwd = pwd:gsub("'", "") - end - - if user then - user = user:gsub("'", "") - end - - local cmd = "(echo '"..pwd.."';sleep 1;echo '"..pwd.."')|" - cmd = cmd .. "passwd '"..user.."' >/dev/null 2>&1" - return os.execute(cmd) -end - - -wifi = {} - -function wifi.getiwconfig() - local cnt = exec("/usr/sbin/iwconfig 2>/dev/null") - local iwc = {} - - for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do - local k = l:match("^(.-) ") - l = l:gsub("^(.-) +", "", 1) - if k then - iwc[k] = _parse_mixed_record(l) - end - end - - return iwc -end - -function wifi.iwscan() - local cnt = exec("iwlist scan 2>/dev/null") - local iws = {} - - for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n\n")) do - local k = l:match("^(.-) ") - l = l:gsub("^[^\n]+", "", 1) - l = luci.util.trim(l) - if k then - iws[k] = {} - for j, c in pairs(luci.util.split(l, "\n Cell")) do - c = c:gsub("^(.-)- ", "", 1) - c = luci.util.split(c, "\n", 7) - c = table.concat(c, "\n", 1) - table.insert(iws[k], _parse_mixed_record(c)) - end - end - end - - return iws -end - - --- Internal functions - -function _parse_delimited_table(iter, delimiter) - delimiter = delimiter or "%s+" - - local data = {} - local trim = luci.util.trim - local split = luci.util.split - - local keys = split(trim(iter()), delimiter, nil, true) - for i, j in pairs(keys) do - keys[i] = trim(keys[i]) - end - - for line in iter do - local row = {} - line = trim(line) - if #line > 0 then - for i, j in pairs(split(line, delimiter, nil, true)) do - if keys[i] then - row[keys[i]] = j - end - end - end - table.insert(data, row) - end - - return data -end - -function _parse_mixed_record(cnt) - local data = {} - - for i, l in pairs(luci.util.split(luci.util.trim(cnt), "\n")) do - for j, f in pairs(luci.util.split(luci.util.trim(l), " ")) do - local k, x, v = f:match('([^%s][^:=]+) *([:=]*) *"*([^\n"]*)"*') - - if k then - if x == "" then - table.insert(data, k) - else - data[k] = v - end - end - end - end - - return data -end \ No newline at end of file diff --git a/libs/core/src/sys/iptparser.lua b/libs/core/src/sys/iptparser.lua deleted file mode 100644 index 6450c3072..000000000 --- a/libs/core/src/sys/iptparser.lua +++ /dev/null @@ -1,245 +0,0 @@ ---[[ -LuCI - Iptables parser and query library - -Copyright 2008 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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -$Id$ - -]]-- - -module("luci.sys.iptparser", package.seeall) -require("luci.sys") -require("luci.util") - - -IptParser = luci.util.class() - ---[[ -IptParser.__init__( ... ) - -The class constructor, initializes the internal lookup table. -]]-- - -function IptParser.__init__( self, ... ) - self._rules = { } - self._chain = nil - self:_parse_rules() -end - - ---[[ -IptParser.find( args ) - -Find all firewall rules that match the given criteria. Expects a table with search criteria as only argument. -If args is nil or an empty table then all rules will be returned. - -The following keys in the args table are recognized: - - - table Match rules that are located within the given table - - chain Match rules that are located within the given chain - - target Match rules with the given target - - protocol Match rules that match the given protocol, rules with protocol "all" are always matched - - source Match rules with the given source, rules with source "0.0.0.0/0" are always matched - - destination Match rules with the given destination, rules with destination "0.0.0.0/0" are always matched - - inputif Match rules with the given input interface, rules with input interface "*" (=all) are always matched - - outputif Match rules with the given output interface, rules with output interface "*" (=all) are always matched - - flags Match rules that match the given flags, current supported values are "-f" (--fragment) and "!f" (! --fragment) - - options Match rules containing all given options - -The return value is a list of tables representing the matched rules. -Each rule table contains the following fields: - - - index The index number of the rule - - table The table where the rule is located, can be one of "filter", "nat" or "mangle" - - chain The chain where the rule is located, e.g. "INPUT" or "postrouting_wan" - - target The rule target, e.g. "REJECT" or "DROP" - - protocol The matching protocols, e.g. "all" or "tcp" - - flags Special rule options ("--", "-f" or "!f") - - inputif Input interface of the rule, e.g. "eth0.0" or "*" for all interfaces - - outputif Output interface of the rule, e.g. "eth0.0" or "*" for all interfaces - - source The source ip range, e.g. "0.0.0.0/0" - - destination The destination ip range, e.g. "0.0.0.0/0" - - options A list of specific options of the rule, e.g. { "reject-with", "tcp-reset" } - - packets The number of packets matched by the rule - - bytes The number of total bytes matched by the rule - -Example: - -ip = luci.sys.iptparser.IptParser() -result = ip.find( { - target="REJECT", - protocol="tcp", - options={ "reject-with", "tcp-reset" } -} ) - -This will match all rules with target "-j REJECT", protocol "-p tcp" (or "-p all") and the option "--reject-with tcp-reset". - -]]-- - -function IptParser.find( self, args ) - - local args = args or { } - local rv = { } - - for i, rule in ipairs(self._rules) do - local match = true - - -- match table - if not ( not args.table or args.table == rule.table ) then - match = false - end - - -- match chain - if not ( match == true and ( not args.chain or args.chain == rule.chain ) ) then - match = false - end - - -- match target - if not ( match == true and ( not args.target or args.target == rule.target ) ) then - match = false - end - - -- match protocol - if not ( match == true and ( not args.protocol or rule.protocol == "all" or args.protocol == rule.protocol ) ) then - match = false - end - - -- match source (XXX: implement ipcalc stuff so that 192.168.1.0/24 matches 0.0.0.0/0 etc.) - if not ( match == true and ( not args.source or rule.source == "0.0.0.0/0" or rule.source == args.source ) ) then - match = false - end - - -- match destination (XXX: implement ipcalc stuff so that 192.168.1.0/24 matches 0.0.0.0/0 etc.) - if not ( match == true and ( not args.destination or rule.destination == "0.0.0.0/0" or rule.destination == args.destination ) ) then - match = false - end - - -- match input interface - if not ( match == true and ( not args.inputif or rule.inputif == "*" or args.inputif == rule.inputif ) ) then - match = false - end - - -- match output interface - if not ( match == true and ( not args.outputif or rule.outputif == "*" or args.outputif == rule.outputif ) ) then - match = false - end - - -- match flags (the "opt" column) - if not ( match == true and ( not args.flags or rule.flags == args.flags ) ) then - match = false - end - - -- match specific options - if not ( match == true and ( not args.options or self:_match_options( rule.options, args.options ) ) ) then - match = false - end - - - -- insert match - if match == true then - table.insert( rv, rule ) - end - end - - return rv -end - - ---[[ -IptParser.resync() - -Rebuild the internal lookup table, for example when rules have changed through external commands. -]]-- - -function IptParser.resync( self ) - self._rules = { } - self._chain = nil - self:_parse_rules() -end - - ---[[ -IptParser._parse_rules() - -[internal] Parse iptables output from all tables. -]]-- - -function IptParser._parse_rules( self ) - - for i, tbl in ipairs({ "filter", "nat", "mangle" }) do - - for i, rule in ipairs(luci.sys.execl("iptables -t " .. tbl .. " --line-numbers -nxvL")) do - - if rule:find( "Chain " ) == 1 then - - self._chain = rule:gsub("Chain ([^%s]*) .*", "%1") - - else - if rule:find("%d") == 1 then - - local rule_parts = luci.util.split( rule, "%s+", nil, true ) - local rule_details = { } - - rule_details["table"] = tbl - rule_details["chain"] = self._chain - rule_details["index"] = tonumber(rule_parts[1]) - rule_details["packets"] = tonumber(rule_parts[2]) - rule_details["bytes"] = tonumber(rule_parts[3]) - rule_details["target"] = rule_parts[4] - rule_details["protocol"] = rule_parts[5] - rule_details["flags"] = rule_parts[6] - rule_details["inputif"] = rule_parts[7] - rule_details["outputif"] = rule_parts[8] - rule_details["source"] = rule_parts[9] - rule_details["destination"] = rule_parts[10] - rule_details["options"] = { } - - for i = 11, #rule_parts - 1 do - rule_details["options"][i-10] = rule_parts[i] - end - - table.insert( self._rules, rule_details ) - end - end - end - end - - self._chain = nil -end - - ---[[ -IptParser._match_options( optlist1, optlist2 ) - -[internal] Return true if optlist1 contains all elements of optlist2. Return false in all other cases. -]]-- - -function IptParser._match_options( self, o1, o2 ) - - -- construct a hashtable of first options list to speed up lookups - local oh = { } - for i, opt in ipairs( o1 ) do oh[opt] = true end - - -- iterate over second options list - -- each string in o2 must be also present in o1 - -- if o2 contains a string which is not found in o1 then return false - for i, opt in ipairs( o2 ) do - if not oh[opt] then - return false - end - end - - return true -end diff --git a/libs/core/src/util.lua b/libs/core/src/util.lua deleted file mode 100644 index 0559fff6f..000000000 --- a/libs/core/src/util.lua +++ /dev/null @@ -1,215 +0,0 @@ ---[[ -LuCI - Utility library - -Description: -Several common useful Lua functions - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.util", package.seeall) - - --- Lua simplified Python-style OO class support emulation -function class(base) - local class = {} - - local create = function(class, ...) - local inst = {} - setmetatable(inst, {__index = class}) - - if inst.__init__ then - local stat, err = pcall(inst.__init__, inst, ...) - if not stat then - error(err) - end - end - - return inst - end - - local classmeta = {__call = create} - - if base then - classmeta.__index = base - end - - setmetatable(class, classmeta) - return class -end - - --- Clones an object (deep on-demand) -function clone(object, deep) - local copy = {} - - for k, v in pairs(object) do - if deep and type(v) == "table" then - v = clone(v, deep) - end - copy[k] = v - end - - setmetatable(copy, getmetatable(object)) - - return copy -end - - --- Combines two or more numerically indexed tables into one -function combine(...) - local result = {} - for i, a in ipairs(arg) do - for j, v in ipairs(a) do - table.insert(result, v) - end - end - return result -end - - --- Checks whether a table has an object "value" in it -function contains(table, value) - for k,v in pairs(table) do - if value == v then - return true - end - end - return false -end - - --- Dumps a table to stdout (useful for testing and debugging) -function dumptable(t, i) - i = i or 0 - for k,v in pairs(t) do - print(string.rep("\t", i) .. k, v) - if type(v) == "table" then - dumptable(v, i+1) - end - end -end - - --- Escapes all occurences of c in s -function escape(s, c) - c = c or "\\" - return s:gsub(c, "\\" .. c) -end - - --- Populate obj in the scope of f as key -function extfenv(f, key, obj) - local scope = getfenv(f) - scope[key] = obj -end - - --- Checks whether an object is an instanceof class -function instanceof(object, class) - local meta = getmetatable(object) - while meta and meta.__index do - if meta.__index == class then - return true - end - meta = getmetatable(meta.__index) - end - return false -end - - --- Creates valid XML PCDATA from a string -function pcdata(value) - value = value:gsub("&", "&") - value = value:gsub('"', """) - value = value:gsub("'", "'") - value = value:gsub("<", "<") - return value:gsub(">", ">") -end - - --- Resets the scope of f doing a shallow copy of its scope into a new table -function resfenv(f) - setfenv(f, clone(getfenv(f))) -end - - --- Splits a string into an array -function split(str, pat, max, regex) - pat = pat or "\n" - max = max or #str - - local t = {} - local c = 1 - - if #str == 0 then - return {""} - end - - if #pat == 0 then - return nil - end - - if max == 0 then - return str - end - - repeat - local s, e = str:find(pat, c, not regex) - table.insert(t, str:sub(c, s and s - 1)) - max = max - 1 - c = e and e + 1 or #str + 1 - until not s or max < 0 - - return t -end - --- Removes whitespace from beginning and end of a string -function trim(str) - local s = str:gsub("^%s*(.-)%s*$", "%1") - return s -end - --- Updates given table with new values -function update(t, updates) - for k, v in pairs(updates) do - t[k] = v - end -end - - --- Updates the scope of f with "extscope" -function updfenv(f, extscope) - update(getfenv(f), extscope) -end - - --- Validates a variable -function validate(value, cast_number, cast_int) - if cast_number or cast_int then - value = tonumber(value) - end - - if cast_int and value and not(value % 1 == 0) then - value = nil - end - - return value -end \ No newline at end of file diff --git a/libs/sgi-haserl/luasrc/sgi/haserl.lua b/libs/sgi-haserl/luasrc/sgi/haserl.lua new file mode 100644 index 000000000..f3994b5c8 --- /dev/null +++ b/libs/sgi-haserl/luasrc/sgi/haserl.lua @@ -0,0 +1,97 @@ +--[[ +LuCI - SGI-Module for Haserl + +Description: +Server Gateway Interface for Haserl + +FileId: +$Id: haserl.lua 2027 2008-05-07 21:16:35Z Cyrus $ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.sgi.haserl", package.seeall) +require("luci.fs") + +-- Environment Table +luci.http.env = ENV + +-- Returns the main dispatcher URL +function luci.http.dispatcher() + return luci.http.env.SCRIPT_NAME or "" +end + +-- Returns the upload dispatcher URL +function luci.http.dispatcher_upload() + return luci.http.dispatcher() .. "-upload" +end + +-- Returns a table of all COOKIE, GET and POST Parameters +function luci.http.formvalues() + return FORM +end + +-- Gets form value from key +function luci.http.formvalue(key, default) + local c = luci.http.formvalues() + + for match in key:gmatch("[%w-_]+") do + c = c[match] + if c == nil then + return default + end + end + + return c +end + +-- Gets a table of values with a certain prefix +function luci.http.formvaluetable(prefix) + return luci.http.formvalue(prefix, {}) +end + +-- Sends a custom HTTP-Header +function luci.http.header(key, value) + print(key .. ": " .. value) +end + +-- Set Content-Type +function luci.http.prepare_content(type) + print("Content-Type: "..type.."\n") +end + +-- Asks the browser to redirect to "url" +function luci.http.redirect(url) + luci.http.status(302, "Found") + luci.http.header("Location", url) + print() +end + +-- Returns the path of an uploaded file +-- WARNING! File uploads can be easily spoofed! Do additional sanity checks! +function luci.http.upload(name) + local fpath = luci.http.formvalue(name) + local fname = luci.http.formvalue(name .. "_name") + + if fpath and fname and luci.fs.isfile(fpath) then + return fpath + end +end + +-- Sets HTTP-Status-Header +function luci.http.status(code, message) + print("Status: " .. tostring(code) .. " " .. message) +end diff --git a/libs/sgi-haserl/src/sgi/haserl.lua b/libs/sgi-haserl/src/sgi/haserl.lua deleted file mode 100644 index f3994b5c8..000000000 --- a/libs/sgi-haserl/src/sgi/haserl.lua +++ /dev/null @@ -1,97 +0,0 @@ ---[[ -LuCI - SGI-Module for Haserl - -Description: -Server Gateway Interface for Haserl - -FileId: -$Id: haserl.lua 2027 2008-05-07 21:16:35Z Cyrus $ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.sgi.haserl", package.seeall) -require("luci.fs") - --- Environment Table -luci.http.env = ENV - --- Returns the main dispatcher URL -function luci.http.dispatcher() - return luci.http.env.SCRIPT_NAME or "" -end - --- Returns the upload dispatcher URL -function luci.http.dispatcher_upload() - return luci.http.dispatcher() .. "-upload" -end - --- Returns a table of all COOKIE, GET and POST Parameters -function luci.http.formvalues() - return FORM -end - --- Gets form value from key -function luci.http.formvalue(key, default) - local c = luci.http.formvalues() - - for match in key:gmatch("[%w-_]+") do - c = c[match] - if c == nil then - return default - end - end - - return c -end - --- Gets a table of values with a certain prefix -function luci.http.formvaluetable(prefix) - return luci.http.formvalue(prefix, {}) -end - --- Sends a custom HTTP-Header -function luci.http.header(key, value) - print(key .. ": " .. value) -end - --- Set Content-Type -function luci.http.prepare_content(type) - print("Content-Type: "..type.."\n") -end - --- Asks the browser to redirect to "url" -function luci.http.redirect(url) - luci.http.status(302, "Found") - luci.http.header("Location", url) - print() -end - --- Returns the path of an uploaded file --- WARNING! File uploads can be easily spoofed! Do additional sanity checks! -function luci.http.upload(name) - local fpath = luci.http.formvalue(name) - local fname = luci.http.formvalue(name .. "_name") - - if fpath and fname and luci.fs.isfile(fpath) then - return fpath - end -end - --- Sets HTTP-Status-Header -function luci.http.status(code, message) - print("Status: " .. tostring(code) .. " " .. message) -end diff --git a/libs/sgi-webuci/luasrc/sgi/webuci.lua b/libs/sgi-webuci/luasrc/sgi/webuci.lua new file mode 100644 index 000000000..498bca921 --- /dev/null +++ b/libs/sgi-webuci/luasrc/sgi/webuci.lua @@ -0,0 +1,100 @@ +--[[ +LuCI - SGI-Module for Haserl + +Description: +Server Gateway Interface for Haserl + +FileId: +$Id: webuci.lua 2027 2008-05-07 21:16:35Z Cyrus $ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.sgi.webuci", package.seeall) + +local status_set = false + +-- Initialize the environment +function initenv(env) + luci.http.env = env +end + +-- Returns the main dispatcher URL +function luci.http.dispatcher() + return luci.http.env.SCRIPT_NAME or "" +end + +-- Returns the upload dispatcher URL +function luci.http.dispatcher_upload() + -- To be implemented +end + +-- Returns a table of all COOKIE, GET and POST Parameters +function luci.http.formvalues() + return webuci.vars +end + +-- Gets form value from key +function luci.http.formvalue(key, default) + return luci.http.formvalues()[key] or default +end + +-- Gets a table of values with a certain prefix +function luci.http.formvaluetable(prefix) + local vals = {} + prefix = prefix and prefix .. "." or "." + + for k, v in pairs(luci.http.formvalues()) do + if k:find(prefix, 1, true) == 1 then + vals[k:sub(#prefix + 1)] = v + end + end + + return vals +end + +-- Sends a custom HTTP-Header +function luci.http.header(key, value) + print(key .. ": " .. value) +end + +-- Set Content-Type +function luci.http.prepare_content(type) + if not status_set then + luci.http.status(200, "OK") + end + + print("Content-Type: "..type.."\n") +end + +-- Asks the browser to redirect to "url" +function luci.http.redirect(url) + luci.http.status(302, "Found") + luci.http.header("Location", url) + print() +end + +-- Returns the path of an uploaded file +-- WARNING! File uploads can be easily spoofed! Do additional sanity checks! +function luci.http.upload(name) + -- To be implemented +end + +-- Sets HTTP-Status-Header +function luci.http.status(code, message) + print(luci.http.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message) + status_set = true +end diff --git a/libs/sgi-webuci/src/sgi/webuci.lua b/libs/sgi-webuci/src/sgi/webuci.lua deleted file mode 100644 index 498bca921..000000000 --- a/libs/sgi-webuci/src/sgi/webuci.lua +++ /dev/null @@ -1,100 +0,0 @@ ---[[ -LuCI - SGI-Module for Haserl - -Description: -Server Gateway Interface for Haserl - -FileId: -$Id: webuci.lua 2027 2008-05-07 21:16:35Z Cyrus $ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.sgi.webuci", package.seeall) - -local status_set = false - --- Initialize the environment -function initenv(env) - luci.http.env = env -end - --- Returns the main dispatcher URL -function luci.http.dispatcher() - return luci.http.env.SCRIPT_NAME or "" -end - --- Returns the upload dispatcher URL -function luci.http.dispatcher_upload() - -- To be implemented -end - --- Returns a table of all COOKIE, GET and POST Parameters -function luci.http.formvalues() - return webuci.vars -end - --- Gets form value from key -function luci.http.formvalue(key, default) - return luci.http.formvalues()[key] or default -end - --- Gets a table of values with a certain prefix -function luci.http.formvaluetable(prefix) - local vals = {} - prefix = prefix and prefix .. "." or "." - - for k, v in pairs(luci.http.formvalues()) do - if k:find(prefix, 1, true) == 1 then - vals[k:sub(#prefix + 1)] = v - end - end - - return vals -end - --- Sends a custom HTTP-Header -function luci.http.header(key, value) - print(key .. ": " .. value) -end - --- Set Content-Type -function luci.http.prepare_content(type) - if not status_set then - luci.http.status(200, "OK") - end - - print("Content-Type: "..type.."\n") -end - --- Asks the browser to redirect to "url" -function luci.http.redirect(url) - luci.http.status(302, "Found") - luci.http.header("Location", url) - print() -end - --- Returns the path of an uploaded file --- WARNING! File uploads can be easily spoofed! Do additional sanity checks! -function luci.http.upload(name) - -- To be implemented -end - --- Sets HTTP-Status-Header -function luci.http.status(code, message) - print(luci.http.env.SERVER_PROTOCOL .. " " .. tostring(code) .. " " .. message) - status_set = true -end diff --git a/libs/web/luasrc/config.lua b/libs/web/luasrc/config.lua new file mode 100644 index 000000000..854b12814 --- /dev/null +++ b/libs/web/luasrc/config.lua @@ -0,0 +1,48 @@ +--[[ +LuCI - Configuration + +Description: +Some LuCI configuration values read from uci file "luci" + + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.config", package.seeall) +require("luci.model.uci") +require("luci.util") +require("luci.sys") + +-- Warning! This is only for fallback and compatibility purporses! -- +main = {} + +-- This is where stylesheets and images go +main.mediaurlbase = "/luci/media" + +-- Does anybody think about browser autodetect here? +-- Too bad busybox doesn't populate HTTP_ACCEPT_LANGUAGE +main.lang = "de" + + +-- Now overwrite with UCI values +local ucidata = luci.model.uci.sections("luci") +if ucidata then + luci.util.update(luci.config, ucidata) +end \ No newline at end of file diff --git a/libs/web/luasrc/dispatcher.lua b/libs/web/luasrc/dispatcher.lua new file mode 100644 index 000000000..175f0dcb0 --- /dev/null +++ b/libs/web/luasrc/dispatcher.lua @@ -0,0 +1,281 @@ +--[[ +LuCI - Dispatcher + +Description: +The request dispatcher and module dispatcher generators + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.dispatcher", package.seeall) +require("luci.http") +require("luci.sys") +require("luci.fs") + +-- Local dispatch database +local tree = {nodes={}} + +-- Index table +local index = {} + +-- Global request object +request = {} + +-- Active dispatched node +dispatched = nil + +-- Status fields +built_index = false +built_tree = false + + +-- Builds a URL +function build_url(...) + return luci.http.dispatcher() .. "/" .. table.concat(arg, "/") +end + +-- Sends a 404 error code and renders the "error404" template if available +function error404(message) + luci.http.status(404, "Not Found") + message = message or "Not Found" + + require("luci.template") + if not pcall(luci.template.render, "error404") then + luci.http.prepare_content("text/plain") + print(message) + end + return false +end + +-- Sends a 500 error code and renders the "error500" template if available +function error500(message) + luci.http.status(500, "Internal Server Error") + + require("luci.template") + if not pcall(luci.template.render, "error500", {message=message}) then + luci.http.prepare_content("text/plain") + print(message) + end + return false +end + +-- Creates a request object for dispatching +function httpdispatch() + local pathinfo = luci.http.env.PATH_INFO or "" + local c = tree + + for s in pathinfo:gmatch("([%w_]+)") do + table.insert(request, s) + end + + dispatch() +end + +-- Dispatches a request +function dispatch() + if not built_tree then + createtree() + end + + local c = tree + local track = {} + + for i, s in ipairs(request) do + c = c.nodes[s] + if not c then + break + end + + for k, v in pairs(c) do + track[k] = v + end + end + + + if track.i18n then + require("luci.i18n").loadc(track.i18n) + end + + if track.setgroup then + luci.sys.process.setgroup(track.setgroup) + end + + if track.setuser then + luci.sys.process.setuser(track.setuser) + end + + -- Init template engine + local tpl = require("luci.template") + tpl.viewns.translate = function(...) return require("luci.i18n").translate(...) end + tpl.viewns.controller = luci.http.dispatcher() + tpl.viewns.uploadctrl = luci.http.dispatcher_upload() + tpl.viewns.media = luci.config.main.mediaurlbase + tpl.viewns.resource = luci.config.main.resourcebase + + -- Load default translation + require("luci.i18n").loadc("default") + + + if c and type(c.target) == "function" then + dispatched = c + + stat, err = pcall(c.target) + if not stat then + error500(err) + end + else + error404() + end +end + +-- Generates the dispatching tree +function createindex() + index = {} + local path = luci.sys.libpath() .. "/controller/" + local suff = ".lua" + + if pcall(require, "fastindex") then + createindex_fastindex(path, suff) + else + createindex_plain(path, suff) + end + + built_index = true +end + +-- Uses fastindex to create the dispatching tree +function createindex_fastindex(path, suffix) + local fi = fastindex.new("index") + fi.add(path .. "*" .. suffix) + fi.add(path .. "*/*" .. suffix) + fi.scan() + + for k, v in pairs(fi.indexes) do + index[v[2]] = v[1] + end +end + +-- Calls the index function of all available controllers +function createindex_plain(path, suffix) + local controllers = luci.util.combine( + luci.fs.glob(path .. "*" .. suffix) or {}, + luci.fs.glob(path .. "*/*" .. suffix) or {} + ) + + for i,c in ipairs(controllers) do + c = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".") + stat, mod = pcall(require, c) + + if stat and mod and type(mod.index) == "function" then + index[c] = mod.index + end + end +end + +-- Creates the dispatching tree from the index +function createtree() + if not built_index then + createindex() + end + + for k, v in pairs(index) do + luci.util.updfenv(v, _M) + + local stat, mod = pcall(require, k) + if stat then + luci.util.updfenv(v, mod) + end + + pcall(v) + end + + built_tree = true +end + +-- Shortcut for creating a dispatching node +function entry(path, target, title, order, add) + add = add or {} + + local c = node(path) + c.target = target + c.title = title + c.order = order + + for k,v in pairs(add) do + c[k] = v + end + + return c +end + +-- Fetch a dispatching node +function node(...) + local c = tree + + if arg[1] and type(arg[1]) == "table" then + arg = arg[1] + end + + for k,v in ipairs(arg) do + if not c.nodes[v] then + c.nodes[v] = {nodes={}} + end + + c = c.nodes[v] + end + + return c +end + +-- Subdispatchers -- +function alias(...) + local req = arg + return function() + request = req + dispatch() + end +end + +function template(name) + require("luci.template") + return function() luci.template.render(name) end +end + +function cbi(model) + require("luci.cbi") + require("luci.template") + + return function() + local stat, res = pcall(luci.cbi.load, model) + if not stat then + error500(res) + return true + end + + local stat, err = pcall(res.parse, res) + if not stat then + error500(err) + return true + end + + luci.template.render("cbi/header") + res:render() + luci.template.render("cbi/footer") + end +end diff --git a/libs/web/luasrc/http.lua b/libs/web/luasrc/http.lua new file mode 100644 index 000000000..fa8821c5a --- /dev/null +++ b/libs/web/luasrc/http.lua @@ -0,0 +1,36 @@ +--[[ +LuCI - HTTP-Interaction + +Description: +HTTP-Header manipulator and form variable preprocessor + +FileId: +$Id$ + +ToDo: +- Cookie handling + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.http", package.seeall) + +if ENV and ENV.HASERLVER then + require("luci.sgi.haserl") +elseif webuci then + require("luci.sgi.webuci") +end \ No newline at end of file diff --git a/libs/web/luasrc/i18n.lua b/libs/web/luasrc/i18n.lua new file mode 100644 index 000000000..3a8a9a6c7 --- /dev/null +++ b/libs/web/luasrc/i18n.lua @@ -0,0 +1,63 @@ +--[[ +LuCI - Internationalisation + +Description: +A very minimalistic but yet effective internationalisation module + +FileId: +$Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- + +module("luci.i18n", package.seeall) +require("luci.sys") + +table = {} +i18ndir = luci.sys.libpath() .. "/i18n/" + +-- Clears the translation table +function clear() + table = {} +end + +-- Loads a translation and copies its data into the global translation table +function load(file) + local f = loadfile(i18ndir .. file) + if f then + setfenv(f, table) + f() + return true + else + return false + end +end + +-- Same as load but autocompletes the filename with .LANG from config.lang +function loadc(file) + return load(file .. "." .. require("luci.config").main.lang) +end + +-- Returns the i18n-value defined by "key" or if there is no such: "default" +function translate(key, default) + return table[key] or default +end + +-- Translate shourtcut with sprintf/string.format inclusion +function translatef(key, default, ...) + return translate(key, default):format(...) +end \ No newline at end of file diff --git a/libs/web/luasrc/template.lua b/libs/web/luasrc/template.lua new file mode 100644 index 000000000..369aa0a30 --- /dev/null +++ b/libs/web/luasrc/template.lua @@ -0,0 +1,220 @@ +--[[ +LuCI - Template Parser + +Description: +A template parser supporting includes, translations, Lua code blocks +and more. It can be used either as a compiler or as an interpreter. + +FileId: $Id$ + +License: +Copyright 2008 Steven Barth + +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 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + +]]-- +module("luci.template", package.seeall) + +require("luci.config") +require("luci.util") +require("luci.fs") +require("luci.http") + +viewdir = luci.sys.libpath() .. "/view/" + + +-- Compile modes: +-- none: Never compile, only use precompiled data from files +-- memory: Always compile, do not save compiled files, ignore precompiled +-- file: Compile on demand, save compiled files, update precompiled +compiler_mode = "memory" + + +-- This applies to compiler modes "always" and "smart" +-- +-- Produce compiled lua code rather than lua sourcecode +-- WARNING: Increases template size heavily!!! +-- This produces the same bytecode as luac but does not have a strip option +compiler_enable_bytecode = false + + +-- Define the namespace for template modules +viewns = { + write = io.write, + include = function(name) Template(name):render(getfenv(2)) end, +} + +-- Compiles a given template into an executable Lua module +function compile(template) + -- Search all <% %> expressions (remember: Lua table indexes begin with #1) + local function expr_add(command) + table.insert(expr, command) + return "<%" .. tostring(#expr) .. "%>" + end + + -- As "expr" should be local, we have to assign it to the "expr_add" scope + local expr = {} + luci.util.extfenv(expr_add, "expr", expr) + + -- Save all expressiosn to table "expr" + template = template:gsub("<%%(.-)%%>", expr_add) + + local function sanitize(s) + s = luci.util.escape(s) + s = luci.util.escape(s, "'") + s = luci.util.escape(s, "\n") + return s + end + + -- Escape and sanitize all the template (all non-expressions) + template = sanitize(template) + + -- Template module header/footer declaration + local header = "write('" + local footer = "')" + + template = header .. template .. footer + + -- Replacements + local r_include = "')\ninclude('%s')\nwrite('" + local r_i18n = "'..translate('%1','%2')..'" + local r_pexec = "'..(%s or '')..'" + local r_exec = "')\n%s\nwrite('" + + -- Parse the expressions + for k,v in pairs(expr) do + local p = v:sub(1, 1) + local re = nil + if p == "+" then + re = r_include:format(sanitize(string.sub(v, 2))) + elseif p == ":" then + re = sanitize(v):gsub(":(.-) (.+)", r_i18n) + elseif p == "=" then + re = r_pexec:format(v:sub(2)) + else + re = r_exec:format(v) + end + template = template:gsub("<%%"..tostring(k).."%%>", re) + end + + if compiler_enable_bytecode then + tf = loadstring(template) + template = string.dump(tf) + end + + return template +end + +-- Oldstyle render shortcut +function render(name, scope, ...) + scope = scope or getfenv(2) + local s, t = pcall(Template, name) + if not s then + error(t) + else + t:render(scope, ...) + end +end + + +-- Template class +Template = luci.util.class() + +-- Shared template cache to store templates in to avoid unnecessary reloading +Template.cache = {} + + +-- Constructor - Reads and compiles the template on-demand +function Template.__init__(self, name) + if self.cache[name] then + self.template = self.cache[name] + else + self.template = nil + end + + -- Create a new namespace for this template + self.viewns = {} + + -- Copy over from general namespace + for k, v in pairs(viewns) do + self.viewns[k] = v + end + + -- If we have a cached template, skip compiling and loading + if self.template then + return + end + + -- Compile and build + local sourcefile = viewdir .. name .. ".htm" + local compiledfile = viewdir .. name .. ".lua" + local err + + if compiler_mode == "file" then + local tplmt = luci.fs.mtime(sourcefile) + local commt = luci.fs.mtime(compiledfile) + + -- Build if there is no compiled file or if compiled file is outdated + if ((commt == nil) and not (tplmt == nil)) + or (not (commt == nil) and not (tplmt == nil) and commt < tplmt) then + local source + source, err = luci.fs.readfile(sourcefile) + + if source then + local compiled = compile(source) + luci.fs.writefile(compiledfile, compiled) + self.template, err = loadstring(compiled) + end + else + self.template, err = loadfile(compiledfile) + end + + elseif compiler_mode == "none" then + self.template, err = loadfile(self.compiledfile) + + elseif compiler_mode == "memory" then + local source + source, err = luci.fs.readfile(sourcefile) + if source then + self.template, err = loadstring(compile(source)) + end + + end + + -- If we have no valid template throw error, otherwise cache the template + if not self.template then + error(err) + else + self.cache[name] = self.template + end +end + + +-- Renders a template +function Template.render(self, scope) + scope = scope or getfenv(2) + + -- Save old environment + local oldfenv = getfenv(self.template) + + -- Put our predefined objects in the scope of the template + luci.util.resfenv(self.template) + luci.util.updfenv(self.template, scope) + luci.util.updfenv(self.template, self.viewns) + + -- Now finally render the thing + self.template() + + -- Reset environment + setfenv(self.template, oldfenv) +end diff --git a/libs/web/src/config.lua b/libs/web/src/config.lua deleted file mode 100644 index 854b12814..000000000 --- a/libs/web/src/config.lua +++ /dev/null @@ -1,48 +0,0 @@ ---[[ -LuCI - Configuration - -Description: -Some LuCI configuration values read from uci file "luci" - - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.config", package.seeall) -require("luci.model.uci") -require("luci.util") -require("luci.sys") - --- Warning! This is only for fallback and compatibility purporses! -- -main = {} - --- This is where stylesheets and images go -main.mediaurlbase = "/luci/media" - --- Does anybody think about browser autodetect here? --- Too bad busybox doesn't populate HTTP_ACCEPT_LANGUAGE -main.lang = "de" - - --- Now overwrite with UCI values -local ucidata = luci.model.uci.sections("luci") -if ucidata then - luci.util.update(luci.config, ucidata) -end \ No newline at end of file diff --git a/libs/web/src/dispatcher.lua b/libs/web/src/dispatcher.lua deleted file mode 100644 index 175f0dcb0..000000000 --- a/libs/web/src/dispatcher.lua +++ /dev/null @@ -1,281 +0,0 @@ ---[[ -LuCI - Dispatcher - -Description: -The request dispatcher and module dispatcher generators - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.dispatcher", package.seeall) -require("luci.http") -require("luci.sys") -require("luci.fs") - --- Local dispatch database -local tree = {nodes={}} - --- Index table -local index = {} - --- Global request object -request = {} - --- Active dispatched node -dispatched = nil - --- Status fields -built_index = false -built_tree = false - - --- Builds a URL -function build_url(...) - return luci.http.dispatcher() .. "/" .. table.concat(arg, "/") -end - --- Sends a 404 error code and renders the "error404" template if available -function error404(message) - luci.http.status(404, "Not Found") - message = message or "Not Found" - - require("luci.template") - if not pcall(luci.template.render, "error404") then - luci.http.prepare_content("text/plain") - print(message) - end - return false -end - --- Sends a 500 error code and renders the "error500" template if available -function error500(message) - luci.http.status(500, "Internal Server Error") - - require("luci.template") - if not pcall(luci.template.render, "error500", {message=message}) then - luci.http.prepare_content("text/plain") - print(message) - end - return false -end - --- Creates a request object for dispatching -function httpdispatch() - local pathinfo = luci.http.env.PATH_INFO or "" - local c = tree - - for s in pathinfo:gmatch("([%w_]+)") do - table.insert(request, s) - end - - dispatch() -end - --- Dispatches a request -function dispatch() - if not built_tree then - createtree() - end - - local c = tree - local track = {} - - for i, s in ipairs(request) do - c = c.nodes[s] - if not c then - break - end - - for k, v in pairs(c) do - track[k] = v - end - end - - - if track.i18n then - require("luci.i18n").loadc(track.i18n) - end - - if track.setgroup then - luci.sys.process.setgroup(track.setgroup) - end - - if track.setuser then - luci.sys.process.setuser(track.setuser) - end - - -- Init template engine - local tpl = require("luci.template") - tpl.viewns.translate = function(...) return require("luci.i18n").translate(...) end - tpl.viewns.controller = luci.http.dispatcher() - tpl.viewns.uploadctrl = luci.http.dispatcher_upload() - tpl.viewns.media = luci.config.main.mediaurlbase - tpl.viewns.resource = luci.config.main.resourcebase - - -- Load default translation - require("luci.i18n").loadc("default") - - - if c and type(c.target) == "function" then - dispatched = c - - stat, err = pcall(c.target) - if not stat then - error500(err) - end - else - error404() - end -end - --- Generates the dispatching tree -function createindex() - index = {} - local path = luci.sys.libpath() .. "/controller/" - local suff = ".lua" - - if pcall(require, "fastindex") then - createindex_fastindex(path, suff) - else - createindex_plain(path, suff) - end - - built_index = true -end - --- Uses fastindex to create the dispatching tree -function createindex_fastindex(path, suffix) - local fi = fastindex.new("index") - fi.add(path .. "*" .. suffix) - fi.add(path .. "*/*" .. suffix) - fi.scan() - - for k, v in pairs(fi.indexes) do - index[v[2]] = v[1] - end -end - --- Calls the index function of all available controllers -function createindex_plain(path, suffix) - local controllers = luci.util.combine( - luci.fs.glob(path .. "*" .. suffix) or {}, - luci.fs.glob(path .. "*/*" .. suffix) or {} - ) - - for i,c in ipairs(controllers) do - c = "luci.controller." .. c:sub(#path+1, #c-#suffix):gsub("/", ".") - stat, mod = pcall(require, c) - - if stat and mod and type(mod.index) == "function" then - index[c] = mod.index - end - end -end - --- Creates the dispatching tree from the index -function createtree() - if not built_index then - createindex() - end - - for k, v in pairs(index) do - luci.util.updfenv(v, _M) - - local stat, mod = pcall(require, k) - if stat then - luci.util.updfenv(v, mod) - end - - pcall(v) - end - - built_tree = true -end - --- Shortcut for creating a dispatching node -function entry(path, target, title, order, add) - add = add or {} - - local c = node(path) - c.target = target - c.title = title - c.order = order - - for k,v in pairs(add) do - c[k] = v - end - - return c -end - --- Fetch a dispatching node -function node(...) - local c = tree - - if arg[1] and type(arg[1]) == "table" then - arg = arg[1] - end - - for k,v in ipairs(arg) do - if not c.nodes[v] then - c.nodes[v] = {nodes={}} - end - - c = c.nodes[v] - end - - return c -end - --- Subdispatchers -- -function alias(...) - local req = arg - return function() - request = req - dispatch() - end -end - -function template(name) - require("luci.template") - return function() luci.template.render(name) end -end - -function cbi(model) - require("luci.cbi") - require("luci.template") - - return function() - local stat, res = pcall(luci.cbi.load, model) - if not stat then - error500(res) - return true - end - - local stat, err = pcall(res.parse, res) - if not stat then - error500(err) - return true - end - - luci.template.render("cbi/header") - res:render() - luci.template.render("cbi/footer") - end -end diff --git a/libs/web/src/http.lua b/libs/web/src/http.lua deleted file mode 100644 index fa8821c5a..000000000 --- a/libs/web/src/http.lua +++ /dev/null @@ -1,36 +0,0 @@ ---[[ -LuCI - HTTP-Interaction - -Description: -HTTP-Header manipulator and form variable preprocessor - -FileId: -$Id$ - -ToDo: -- Cookie handling - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.http", package.seeall) - -if ENV and ENV.HASERLVER then - require("luci.sgi.haserl") -elseif webuci then - require("luci.sgi.webuci") -end \ No newline at end of file diff --git a/libs/web/src/i18n.lua b/libs/web/src/i18n.lua deleted file mode 100644 index 3a8a9a6c7..000000000 --- a/libs/web/src/i18n.lua +++ /dev/null @@ -1,63 +0,0 @@ ---[[ -LuCI - Internationalisation - -Description: -A very minimalistic but yet effective internationalisation module - -FileId: -$Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- - -module("luci.i18n", package.seeall) -require("luci.sys") - -table = {} -i18ndir = luci.sys.libpath() .. "/i18n/" - --- Clears the translation table -function clear() - table = {} -end - --- Loads a translation and copies its data into the global translation table -function load(file) - local f = loadfile(i18ndir .. file) - if f then - setfenv(f, table) - f() - return true - else - return false - end -end - --- Same as load but autocompletes the filename with .LANG from config.lang -function loadc(file) - return load(file .. "." .. require("luci.config").main.lang) -end - --- Returns the i18n-value defined by "key" or if there is no such: "default" -function translate(key, default) - return table[key] or default -end - --- Translate shourtcut with sprintf/string.format inclusion -function translatef(key, default, ...) - return translate(key, default):format(...) -end \ No newline at end of file diff --git a/libs/web/src/template.lua b/libs/web/src/template.lua deleted file mode 100644 index 369aa0a30..000000000 --- a/libs/web/src/template.lua +++ /dev/null @@ -1,220 +0,0 @@ ---[[ -LuCI - Template Parser - -Description: -A template parser supporting includes, translations, Lua code blocks -and more. It can be used either as a compiler or as an interpreter. - -FileId: $Id$ - -License: -Copyright 2008 Steven Barth - -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 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -]]-- -module("luci.template", package.seeall) - -require("luci.config") -require("luci.util") -require("luci.fs") -require("luci.http") - -viewdir = luci.sys.libpath() .. "/view/" - - --- Compile modes: --- none: Never compile, only use precompiled data from files --- memory: Always compile, do not save compiled files, ignore precompiled --- file: Compile on demand, save compiled files, update precompiled -compiler_mode = "memory" - - --- This applies to compiler modes "always" and "smart" --- --- Produce compiled lua code rather than lua sourcecode --- WARNING: Increases template size heavily!!! --- This produces the same bytecode as luac but does not have a strip option -compiler_enable_bytecode = false - - --- Define the namespace for template modules -viewns = { - write = io.write, - include = function(name) Template(name):render(getfenv(2)) end, -} - --- Compiles a given template into an executable Lua module -function compile(template) - -- Search all <% %> expressions (remember: Lua table indexes begin with #1) - local function expr_add(command) - table.insert(expr, command) - return "<%" .. tostring(#expr) .. "%>" - end - - -- As "expr" should be local, we have to assign it to the "expr_add" scope - local expr = {} - luci.util.extfenv(expr_add, "expr", expr) - - -- Save all expressiosn to table "expr" - template = template:gsub("<%%(.-)%%>", expr_add) - - local function sanitize(s) - s = luci.util.escape(s) - s = luci.util.escape(s, "'") - s = luci.util.escape(s, "\n") - return s - end - - -- Escape and sanitize all the template (all non-expressions) - template = sanitize(template) - - -- Template module header/footer declaration - local header = "write('" - local footer = "')" - - template = header .. template .. footer - - -- Replacements - local r_include = "')\ninclude('%s')\nwrite('" - local r_i18n = "'..translate('%1','%2')..'" - local r_pexec = "'..(%s or '')..'" - local r_exec = "')\n%s\nwrite('" - - -- Parse the expressions - for k,v in pairs(expr) do - local p = v:sub(1, 1) - local re = nil - if p == "+" then - re = r_include:format(sanitize(string.sub(v, 2))) - elseif p == ":" then - re = sanitize(v):gsub(":(.-) (.+)", r_i18n) - elseif p == "=" then - re = r_pexec:format(v:sub(2)) - else - re = r_exec:format(v) - end - template = template:gsub("<%%"..tostring(k).."%%>", re) - end - - if compiler_enable_bytecode then - tf = loadstring(template) - template = string.dump(tf) - end - - return template -end - --- Oldstyle render shortcut -function render(name, scope, ...) - scope = scope or getfenv(2) - local s, t = pcall(Template, name) - if not s then - error(t) - else - t:render(scope, ...) - end -end - - --- Template class -Template = luci.util.class() - --- Shared template cache to store templates in to avoid unnecessary reloading -Template.cache = {} - - --- Constructor - Reads and compiles the template on-demand -function Template.__init__(self, name) - if self.cache[name] then - self.template = self.cache[name] - else - self.template = nil - end - - -- Create a new namespace for this template - self.viewns = {} - - -- Copy over from general namespace - for k, v in pairs(viewns) do - self.viewns[k] = v - end - - -- If we have a cached template, skip compiling and loading - if self.template then - return - end - - -- Compile and build - local sourcefile = viewdir .. name .. ".htm" - local compiledfile = viewdir .. name .. ".lua" - local err - - if compiler_mode == "file" then - local tplmt = luci.fs.mtime(sourcefile) - local commt = luci.fs.mtime(compiledfile) - - -- Build if there is no compiled file or if compiled file is outdated - if ((commt == nil) and not (tplmt == nil)) - or (not (commt == nil) and not (tplmt == nil) and commt < tplmt) then - local source - source, err = luci.fs.readfile(sourcefile) - - if source then - local compiled = compile(source) - luci.fs.writefile(compiledfile, compiled) - self.template, err = loadstring(compiled) - end - else - self.template, err = loadfile(compiledfile) - end - - elseif compiler_mode == "none" then - self.template, err = loadfile(self.compiledfile) - - elseif compiler_mode == "memory" then - local source - source, err = luci.fs.readfile(sourcefile) - if source then - self.template, err = loadstring(compile(source)) - end - - end - - -- If we have no valid template throw error, otherwise cache the template - if not self.template then - error(err) - else - self.cache[name] = self.template - end -end - - --- Renders a template -function Template.render(self, scope) - scope = scope or getfenv(2) - - -- Save old environment - local oldfenv = getfenv(self.template) - - -- Put our predefined objects in the scope of the template - luci.util.resfenv(self.template) - luci.util.updfenv(self.template, scope) - luci.util.updfenv(self.template, self.viewns) - - -- Now finally render the thing - self.template() - - -- Reset environment - setfenv(self.template, oldfenv) -end diff --git a/modules/admin-core/luasrc/controller/admin/index.lua b/modules/admin-core/luasrc/controller/admin/index.lua new file mode 100644 index 000000000..11123c9c9 --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/index.lua @@ -0,0 +1,24 @@ +module("luci.controller.admin.index", package.seeall) + +function index() + local root = node() + if not root.target then + root.target = alias("admin") + end + + local page = node("admin") + page.target = alias("admin", "index") + page.title = "Administration" + page.order = 10 + + local page = node("admin", "index") + page.target = template("admin_index/index") + page.title = "Übersicht" + page.order = 10 + + local page = node("admin", "index", "luci") + page.target = cbi("admin_index/luci") + page.title = "Oberfläche" + + +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/network.lua b/modules/admin-core/luasrc/controller/admin/network.lua new file mode 100644 index 000000000..397f2e4ca --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/network.lua @@ -0,0 +1,39 @@ +module("luci.controller.admin.network", package.seeall) + +function index() + local page = node("admin", "network") + page.target = template("admin_network/index") + page.title = "Netzwerk" + page.order = 50 + + local page = node("admin", "network", "vlan") + page.target = cbi("admin_network/vlan") + page.title = "Switch" + page.order = 10 + + local page = node("admin", "network", "ifaces") + page.target = cbi("admin_network/ifaces") + page.title = "Schnittstellen" + page.order = 20 + + local page = node("admin", "network", "dhcp") + page.target = cbi("admin_network/dhcp") + page.title = "DHCP-Server" + page.order = 30 + + local page = node("admin", "network", "ptp") + page.target = cbi("admin_network/ptp") + page.title = "PPPoE / PPTP" + page.order = 40 + + local page = node("admin", "network", "routes") + page.target = cbi("admin_network/routes") + page.title = "Statische Routen" + page.order = 50 + + if luci.fs.isfile("/etc/config/qos") then + local page = node("admin", "network", "qos") + page.target = cbi("admin_network/qos") + page.title = "Quality of Service" + end +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/services.lua b/modules/admin-core/luasrc/controller/admin/services.lua new file mode 100644 index 000000000..4dcf837c6 --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/services.lua @@ -0,0 +1,29 @@ +module("luci.controller.admin.services", package.seeall) + +function index() + local page = node("admin", "services") + page.target = template("admin_services/index") + page.title = "Dienste" + page.order = 40 + + local page = node("admin", "services", "httpd") + page.target = cbi("admin_services/httpd") + page.title = "HTTP-Server" + page.order = 10 + + local page = node("admin", "services", "dropbear") + page.target = cbi("admin_services/dropbear") + page.title = "SSH-Server" + page.order = 20 + + local page = node("admin", "services", "dnsmasq") + page.target = cbi("admin_services/dnsmasq") + page.title = "Dnsmasq" + page.order = 30 + + if luci.fs.isfile("/etc/config/olsr") then + local page = node("admin", "services", "olsr") + page.target = cbi("admin_services/olsrd") + page.title = "OLSR" + end +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/status.lua b/modules/admin-core/luasrc/controller/admin/status.lua new file mode 100644 index 000000000..34c210ca6 --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/status.lua @@ -0,0 +1,11 @@ +module("luci.controller.admin.status", package.seeall) + +function index() + entry({"admin", "status"}, template("admin_status/index"), "Status", 20) + entry({"admin", "status", "syslog"}, action_syslog, "Systemprotokoll") +end + +function action_syslog() + local syslog = luci.sys.syslog() + luci.template.render("admin_status/syslog", {syslog=syslog}) +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/system.lua b/modules/admin-core/luasrc/controller/admin/system.lua new file mode 100644 index 000000000..e44e787fd --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/system.lua @@ -0,0 +1,245 @@ +module("luci.controller.admin.system", package.seeall) + +require("luci.sys") +require("luci.http") +require("luci.util") +require("luci.fs") +require("luci.model.ipkg") +require("luci.model.uci") + +function index() + local page = node("admin", "system") + page.target = template("admin_system/index") + page.title = "System" + page.order = 30 + + local page = node("admin", "system", "packages") + page.target = action_packages + page.title = "Paketverwaltung" + page.order = 10 + + local page = node("admin", "system", "packages", "ipkg") + page.target = action_ipkg + page.title = "IPKG-Konfiguration" + + local page = node("admin", "system", "passwd") + page.target = action_passwd + page.title = "Passwort ändern" + page.order = 20 + + local page = node("admin", "system", "sshkeys") + page.target = action_sshkeys + page.title = "SSH-Schlüssel" + page.order = 30 + + local page = node("admin", "system", "hostname") + page.target = cbi("admin_system/hostname") + page.title = "Hostname" + page.order = 40 + + local page = node("admin", "system", "fstab") + page.target = cbi("admin_system/fstab") + page.title = "Einhängepunkte" + page.order = 50 + + local page = node("admin", "system", "upgrade") + page.target = action_upgrade + page.title = "Firmwareupgrade" + page.order = 60 + + local page = node("admin", "system", "reboot") + page.target = action_reboot + page.title = "Neu starten" + page.order = 70 +end + +function action_editor() + local file = luci.http.formvalue("file", "") + local data = luci.http.formvalue("data") + local err = nil + local msg = nil + local stat = true + + if file and data then + stat, err = luci.fs.writefile(file, data) + end + + if not stat then + err = luci.util.split(err, " ") + table.remove(err, 1) + msg = table.concat(err, " ") + end + + local cnt, err = luci.fs.readfile(file) + if cnt then + cnt = luci.util.pcdata(cnt) + end + luci.template.render("admin_system/editor", {fn=file, cnt=cnt, msg=msg}) +end + +function action_ipkg() + local file = "/etc/ipkg.conf" + local data = luci.http.formvalue("data") + local stat = nil + local err = nil + + if data then + stat, err = luci.fs.writefile(file, data) + end + + local cnt = luci.fs.readfile(file) + if cnt then + cnt = luci.util.pcdata(cnt) + end + + luci.template.render("admin_system/ipkg", {cnt=cnt, msg=err}) +end + +function action_packages() + local ipkg = luci.model.ipkg + local void = nil + local submit = luci.http.formvalue("submit") + + + -- Search query + local query = luci.http.formvalue("query") + query = (query ~= '') and query or nil + + + -- Packets to be installed + local install = submit and luci.http.formvaluetable("install") + + -- Install from URL + local url = luci.http.formvalue("url") + if url and url ~= '' and submit then + if not install then + install = {} + end + install[url] = 1 + end + + -- Do install + if install then + for k, v in pairs(install) do + void, install[k] = ipkg.install(k) + end + end + + + -- Remove packets + local remove = submit and luci.http.formvaluetable("remove") + if remove then + for k, v in pairs(remove) do + void, remove[k] = ipkg.remove(k) + end + end + + + -- Update all packets + local update = luci.http.formvalue("update") + if update then + void, update = ipkg.update() + end + + + -- Upgrade all packets + local upgrade = luci.http.formvalue("upgrade") + if upgrade then + void, upgrade = ipkg.upgrade() + end + + + -- Package info + local info = luci.model.ipkg.info(query) + info = info or {} + local pkgs = {} + + -- Sort after status and name + for k, v in pairs(info) do + local x = 0 + for i, j in pairs(pkgs) do + local vins = (v.Status and v.Status.installed) + local jins = (j.Status and j.Status.installed) + if vins ~= jins then + if vins then + break + end + else + if j.Package > v.Package then + break + end + end + x = i + end + table.insert(pkgs, x+1, v) + end + + luci.template.render("admin_system/packages", {pkgs=pkgs, query=query, + install=install, remove=remove, update=update, upgrade=upgrade}) +end + +function action_passwd() + local p1 = luci.http.formvalue("pwd1") + local p2 = luci.http.formvalue("pwd2") + local stat = nil + + if p1 or p2 then + if p1 == p2 then + stat = luci.sys.user.setpasswd("root", p1) + else + stat = 10 + end + end + + luci.template.render("admin_system/passwd", {stat=stat}) +end + +function action_reboot() + local reboot = luci.http.formvalue("reboot") + luci.template.render("admin_system/reboot", {reboot=reboot}) + if reboot then + luci.sys.reboot() + end +end + +function action_sshkeys() + local file = "/etc/dropbear/authorized_keys" + local data = luci.http.formvalue("data") + local stat = nil + local err = nil + + if data then + stat, err = luci.fs.writefile(file, data) + end + + local cnt = luci.fs.readfile(file) + if cnt then + cnt = luci.util.pcdata(cnt) + end + + luci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err}) +end + +function action_upgrade() + local ret = nil + local plat = luci.fs.mtime("/lib/upgrade/platform.sh") + + local image = luci.http.upload("image") + local keepcfg = luci.http.formvalue("keepcfg") + + if plat and image then + local kpattern = nil + if keepcfg then + local files = luci.model.uci.sections("luci").flash_keep + if files.luci and files.luci.flash_keep then + kpattern = "" + for k,v in pairs(files.luci.flash_keep) do + kpattern = kpattern .. " " .. v + end + end + end + ret = luci.sys.flash(image, kpattern) + end + + luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret}) +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/uci.lua b/modules/admin-core/luasrc/controller/admin/uci.lua new file mode 100644 index 000000000..ca1440bde --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/uci.lua @@ -0,0 +1,67 @@ +module("luci.controller.admin.uci", package.seeall) +require("luci.util") +require("luci.sys") + +function index() + node("admin", "uci", "changes").target = template("admin_uci/changes") + node("admin", "uci", "revert").target = action_revert + node("admin", "uci", "apply").target = action_apply +end + +-- This function has a higher priority than the admin_uci/apply template +function action_apply() + local changes = luci.model.uci.changes() + local output = "" + + if changes then + local com = {} + local run = {} + + -- Collect files to be applied and commit changes + for i, line in ipairs(luci.util.split(changes)) do + local r = line:match("^-?([^.]+)") + if r then + com[r] = true + + if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then + run[luci.config.uci_oncommit[r]] = true + end + end + end + + -- Apply + for config, i in pairs(com) do + luci.model.uci.commit(config) + end + + -- Search for post-commit commands + for cmd, i in pairs(run) do + output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n" + end + end + + luci.template.render("admin_uci/apply", {changes=changes, output=output}) +end + + +function action_revert() + local changes = luci.model.uci.changes() + if changes then + local revert = {} + + -- Collect files to be reverted + for i, line in ipairs(luci.util.split(changes)) do + local r = line:match("^-?([^.]+)") + if r then + revert[r] = true + end + end + + -- Revert them + for k, v in pairs(revert) do + luci.model.uci.revert(k) + end + end + + luci.template.render("admin_uci/revert", {changes=changes}) +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/controller/admin/wifi.lua b/modules/admin-core/luasrc/controller/admin/wifi.lua new file mode 100644 index 000000000..0da6b7983 --- /dev/null +++ b/modules/admin-core/luasrc/controller/admin/wifi.lua @@ -0,0 +1,18 @@ +module("luci.controller.admin.wifi", package.seeall) + +function index() + local page = node("admin", "wifi") + page.target = template("admin_wifi/index") + page.title = "Drahtlos" + page.order = 60 + + local page = node("admin", "wifi", "devices") + page.target = cbi("admin_wifi/devices") + page.title = "Geräte" + page.order = 10 + + local page = node("admin", "wifi", "networks") + page.target = cbi("admin_wifi/networks") + page.title = "Netze" + page.order = 20 +end \ No newline at end of file diff --git a/modules/admin-core/luasrc/i18n/admin_index.en b/modules/admin-core/luasrc/i18n/admin_index.en new file mode 100644 index 000000000..0831b59f0 --- /dev/null +++ b/modules/admin-core/luasrc/i18n/admin_index.en @@ -0,0 +1,20 @@ +luci = "User Interface" + +hello = "Hello!" +admin1 = "This is the administration area of LuCI." +admin2 = "LuCI is a free, flexible, and user friendly graphical interface for configuring OpenWRT Kamikaze." +admin3 = "On the following pages you can adjust all important settings of your router." +admin4 = "You will find a navigation leading to the different configuration pages on the left side." +admin5 = [[As we are always want to improve this interface we are looking forward +to your feedback and suggestions.]] +admin6 = "And now have fun with your router!" +team = "The LuCI Team" + +luci1 = "Here you can customize the settings and the functionality of LuCI." +language = "Language" +general = "General" +ucicommit = "Post-commit actions" +ucicommit1 = [[These commands will be executed automatically when a given UCI configuration is committed allowing +changes to be applied instantly.]] +keepflash = "Files to be kept when flashing a new firmware" +keepflash1 = "When flashing a new firmware with LuCI these files will be added to the new firmware installation." \ No newline at end of file diff --git a/modules/admin-core/luasrc/i18n/admin_uci.en b/modules/admin-core/luasrc/i18n/admin_uci.en new file mode 100644 index 000000000..00ac5f5ff --- /dev/null +++ b/modules/admin-core/luasrc/i18n/admin_uci.en @@ -0,0 +1,2 @@ +uci_applied = "The following changes were applied" +uci_reverted = "The following changes were reverted" \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_index/luci.lua b/modules/admin-core/luasrc/model/cbi/admin_index/luci.lua new file mode 100644 index 000000000..bb6bc1820 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_index/luci.lua @@ -0,0 +1,33 @@ +-- ToDo: Translate +require("luci.config") +m = Map("luci", translate("luci", "Oberfläche"), translate("luci1", + "Hier können Eigenschaften und die Funktionalität der Oberfläche angepasst werden.")) + +c = m:section(NamedSection, "main", "core", translate("general", "Allgemein")) + +l = c:option(ListValue, "lang", translate("language", "Sprache")) +for k, v in pairs(luci.config.languages) do + if k:sub(1, 1) ~= "." then + l:value(k, v) + end +end + +t = c:option(ListValue, "mediaurlbase", translate("design", "Design")) +for k, v in pairs(luci.config.themes) do + if k:sub(1, 1) ~= "." then + t:value(v, k) + end +end + +u = m:section(NamedSection, "uci_oncommit", "event", translate("ucicommit", "UCI-Befehle beim Anwenden"), + translate("ucicommit1", [[Beim Anwenden +der Konfiguration aus der Oberflächliche heraus können automatisch die relevanten Dienste neugestart werden, +sodass Änderungen sofort nach dem Anwenden aktiv werden und der Router nicht erst neugestartet werden muss.]])) +u.dynamic = true + +f = m:section(NamedSection, "flash_keep", "extern", translate("keepflash", "Zu übernehmende Dateien bei Firmwareupgrade"), + translate("keepflash1", [[Die folgenden Dateien und Verzeichnisse werden beim Aktualisieren der Firmware +über die Oberfläche automatisch in die neue Firmware übernommen.]])) +f.dynamic = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua b/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua new file mode 100644 index 000000000..63ef0aa3d --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/dhcp.lua @@ -0,0 +1,41 @@ +-- ToDo: Translate, Add descriptions and help texts +require("luci.model.uci") +require("luci.sys") + +m = Map("dhcp", "DHCP", [[Mit Hilfe von DHCP können Netzteilnehmer automatisch +ihre Netzwerkkonfiguration (IP-Adresse, Netzmaske, DNS-Server, DHCP, ...) beziehen.]]) + +s = m:section(TypedSection, "dhcp") +s.addremove = true +s.anonymous = true + +iface = s:option(ListValue, "interface", "Schnittstelle") +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + s:depends("interface", k) -- Only change sections with existing interfaces + end +end + +s:option(Value, "start", "Start", "Erste vergebene Adresse (letztes Oktett)").rmempty = true + +s:option(Value, "limit", "Limit", "Anzahl zu vergebender Adressen -1").rmempty = true + +s:option(Value, "leasetime", "Laufzeit").rmempty = true + +s:option(Flag, "dynamicdhcp", "Dynamisches DHCP").rmempty = true + +s:option(Value, "name", "Name").optional = true + +s:option(Flag, "ignore", "Schnittstelle ignorieren", "DHCP für dieses Netzwerk deaktivieren").optional = true + +s:option(Value, "netmask", "Netzmaske").optional = true + +s:option(Flag, "force", "Start erzwingen").optional = true + +for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do + k, v = line:match("([^ ]+) +([^ ]+)") + s:option(Value, "dhcp"..k, v).optional = true +end + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/ifaces.lua b/modules/admin-core/luasrc/model/cbi/admin_network/ifaces.lua new file mode 100644 index 000000000..2dd190957 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/ifaces.lua @@ -0,0 +1,43 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("network", "Schnittstellen", [[An dieser Stelle können die einzelnen Schnittstellen +des Netzwerkes konfiguriert werden. Es können mehrere Schnittstellen zu einer Brücke zusammengefasst werden, +indem diese durch Leerzeichen getrennt aufgezählt werden und ein entsprechender Haken im Feld Netzwerkbrücke +gesetzt wird. Es können VLANs in der Notation SCHNITTSTELLE.VLANNR (z.B.: eth0.1) verwendet werden.]]) + +s = m:section(TypedSection, "interface") +s.addremove = true +s:exclude("loopback") +s:depends("proto", "static") +s:depends("proto", "dhcp") + +p = s:option(ListValue, "proto", "Protokoll") +p:value("static", "statisch") +p:value("dhcp", "DHCP") +p.default = "static" + +br = s:option(Flag, "type", "Netzwerkbrücke", "überbrückt angegebene Schnittstelle(n)") +br.enabled = "bridge" +br.rmempty = true + +s:option(Value, "ifname", "Schnittstelle") + +s:option(Value, "ipaddr", "IP-Adresse") + +s:option(Value, "netmask", "Netzmaske"):depends("proto", "static") + +gw = s:option(Value, "gateway", "Gateway") +gw:depends("proto", "static") +gw.rmempty = true + +dns = s:option(Value, "dns", "DNS-Server") +dns:depends("proto", "static") +dns.optional = true + +mtu = s:option(Value, "mtu", "MTU") +mtu.optional = true +mtu.isinteger = true + +mac = s:option(Value, "macaddr", "MAC-Adresse") +mac.optional = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/ptp.lua b/modules/admin-core/luasrc/model/cbi/admin_network/ptp.lua new file mode 100644 index 000000000..6a627f268 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/ptp.lua @@ -0,0 +1,33 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("network", "Punkt-zu-Punkt Verbindungen", [[Punkt-zu-Punkt Verbindungen +über PPPoE oder PPTP werden häufig dazu verwendet, um über DSL o.ä. Techniken eine +Verbindung zum Internetgateway eines Internetzugangsanbieters aufzubauen.]]) + +s = m:section(TypedSection, "interface") +s.addremove = true +s:depends("proto", "pppoe") +s:depends("proto", "pptp") + +p = s:option(ListValue, "proto", "Protokoll") +p:value("pppoe", "PPPoE") +p:value("pptp", "PPTP") +p.default = "pppoe" + +s:option(Value, "ifname", "Schnittstelle") + +s:option(Value, "username", "Benutzername") +s:option(Value, "password", "Passwort") + +s:option(Value, "keepalive", "Keep-Alive", "Bei einer Verbindungstrennung automatisch neu verbinden").optional = true + +s:option(Value, "demand", "Dial on Demand (idle time)", "Zeit nach der die Verbindung bei Inaktivität getrennt wird").optional = true + +srv = s:option(Value, "server", "PPTP-Server") +srv:depends("proto", "pptp") +srv.optional = true + +mtu = s:option(Value, "mtu", "MTU") +mtu.optional = true +mtu.isinteger = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/qos.lua b/modules/admin-core/luasrc/model/cbi/admin_network/qos.lua new file mode 100644 index 000000000..d58130f10 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/qos.lua @@ -0,0 +1,56 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("qos", "Quality of Service", [[Mit Hilfe von QoS kann einzelnen Rechnern oder Netzwerkdiensten +eine höhere oder niedrigere Priorität zugewiesen werden.]]) + +s = m:section(TypedSection, "interface", "Schnittstellen") +s.addremove = true + +s:option(Flag, "enabled", "aktiviert") + +c = s:option(ListValue, "classgroup", "Klassifizierung") +c:value("Default", "standard") +c.default = "Default" + +s:option(Flag, "overhead", "Overheadberechnung") + +s:option(Value, "download", "Downlink", "kb/s") + +s:option(Value, "upload", "Uplink", "kb/s") + +s = m:section(TypedSection, "classify", "Klassifizierung") + +s.anonymous = true +s.addremove = true + +t = s:option(ListValue, "target", "Klasse") +t:value("Priority") +t:value("Express") +t:value("Normal") +t:value("Bulk") +t.default = "Normal" + +s:option(Value, "srchost", "Quelladresse", "Quellhost / Quellnetz").optional = true +s:option(Value, "dsthost", "Zieladresse", "Zielhost / Zielnetz").optional = true +s:option(Value, "layer7", "Layer 7").optional = true + +p2p = s:option(ListValue, "ipp2p", "P2P") +p2p:value("") +p2p:value("all", "Alle") +p2p:value("bit", "Bittorrent") +p2p:value("dc", "DirectConnect") +p2p:value("edk", "eDonkey") +p2p:value("gnu", "Gnutella") +p2p:value("kazaa", "Kazaa") +p2p.optional = true + +p = s:option(ListValue, "proto", "Protokoll") +p:value("") +p:value("tcp", "TCP") +p:value("udp", "UDP") +p:value("icmp", "ICMP") +p.optional = true + +s:option(Value, "ports", "Port").optional = true +s:option(Value, "portrange", "Portbereich").optional = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua b/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua new file mode 100644 index 000000000..a2a27eb26 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/routes.lua @@ -0,0 +1,24 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("network", "Statische Routen", [[Statische Routen geben an, +über welche Schnittstelle und welches Gateway ein bestimmter Host +oder ein bestimmtes Netzwerk erreicht werden kann.]]) + +s = m:section(TypedSection, "route") +s.addremove = true +s.anonymous = true +s.template = "cbi/tblsection" + +iface = s:option(ListValue, "interface", "Schnittstelle") +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + iface:value(k) + end +end + +s:option(Value, "target", "Ziel", "Host-IP oder Netzwerk") + +s:option(Value, "netmask", "Netzmaske", "falls Ziel ein Netzwerk ist").rmemepty = true + +s:option(Value, "gateway", "Gateway") + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_network/vlan.lua b/modules/admin-core/luasrc/model/cbi/admin_network/vlan.lua new file mode 100644 index 000000000..7b493643b --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_network/vlan.lua @@ -0,0 +1,17 @@ +-- ToDo: Autodetect things, maybe use MultiValue instead, Translate, Add descriptions +m = Map("network", "VLAN", [[Die Netzwerkschnittstellen am Router +können zu verschienden VLANs zusammengefasst werden, in denen Geräte miteinander direkt +kommunizieren können. VLANs werden auch häufig dazu genutzt, um Netzwerke voneiander zu trennen. +So ist oftmals eine Schnittstelle als Uplink zu einem größerem Netz, wie dem Internet vorkonfiguriert +und die anderen Schnittstellen bilden ein VLAN für das lokale Netzwerk.]]) + +s = m:section(TypedSection, "switch", nil, [[Die zu einem VLAN gehörenden Schnittstellen +werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet +in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen +ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers.]]) + +for i = 0, 15 do + s:option(Value, "vlan"..i, "vlan"..i).optional = true +end + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_services/dnsmasq.lua b/modules/admin-core/luasrc/model/cbi/admin_services/dnsmasq.lua new file mode 100644 index 000000000..86716ff9f --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_services/dnsmasq.lua @@ -0,0 +1,29 @@ +m = Map("dhcp", "Dnsmasq", "Dnsmasq ist ein kombinierter DHCP-Server und DNS-Forwarder für NAT-Firewalls.") + +s = m:section(TypedSection, "dnsmasq", "Einstellungen") +s.anonymous = true + +s:option(Flag, "domainneeded", "Anfragen nur mit Domain", "Anfragen ohne Domainnamen nicht weiterleiten") +s:option(Flag, "authoritative", "Authoritativ", "Dies ist der einzige DHCP im lokalen Netz") +s:option(Flag, "boguspriv", "Private Anfragen filtern", "Reverse DNS-Anfragen für lokalen Netze nicht weiterleiten") +s:option(Flag, "filterwin2k", "Windowsanfragen filtern", "nutzlose DNS-Anfragen aktueller Windowssysteme filtern") +s:option(Flag, "localise_queries", "Lokalisiere Anfragen", "Gibt die Adresse eines Hostnamen entsprechend seines Subnetzes zurück") +s:option(Value, "local", "Lokale Server") +s:option(Value, "domain", "Lokale Domain") +s:option(Flag, "expandhosts", "Erweitere Hosts", "Fügt Domainnamen zu einfachen Hosteinträgen in der Resolvdatei hinzu") +s:option(Flag, "nonegcache", "Unbekannte nicht cachen", "Negative DNS-Antworten nicht zwischenspeichern") +s:option(Flag, "readethers", "Verwende /etc/ethers", "Lese Informationen aus /etc/ethers um den DHCP-Server zu konfigurieren") +s:option(Value, "leasefile", "Leasedatei", "Speicherort für vergebenen DHCP-Adressen") +s:option(Value, "resolvfile", "Resolvdatei", "Lokale DNS-Datei") +s:option(Flag, "nohosts", "Ignoriere /etc/hosts").optional = true +s:option(Flag, "strictorder", "Strikte Reihenfolge", "DNS-Server werden strikt der Reihenfolge in der Resolvdatei nach abgefragt").optional = true +s:option(Flag, "logqueries", "Schreibe Abfragelog").optional = true +s:option(Flag, "noresolv", "Ignoriere Resolvdatei").optional = true +s:option(Value, "dnsforwardmax", "gleichzeitige Abfragen").optional = true +s:option(Value, "port", "DNS-Port").optional = true +s:option(Value, "ednspacket_max", "max. EDNS.0 Paketgröße").optional = true +s:option(Value, "dhcpleasemax", "max. DHCP-Leases").optional = true +s:option(Value, "addnhosts", "Zusätzliche Hostdatei").optional = true +s:option(Value, "queryport", "Abfrageport").optional = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_services/dropbear.lua b/modules/admin-core/luasrc/model/cbi/admin_services/dropbear.lua new file mode 100644 index 000000000..3ecf95335 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_services/dropbear.lua @@ -0,0 +1,15 @@ +-- ToDo: Translate, Add descriptions +m = Map("dropbear", "SSH-Server", [[Der SSH-Server ermöglicht Shell-Zugriff +über das Netzwerk und bietet einen integrierten SCP-Dienst.]]) + +s = m:section(TypedSection, "dropbear") +s.anonymous = true + +port = s:option(Value, "Port", "Port") +port.isinteger = true + +pwauth = s:option(Flag, "PasswordAuth", "Passwortanmeldung", "Erlaube Anmeldung per Passwort") +pwauth.enabled = 'on' +pwauth.disabled = 'off' + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_services/httpd.lua b/modules/admin-core/luasrc/model/cbi/admin_services/httpd.lua new file mode 100644 index 000000000..3bd49a2d7 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_services/httpd.lua @@ -0,0 +1,18 @@ +-- ToDo: Translate, Add descriptions +m = Map("httpd", "HTTP-Server", "Der HTTP-Server ist u.a. für die Bereitstellung dieser Obefläche zuständig.") + +s = m:section(TypedSection, "httpd") +s.anonymous = true + +port = s:option(Value, "port", "Port") +port.isinteger = true + +s:option(Value, "home", "Wurzelverzeichnis") + +config = s:option(Value, "c_file", "Konfigurationsdatei", "/etc/httpd.conf wenn leer") +config.rmempty = true + +realm = s:option(Value, "realm", "Anmeldeaufforderung", "Aufforderungstext zum Anmelden im Administrationsbereich") +realm.rmempty = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua b/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua new file mode 100644 index 000000000..a1a197808 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_services/olsrd.lua @@ -0,0 +1,89 @@ +-- ToDo: Autodetect things, Translate, Add descriptions +require("luci.fs") + +m = Map("olsr", "OLSR", [[OLSR ist ein flexibles Routingprotokoll, +dass den Aufbau von mobilen Ad-Hoc Netzen unterstützt.]]) + +s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen") + +debug = s:option(ListValue, "DebugLevel", "Debugmodus") +for i=0, 9 do + debug:value(i) +end + +ipv = s:option(ListValue, "IpVersion", "Internet Protokoll") +ipv:value("4", "IPv4") +ipv:value("6", "IPv6") + +noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk") +noint.enabled = "yes" +noint.disabled = "no" + +s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s") + +tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz") +tcr:value("0", "MPR-Selektoren") +tcr:value("1", "MPR-Selektoren und MPR") +tcr:value("2", "Alle Nachbarn") + +s:option(Value, "MprCoverage", "MPR-Erfassung") + +lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level") +lql:value("0", "deaktiviert") +lql:value("1", "MPR-Auswahl") +lql:value("2", "MPR-Auswahl und Routing") + +lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye") + +s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße") + +s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit") + +hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren") +hyst.enabled = "yes" +hyst.disabled = "no" + + +i = m:section(TypedSection, "Interface", "Schnittstellen") +i.anonymous = true +i.addremove = true +i.dynamic = true + +network = i:option(ListValue, "Interface", "Netzwerkschnittstellen") +network:value("") +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + network:value(k) + end +end + +i:option(Value, "HelloInterval", "Hello-Intervall") + +i:option(Value, "HelloValidityTime", "Hello-Gültigkeit") + +i:option(Value, "TcInterval", "TC-Intervall") + +i:option(Value, "TcValidityTime", "TC-Gültigkeit") + +i:option(Value, "MidInterval", "MID-Intervall") + +i:option(Value, "MidValidityTime", "MID-Gültigkeit") + +i:option(Value, "HnaInterval", "HNA-Intervall") + +i:option(Value, "HnaValidityTime", "HNA-Gültigkeit") + + +p = m:section(TypedSection, "LoadPlugin", "Plugins") +p.addremove = true +p.dynamic = true + +lib = p:option(ListValue, "Library", "Bibliothek") +lib:value("") +for k, v in pairs(luci.fs.dir("/usr/lib")) do + if v:sub(1, 6) == "olsrd_" then + lib:value(v) + end +end + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_system/fstab.lua b/modules/admin-core/luasrc/model/cbi/admin_system/fstab.lua new file mode 100644 index 000000000..d705743a0 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_system/fstab.lua @@ -0,0 +1,25 @@ +m = Map("fstab", "Einhängepunkte") + +mount = m:section(TypedSection, "mount", "Einhängepunkte", [[Einhängepunkte bestimmen, an welcher Stelle des Dateisystems +bestimmte Laufwerke und Speicher zur Verwendung eingebunden werden.]]) +mount.anonymous = true +mount.addremove = true + +mount:option(Flag, "enabled", "aktivieren") +mount:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)") +mount:option(Value, "target", "Einhängepunkt", "Die Stelle an der der Speicher in das Dateisystem eingehängt wird.") +mount:option(Value, "fstype", "Dateisystem", "Das Dateisystem mit dem der Speicher formatiert ist (z.B.: ext3)") +mount:option(Value, "options", "Optionen", "Weitere Optionen (siehe das Handbuch des Befehls 'mount')") + + +swap = m:section(TypedSection, "swap", "SWAP", [[Falls der Arbeitsspeicher des Routers nicht ausreicht, +kann dieser nicht benutzte Daten zeitweise auf einem SWAP-Laufwerk auslagern um so die +effektive Größe des Arbeitsspeichers zu erhöhen. Die Auslagerung der Daten ist natürlich bedeutend langsamer +als direkte Arbeitsspeicherzugriffe.]]) +swap.anonymous = true +swap.addremove = true + +swap:option(Flag, "enabled", "aktivieren") +swap:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)") + +return m diff --git a/modules/admin-core/luasrc/model/cbi/admin_system/hostname.lua b/modules/admin-core/luasrc/model/cbi/admin_system/hostname.lua new file mode 100644 index 000000000..c9e159d05 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_system/hostname.lua @@ -0,0 +1,9 @@ +m = Map("system", "Hostname", [[Definiert den Hostnamen des Routers. +Der Hostname ist eine im Netzwerk eindeutige Kennung, die dieses Gerät identifiziert.]]) + +s = m:section(TypedSection, "system") +s.anonymous = true + +s:option(Value, "hostname", "Hostname") + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_wifi/devices.lua b/modules/admin-core/luasrc/model/cbi/admin_wifi/devices.lua new file mode 100644 index 000000000..2931a6e55 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_wifi/devices.lua @@ -0,0 +1,52 @@ +-- ToDo: Translate, Add descriptions and help texts + +m = Map("wireless", "Geräte", [[An dieser Stelle können eingebaute WLAN-Geräte konfiguriert werden.]]) + +s = m:section(TypedSection, "wifi-device") +--s.addremove = true + +en = s:option(Flag, "disabled", "Aktivieren") +en.enabled = "0" +en.disabled = "1" + +t = s:option(ListValue, "type", "Typ") +t:value("broadcom") +t:value("atheros") +t:value("mac80211") +t:value("prism2") +--[[ +require("luci.sys") +local c = ". /etc/functions.sh;for i in /lib/wifi/*;do . $i;done;echo $DRIVERS" +for driver in luci.sys.execl(c)[1]:gmatch("[^ ]+") do + t:value(driver) +end +]]-- + +mode = s:option(ListValue, "mode", "Modus") +mode:value("", "standard") +mode:value("11b", "802.11b") +mode:value("11g", "802.11g") +mode:value("11a", "802.11a") +mode:value("11bg", "802.11b+g") +mode.rmempty = true + +s:option(Value, "channel", "Funkkanal") + +s:option(Value, "txantenna", "Sendeantenne").rmempty = true + +s:option(Value, "rxantenna", "Empfangsantenne").rmempty = true + +s:option(Value, "distance", "Distanz", + "Distanz zum am weitesten entfernten Funkpartner (m)").rmempty = true + +s:option(Value, "diversity", "Diversität"):depends("type", "atheros") + +country = s:option(Value, "country", "Ländercode") +country.optional = true +country:depends("type", "broadcom") + +maxassoc = s:option(Value, "maxassoc", "Verbindungslimit") +maxassoc:depends("type", "broadcom") +maxassoc.optional = true + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua b/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua new file mode 100644 index 000000000..a5be6f502 --- /dev/null +++ b/modules/admin-core/luasrc/model/cbi/admin_wifi/networks.lua @@ -0,0 +1,77 @@ +-- ToDo: Translate, Add descriptions and help texts +m = Map("wireless", "Netze", [[Pro WLAN-Gerät können mehrere Netze bereitgestellt werden. +Es sollte beachtet werden, dass es hardware- / treiberspezifische Einschränkungen gibt. +So kann pro WLAN-Gerät in der Regel entweder 1 Ad-Hoc-Zugang ODER bis zu 3 Access-Point und 1 Client-Zugang +gleichzeitig erstellt werden.]]) + +s = m:section(TypedSection, "wifi-iface") +s.addremove = true +s.anonymous = true + +s:option(Value, "ssid", "Netzkennung (ESSID)").maxlength = 32 + +device = s:option(ListValue, "device", "Gerät") +local d = luci.model.uci.sections("wireless") +if d then + for k, v in pairs(d) do + if v[".type"] == "wifi-device" then + device:value(k) + end + end +end + +network = s:option(ListValue, "network", "Netzwerk", "WLAN-Netz zu Netzwerk hinzufügen") +network:value("") +for k, v in pairs(luci.model.uci.sections("network")) do + if v[".type"] == "interface" and k ~= "loopback" then + network:value(k) + end +end + +mode = s:option(ListValue, "mode", "Modus") +mode:value("ap", "Access Point") +mode:value("adhoc", "Ad-Hoc") +mode:value("sta", "Client") +mode:value("wds", "WDS") + +s:option(Value, "bssid", "BSSID").optional = true + +s:option(Value, "txpower", "Sendeleistung", "dbm").rmempty = true + +s:option(Flag, "frameburst", "Broadcom-Frameburst").optional = true +s:option(Flag, "bursting", "Atheros-Frameburst").optional = true + + +encr = s:option(ListValue, "encryption", "Verschlüsselung") +encr:value("none", "keine") +encr:value("wep", "WEP") +encr:value("psk", "WPA-PSK") +encr:value("wpa", "WPA-Radius") +encr:value("psk2", "WPA2-PSK") +encr:value("wpa2", "WPA2-Radius") + +key = s:option(Value, "key", "Schlüssel") +key:depends("encryption", "wep") +key:depends("encryption", "psk") +key:depends("encryption", "wpa") +key:depends("encryption", "psk2") +key:depends("encryption", "wpa2") +key.rmempty = true + +server = s:option(Value, "server", "Radius-Server") +server:depends("encryption", "wpa") +server:depends("encryption", "wpa2") +server.rmempty = true + +port = s:option(Value, "port", "Radius-Port") +port:depends("encryption", "wpa") +port:depends("encryption", "wpa2") +port.rmempty = true + +s:option(Flag, "isolate", "AP-Isolation", "Unterbindet Client-Client-Verkehr").optional = true + +s:option(Flag, "hidden", "ESSID verstecken").optional = true + + + +return m \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_index/index.htm b/modules/admin-core/luasrc/view/admin_index/index.htm new file mode 100644 index 000000000..2e5c7c374 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_index/index.htm @@ -0,0 +1,11 @@ +<%+header%> +

<%:hello Hallo!%>

+

<%:admin1 Dies ist der Administrationsbereich von LuCI.%>

+

<%:admin2 LuCI ist eine freie, flexible und benutzerfreundliche grafische Oberfläche zur Konfiguration von OpenWRT Kamikaze.%>
+<%:admin3 Auf den folgenden Seiten können alle wichtigen Einstellungen des Routers vorgenommen werden.%>

+

<%:admin4 Auf der linken Seite befindet sich eine Navigation, die zu den einzelnen Konfigurationsseiten führt.%>

+

<%:admin5 Wir sind natürlich stets darum bemüht, diese Oberfläche +noch besser und intuitiver zu Gestalten und freuen uns über jegliche Art von Feedback oder Verbesserungsvorschlägen.%>

+

<%:admin6 Und nun wünschen wir viel Spaß mit dem Router!%>

+

<%:team Das LuCI-Team%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_network/index.htm b/modules/admin-core/luasrc/view/admin_network/index.htm new file mode 100644 index 000000000..7fa4f5565 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_network/index.htm @@ -0,0 +1,11 @@ +<%+header%> +

<%:network Netzwerk%>

+

<%:network1 In diesem Bereich finden sich alle netzwerkbezogenen Einstellungen.%>

+

<%:network2 Der Netzwerkswitch kann bei den meisten Routern frei konfiguriert +und in mehrere VLANs aufgeteilt werden. %>

+

<%:network3 Schnittstellen und PPPoE/PPTP-Einstellungen ermöglichen +die freie Organisation des Netzwerks und die Anbindung an ein WAN.%>

+

<%:network4 DHCP ermöglichst die automatische Netzwerkkonfiguration von Rechnern im (W)LAN.%>

+

<%:network5 Portweiterleitung und Firewall erlauben eine effektive Absicherung des Netzes, bei gleichzeitiger +Bereitstellung von externen Diensten.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_services/index.htm b/modules/admin-core/luasrc/view/admin_services/index.htm new file mode 100644 index 000000000..a06fe1056 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_services/index.htm @@ -0,0 +1,8 @@ +<%+header%> +

<%:services Dienste%>

+

<%:services1 Dienste und Dämonen stellen bestimmte Funktionalitäten auf dem Router zur Verfügung.%>

+

<%:services2 Es handelt sich hierbei meist um Netzwerkserver, die verschiedene Aufgaben auf dem Router erfüllen, +beispielsweise Shell-Zugang ermöglichen oder diese Weboberfläche per HTTP anbieten.%>

+

<%:servcies3 In diesen Bereich fallen auch die Meshnetzwerkdienste wie OLSR und BATMAN, die dabei helfen, +ein autarkes Ad-Hoc Netzwerk aufzubauen.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_status/index.htm b/modules/admin-core/luasrc/view/admin_status/index.htm new file mode 100644 index 000000000..984093693 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_status/index.htm @@ -0,0 +1,7 @@ +<%+header%> +

<%:status Status%>

+

<%:status1 Hier finden sich Informationen über den aktuellen Status des Systems, beispielsweise +Prozessortakt, Speicherauslastung und Netzwerkschnittstellen.%>

+

<%:status2 Zusätzlich können hier Protokolldaten, des Kernels und diverser Systemdienste eingesehen werden, +um deren Zustand zu kontrollieren.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_status/syslog.htm b/modules/admin-core/luasrc/view/admin_status/syslog.htm new file mode 100644 index 000000000..905161be2 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_status/syslog.htm @@ -0,0 +1,5 @@ +<%+header%> +

<%:status Status%>

+

<%:syslog Systemprotokoll%>

+<%=syslog%> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/editor.htm b/modules/admin-core/luasrc/view/admin_system/editor.htm new file mode 100644 index 000000000..ef3e0d8ab --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/editor.htm @@ -0,0 +1,14 @@ +<%+header%> +

<%:texteditor Texteditor%>

+ +
<%:file Datei%>: +<% if msg then %><%:error Fehler%>: <%=msg%><% end %>
+
+
+
+
+ + +
+ +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/index.htm b/modules/admin-core/luasrc/view/admin_system/index.htm new file mode 100644 index 000000000..3e9a28221 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/index.htm @@ -0,0 +1,9 @@ +<%+header%> +

<%:system System%>

+

<%:system1 Hier finden sich Einstellungen, die das System selbst, dessen Kennung, +installierte Software und Hardware, Authentifizierung oder eingehängte Speicher betreffen.%>

+

<%:system2 Diese Einstellungen definieren die Grundlage des Systems, auf dem die +installierte Software aufbaut.%>

+

<%:system3 Beachte bitte, dass eine fehlerhafte Konfiguration den Start +des Routers verhindern oder dich vom Zugriff auf diesen ausschließen kann.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/ipkg.htm b/modules/admin-core/luasrc/view/admin_system/ipkg.htm new file mode 100644 index 000000000..9a88ee57b --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/ipkg.htm @@ -0,0 +1,26 @@ +<%+header%> +

<%:system System%>

+

<%:ipkg IPKG-Konfiguration%>

+ +
+ +
<%:ipkg_pkglists Paketlisten%>:src Name URL
+
<%:ipkg_targets Installationsziele%>:dest Name Pfad
+ +
+ +
+
+
+
+ +
+
+
+
+ + +
+ <% if msg then %>
<%:error Fehler%>: <%=msg%>
<% end %> +
+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/packages.htm b/modules/admin-core/luasrc/view/admin_system/packages.htm new file mode 100644 index 000000000..52da37040 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/packages.htm @@ -0,0 +1,77 @@ +<%+header%> +

<%:system System%>

+

<%:packages Paketverwaltung%>

+ +
+ +<% if install or remove or update or upgrade then %> +
<%:status Status%>:
+<% if update then %> + <%:packages_update Paketlisten aktualisieren%>: <% if update == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=update%>)<% end %>
+<% end %> +<% if upgrade then%> + <%:packages_upgrade Installierte Pakete aktualisieren%>: <% if upgrade == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=upgrade%>)<% end %>
+<% end %> +<% if install then for k,v in pairs(install) do %> + <%:packages_install Installation von%> '<%=k%>': <% if v == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=v%>)<% end %>
+<% end end %> +<% if remove then for k,v in pairs(remove) do %> + <%:packages_remove Deinstallation von%> '<%=k%>': <% if v == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=v%>)<% end %>
+<% end end %> +
+
+<% end %> + + + +
+
+ +
+
+ <%:packages_installurl Paket herunterladen und installieren%>:
+ + +
+ +
+
+ +
+ <%:filter Filter%>: + + + +
+ +
+
+ +
+ + + + + + + + + <% for k, pkg in pairs(pkgs) do %> + + + + + + + + <% end %> +
<%:packages_name Paketname%><%:version Version%><%:install Installieren%><%:delete Löschen%><%:descr Beschreibung%>
<%=pkg.Package%><%=pkg.Version%><% if not pkg.Status or not pkg.Status.installed then %><% else %><%:installed installiert%><% end %><% if pkg.Status and pkg.Status.installed then %><% else %><%:notinstalled nicht installiert%><% end %><%=pkg.Description%>
+
+
+ +
+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/passwd.htm b/modules/admin-core/luasrc/view/admin_system/passwd.htm new file mode 100644 index 000000000..87b253368 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/passwd.htm @@ -0,0 +1,35 @@ +<%+header%> +

<%:system System%>

+

<%:passwd Passwort ändern%>

+

<%:passwd1 Ändert das Passwort des Systemverwalters (Benutzer "root")%>

+

+<% if stat then %> + <% if stat == 0 then %> + <%:password_changed Passwort erfolgreich geändert!%> + <% elseif stat == 10 then %> + <%:password_nomatch Passwörter stimmen nicht überein! %> + <% else %> + <%:unknown_error Unbekannter Fehler!%> + <% end %> +<% end %> +<% if not stat or stat == 10 then %> +
+
+
+
<%:password Passwort%>
+
+
+
+
<%:confirmation Bestätigung%>
+
+
+
+
+ + +
+
+
+<% end %> +
+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/reboot.htm b/modules/admin-core/luasrc/view/admin_system/reboot.htm new file mode 100644 index 000000000..e81be408c --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/reboot.htm @@ -0,0 +1,11 @@ +<%+header%> +

<%:system System%>

+

<%:reboot Neu starten%>

+

<%:reboot1 Startet das Betriebssystem des Routers neu.%>

+<% if not reboot then %> +

<%:reboot_do Neustart durchführen%>

+<% else %> +

<%:reboot_running Bitte warten: Neustart wird durchgeführt...%>

+ +<% end %> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/sshkeys.htm b/modules/admin-core/luasrc/view/admin_system/sshkeys.htm new file mode 100644 index 000000000..3765e1eea --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/sshkeys.htm @@ -0,0 +1,26 @@ +<%+header%> +

<%:system System%>

+

<%:sshkeys SSH-Schlüssel%>

+ +
+ +
<%:sshkeys_descr Hier können öffentliche SSH-Schlüssel (einer pro Zeile) + zur Authentifizierung abgelegt werden.%>
+ +
+ +
+
+
+
+ +
+
+
+
+ + +
+ <% if msg then %>
<%:error Fehler%>: <%=msg%>
<% end %> +
+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_system/upgrade.htm b/modules/admin-core/luasrc/view/admin_system/upgrade.htm new file mode 100644 index 000000000..185e03124 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_system/upgrade.htm @@ -0,0 +1,34 @@ +<%+header%> +

<%:system System%>

+

<%:upgrade Upgrade%>

+

<%:upgrade1 Ersetzt die installierte Firmware (das Betriebssystem des Routers) durch ein neues. +Das Format der Firmware ist plattformabhängig.%>

+
+<% if sysupgrade and not ret then %> +
+
+
+
<%:fwimage Firmwareimage%>
+
+
+
+
+ + <%:keepcfg Konfigurationsdateien übernehmen%> +
+
+
+ +
+
+
+<% elseif ret then %> + <% if ret == 0 then %> +
<%:flashed Flashvorgang erfolgreich. Router startet neu...%>
+ <% else %> +
<%:flasherr Flashvorgang fehlgeschlagen!%> (<%:code Code%> <%=ret%>)
+ <% end %> +<% else %> +
<%:notimplemented Diese Funktion steht leider (noch) nicht zur Verfügung.%>
+<% end %> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_uci/apply.htm b/modules/admin-core/luasrc/view/admin_uci/apply.htm new file mode 100644 index 000000000..090967a2d --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_uci/apply.htm @@ -0,0 +1,6 @@ +<%+header%> +

<%:config Konfiguration%>

+

<%:uci_applied Die folgenden Änderungen wurden übernommen%>:

+<%=(changes or "-")%> +<%=output%> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_uci/changes.htm b/modules/admin-core/luasrc/view/admin_uci/changes.htm new file mode 100644 index 000000000..43a48e3fc --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_uci/changes.htm @@ -0,0 +1,11 @@ +<%+header%> +

<%:config Konfiguration%>

+

<%:changes Änderungen%>

+<%=luci.model.uci.changes()%> +
+ +
+
+ +
+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_uci/revert.htm b/modules/admin-core/luasrc/view/admin_uci/revert.htm new file mode 100644 index 000000000..39aaabcd8 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_uci/revert.htm @@ -0,0 +1,5 @@ +<%+header%> +

<%:config Konfiguration%>

+

<%:uci_reverted Die folgenden Änderungen wurden verworfen%>:

+<%=(changes or "-")%> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/admin_wifi/index.htm b/modules/admin-core/luasrc/view/admin_wifi/index.htm new file mode 100644 index 000000000..6a6059835 --- /dev/null +++ b/modules/admin-core/luasrc/view/admin_wifi/index.htm @@ -0,0 +1,9 @@ +<%+header%> +

<%:wifi Drahtlos%>

+

<%:wifi1 Hier finden sich Konfiugrationsmöglichkeiten für Drahtlos-Netzwerke nach dem WLAN-Standard.%>

+

<%:wifi2 802.11b/g/a/n-Geräte können so einfach in das bestehende physische Netzwerk integriert werden. +Die Unterstützung von virtuellen Adaptern ermöglicht auch den Einsatz als Wireless-Repeater oder von +mehreren Netzwerken gleichzeitig auf einem Gerät.%>

+

<%:wifi3 Es werden Managed, Client, Ad-Hoc und WDS-Modus unterstützt sowie WPA und WPA2-Verschlüsselung zur gesicherten +Kommunikation.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/error404.htm b/modules/admin-core/luasrc/view/error404.htm new file mode 100644 index 000000000..60daee2cb --- /dev/null +++ b/modules/admin-core/luasrc/view/error404.htm @@ -0,0 +1,5 @@ +<%+header%> +

404 Not Found

+

Sorry, the object you requested was not found.

+Unable to dispatch: <%=luci.http.env.PATH_INFO%> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/error500.htm b/modules/admin-core/luasrc/view/error500.htm new file mode 100644 index 000000000..8af22e8f2 --- /dev/null +++ b/modules/admin-core/luasrc/view/error500.htm @@ -0,0 +1,5 @@ +<%+header%> +

500 Internal Server Error

+

Sorry, the server encountered an unexpected error.

+<%=message%> +<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/footer.htm b/modules/admin-core/luasrc/view/footer.htm new file mode 100644 index 000000000..c8506ac5c --- /dev/null +++ b/modules/admin-core/luasrc/view/footer.htm @@ -0,0 +1,7 @@ +
+
+
+ + + + \ No newline at end of file diff --git a/modules/admin-core/luasrc/view/header.htm b/modules/admin-core/luasrc/view/header.htm new file mode 100644 index 000000000..5f876781f --- /dev/null +++ b/modules/admin-core/luasrc/view/header.htm @@ -0,0 +1,137 @@ +<% +require("luci.sys") +local load1, load5, load15 = luci.sys.loadavg() + +local request = require("luci.dispatcher").request +local category = request[1] +local tree = luci.dispatcher.node() +local cattree = category and luci.dispatcher.node(category) +local node = luci.dispatcher.dispatched + +local c = tree +for i,r in ipairs(request) do + if c.nodes and c.nodes[r] then + c = c.nodes[r] + c._menu_selected = true + end +end + +require("luci.i18n").loadc("default") + +require("luci.http").prepare_content("text/html") +%> + + + + + <% if node and node.css then %><% end %> + + + LuCI - Lua Configuration Interface + + + + +
+<%:path Pfad%>: <% +local c = tree +local url = controller +for k,v in pairs(request) do + if c.nodes and c.nodes[v] then + c = c.nodes[v] + url = url .. "/" .. v + %><%=c.title or v%> <% if k ~= #request then %>» <% end + end +end +%> +
+ +
+ +<% end + end +end +%> +
+ +
\ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/index.lua b/modules/admin-core/src/controller/admin/index.lua deleted file mode 100644 index 11123c9c9..000000000 --- a/modules/admin-core/src/controller/admin/index.lua +++ /dev/null @@ -1,24 +0,0 @@ -module("luci.controller.admin.index", package.seeall) - -function index() - local root = node() - if not root.target then - root.target = alias("admin") - end - - local page = node("admin") - page.target = alias("admin", "index") - page.title = "Administration" - page.order = 10 - - local page = node("admin", "index") - page.target = template("admin_index/index") - page.title = "Übersicht" - page.order = 10 - - local page = node("admin", "index", "luci") - page.target = cbi("admin_index/luci") - page.title = "Oberfläche" - - -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/network.lua b/modules/admin-core/src/controller/admin/network.lua deleted file mode 100644 index 397f2e4ca..000000000 --- a/modules/admin-core/src/controller/admin/network.lua +++ /dev/null @@ -1,39 +0,0 @@ -module("luci.controller.admin.network", package.seeall) - -function index() - local page = node("admin", "network") - page.target = template("admin_network/index") - page.title = "Netzwerk" - page.order = 50 - - local page = node("admin", "network", "vlan") - page.target = cbi("admin_network/vlan") - page.title = "Switch" - page.order = 10 - - local page = node("admin", "network", "ifaces") - page.target = cbi("admin_network/ifaces") - page.title = "Schnittstellen" - page.order = 20 - - local page = node("admin", "network", "dhcp") - page.target = cbi("admin_network/dhcp") - page.title = "DHCP-Server" - page.order = 30 - - local page = node("admin", "network", "ptp") - page.target = cbi("admin_network/ptp") - page.title = "PPPoE / PPTP" - page.order = 40 - - local page = node("admin", "network", "routes") - page.target = cbi("admin_network/routes") - page.title = "Statische Routen" - page.order = 50 - - if luci.fs.isfile("/etc/config/qos") then - local page = node("admin", "network", "qos") - page.target = cbi("admin_network/qos") - page.title = "Quality of Service" - end -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/services.lua b/modules/admin-core/src/controller/admin/services.lua deleted file mode 100644 index 4dcf837c6..000000000 --- a/modules/admin-core/src/controller/admin/services.lua +++ /dev/null @@ -1,29 +0,0 @@ -module("luci.controller.admin.services", package.seeall) - -function index() - local page = node("admin", "services") - page.target = template("admin_services/index") - page.title = "Dienste" - page.order = 40 - - local page = node("admin", "services", "httpd") - page.target = cbi("admin_services/httpd") - page.title = "HTTP-Server" - page.order = 10 - - local page = node("admin", "services", "dropbear") - page.target = cbi("admin_services/dropbear") - page.title = "SSH-Server" - page.order = 20 - - local page = node("admin", "services", "dnsmasq") - page.target = cbi("admin_services/dnsmasq") - page.title = "Dnsmasq" - page.order = 30 - - if luci.fs.isfile("/etc/config/olsr") then - local page = node("admin", "services", "olsr") - page.target = cbi("admin_services/olsrd") - page.title = "OLSR" - end -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/status.lua b/modules/admin-core/src/controller/admin/status.lua deleted file mode 100644 index 34c210ca6..000000000 --- a/modules/admin-core/src/controller/admin/status.lua +++ /dev/null @@ -1,11 +0,0 @@ -module("luci.controller.admin.status", package.seeall) - -function index() - entry({"admin", "status"}, template("admin_status/index"), "Status", 20) - entry({"admin", "status", "syslog"}, action_syslog, "Systemprotokoll") -end - -function action_syslog() - local syslog = luci.sys.syslog() - luci.template.render("admin_status/syslog", {syslog=syslog}) -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/system.lua b/modules/admin-core/src/controller/admin/system.lua deleted file mode 100644 index e44e787fd..000000000 --- a/modules/admin-core/src/controller/admin/system.lua +++ /dev/null @@ -1,245 +0,0 @@ -module("luci.controller.admin.system", package.seeall) - -require("luci.sys") -require("luci.http") -require("luci.util") -require("luci.fs") -require("luci.model.ipkg") -require("luci.model.uci") - -function index() - local page = node("admin", "system") - page.target = template("admin_system/index") - page.title = "System" - page.order = 30 - - local page = node("admin", "system", "packages") - page.target = action_packages - page.title = "Paketverwaltung" - page.order = 10 - - local page = node("admin", "system", "packages", "ipkg") - page.target = action_ipkg - page.title = "IPKG-Konfiguration" - - local page = node("admin", "system", "passwd") - page.target = action_passwd - page.title = "Passwort ändern" - page.order = 20 - - local page = node("admin", "system", "sshkeys") - page.target = action_sshkeys - page.title = "SSH-Schlüssel" - page.order = 30 - - local page = node("admin", "system", "hostname") - page.target = cbi("admin_system/hostname") - page.title = "Hostname" - page.order = 40 - - local page = node("admin", "system", "fstab") - page.target = cbi("admin_system/fstab") - page.title = "Einhängepunkte" - page.order = 50 - - local page = node("admin", "system", "upgrade") - page.target = action_upgrade - page.title = "Firmwareupgrade" - page.order = 60 - - local page = node("admin", "system", "reboot") - page.target = action_reboot - page.title = "Neu starten" - page.order = 70 -end - -function action_editor() - local file = luci.http.formvalue("file", "") - local data = luci.http.formvalue("data") - local err = nil - local msg = nil - local stat = true - - if file and data then - stat, err = luci.fs.writefile(file, data) - end - - if not stat then - err = luci.util.split(err, " ") - table.remove(err, 1) - msg = table.concat(err, " ") - end - - local cnt, err = luci.fs.readfile(file) - if cnt then - cnt = luci.util.pcdata(cnt) - end - luci.template.render("admin_system/editor", {fn=file, cnt=cnt, msg=msg}) -end - -function action_ipkg() - local file = "/etc/ipkg.conf" - local data = luci.http.formvalue("data") - local stat = nil - local err = nil - - if data then - stat, err = luci.fs.writefile(file, data) - end - - local cnt = luci.fs.readfile(file) - if cnt then - cnt = luci.util.pcdata(cnt) - end - - luci.template.render("admin_system/ipkg", {cnt=cnt, msg=err}) -end - -function action_packages() - local ipkg = luci.model.ipkg - local void = nil - local submit = luci.http.formvalue("submit") - - - -- Search query - local query = luci.http.formvalue("query") - query = (query ~= '') and query or nil - - - -- Packets to be installed - local install = submit and luci.http.formvaluetable("install") - - -- Install from URL - local url = luci.http.formvalue("url") - if url and url ~= '' and submit then - if not install then - install = {} - end - install[url] = 1 - end - - -- Do install - if install then - for k, v in pairs(install) do - void, install[k] = ipkg.install(k) - end - end - - - -- Remove packets - local remove = submit and luci.http.formvaluetable("remove") - if remove then - for k, v in pairs(remove) do - void, remove[k] = ipkg.remove(k) - end - end - - - -- Update all packets - local update = luci.http.formvalue("update") - if update then - void, update = ipkg.update() - end - - - -- Upgrade all packets - local upgrade = luci.http.formvalue("upgrade") - if upgrade then - void, upgrade = ipkg.upgrade() - end - - - -- Package info - local info = luci.model.ipkg.info(query) - info = info or {} - local pkgs = {} - - -- Sort after status and name - for k, v in pairs(info) do - local x = 0 - for i, j in pairs(pkgs) do - local vins = (v.Status and v.Status.installed) - local jins = (j.Status and j.Status.installed) - if vins ~= jins then - if vins then - break - end - else - if j.Package > v.Package then - break - end - end - x = i - end - table.insert(pkgs, x+1, v) - end - - luci.template.render("admin_system/packages", {pkgs=pkgs, query=query, - install=install, remove=remove, update=update, upgrade=upgrade}) -end - -function action_passwd() - local p1 = luci.http.formvalue("pwd1") - local p2 = luci.http.formvalue("pwd2") - local stat = nil - - if p1 or p2 then - if p1 == p2 then - stat = luci.sys.user.setpasswd("root", p1) - else - stat = 10 - end - end - - luci.template.render("admin_system/passwd", {stat=stat}) -end - -function action_reboot() - local reboot = luci.http.formvalue("reboot") - luci.template.render("admin_system/reboot", {reboot=reboot}) - if reboot then - luci.sys.reboot() - end -end - -function action_sshkeys() - local file = "/etc/dropbear/authorized_keys" - local data = luci.http.formvalue("data") - local stat = nil - local err = nil - - if data then - stat, err = luci.fs.writefile(file, data) - end - - local cnt = luci.fs.readfile(file) - if cnt then - cnt = luci.util.pcdata(cnt) - end - - luci.template.render("admin_system/sshkeys", {cnt=cnt, msg=err}) -end - -function action_upgrade() - local ret = nil - local plat = luci.fs.mtime("/lib/upgrade/platform.sh") - - local image = luci.http.upload("image") - local keepcfg = luci.http.formvalue("keepcfg") - - if plat and image then - local kpattern = nil - if keepcfg then - local files = luci.model.uci.sections("luci").flash_keep - if files.luci and files.luci.flash_keep then - kpattern = "" - for k,v in pairs(files.luci.flash_keep) do - kpattern = kpattern .. " " .. v - end - end - end - ret = luci.sys.flash(image, kpattern) - end - - luci.template.render("admin_system/upgrade", {sysupgrade=plat, ret=ret}) -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/uci.lua b/modules/admin-core/src/controller/admin/uci.lua deleted file mode 100644 index ca1440bde..000000000 --- a/modules/admin-core/src/controller/admin/uci.lua +++ /dev/null @@ -1,67 +0,0 @@ -module("luci.controller.admin.uci", package.seeall) -require("luci.util") -require("luci.sys") - -function index() - node("admin", "uci", "changes").target = template("admin_uci/changes") - node("admin", "uci", "revert").target = action_revert - node("admin", "uci", "apply").target = action_apply -end - --- This function has a higher priority than the admin_uci/apply template -function action_apply() - local changes = luci.model.uci.changes() - local output = "" - - if changes then - local com = {} - local run = {} - - -- Collect files to be applied and commit changes - for i, line in ipairs(luci.util.split(changes)) do - local r = line:match("^-?([^.]+)") - if r then - com[r] = true - - if luci.config.uci_oncommit and luci.config.uci_oncommit[r] then - run[luci.config.uci_oncommit[r]] = true - end - end - end - - -- Apply - for config, i in pairs(com) do - luci.model.uci.commit(config) - end - - -- Search for post-commit commands - for cmd, i in pairs(run) do - output = output .. cmd .. ":" .. luci.sys.exec(cmd) .. "\n" - end - end - - luci.template.render("admin_uci/apply", {changes=changes, output=output}) -end - - -function action_revert() - local changes = luci.model.uci.changes() - if changes then - local revert = {} - - -- Collect files to be reverted - for i, line in ipairs(luci.util.split(changes)) do - local r = line:match("^-?([^.]+)") - if r then - revert[r] = true - end - end - - -- Revert them - for k, v in pairs(revert) do - luci.model.uci.revert(k) - end - end - - luci.template.render("admin_uci/revert", {changes=changes}) -end \ No newline at end of file diff --git a/modules/admin-core/src/controller/admin/wifi.lua b/modules/admin-core/src/controller/admin/wifi.lua deleted file mode 100644 index 0da6b7983..000000000 --- a/modules/admin-core/src/controller/admin/wifi.lua +++ /dev/null @@ -1,18 +0,0 @@ -module("luci.controller.admin.wifi", package.seeall) - -function index() - local page = node("admin", "wifi") - page.target = template("admin_wifi/index") - page.title = "Drahtlos" - page.order = 60 - - local page = node("admin", "wifi", "devices") - page.target = cbi("admin_wifi/devices") - page.title = "Geräte" - page.order = 10 - - local page = node("admin", "wifi", "networks") - page.target = cbi("admin_wifi/networks") - page.title = "Netze" - page.order = 20 -end \ No newline at end of file diff --git a/modules/admin-core/src/i18n/admin_index.en b/modules/admin-core/src/i18n/admin_index.en deleted file mode 100644 index 0831b59f0..000000000 --- a/modules/admin-core/src/i18n/admin_index.en +++ /dev/null @@ -1,20 +0,0 @@ -luci = "User Interface" - -hello = "Hello!" -admin1 = "This is the administration area of LuCI." -admin2 = "LuCI is a free, flexible, and user friendly graphical interface for configuring OpenWRT Kamikaze." -admin3 = "On the following pages you can adjust all important settings of your router." -admin4 = "You will find a navigation leading to the different configuration pages on the left side." -admin5 = [[As we are always want to improve this interface we are looking forward -to your feedback and suggestions.]] -admin6 = "And now have fun with your router!" -team = "The LuCI Team" - -luci1 = "Here you can customize the settings and the functionality of LuCI." -language = "Language" -general = "General" -ucicommit = "Post-commit actions" -ucicommit1 = [[These commands will be executed automatically when a given UCI configuration is committed allowing -changes to be applied instantly.]] -keepflash = "Files to be kept when flashing a new firmware" -keepflash1 = "When flashing a new firmware with LuCI these files will be added to the new firmware installation." \ No newline at end of file diff --git a/modules/admin-core/src/i18n/admin_uci.en b/modules/admin-core/src/i18n/admin_uci.en deleted file mode 100644 index 00ac5f5ff..000000000 --- a/modules/admin-core/src/i18n/admin_uci.en +++ /dev/null @@ -1,2 +0,0 @@ -uci_applied = "The following changes were applied" -uci_reverted = "The following changes were reverted" \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_index/luci.lua b/modules/admin-core/src/model/cbi/admin_index/luci.lua deleted file mode 100644 index bb6bc1820..000000000 --- a/modules/admin-core/src/model/cbi/admin_index/luci.lua +++ /dev/null @@ -1,33 +0,0 @@ --- ToDo: Translate -require("luci.config") -m = Map("luci", translate("luci", "Oberfläche"), translate("luci1", - "Hier können Eigenschaften und die Funktionalität der Oberfläche angepasst werden.")) - -c = m:section(NamedSection, "main", "core", translate("general", "Allgemein")) - -l = c:option(ListValue, "lang", translate("language", "Sprache")) -for k, v in pairs(luci.config.languages) do - if k:sub(1, 1) ~= "." then - l:value(k, v) - end -end - -t = c:option(ListValue, "mediaurlbase", translate("design", "Design")) -for k, v in pairs(luci.config.themes) do - if k:sub(1, 1) ~= "." then - t:value(v, k) - end -end - -u = m:section(NamedSection, "uci_oncommit", "event", translate("ucicommit", "UCI-Befehle beim Anwenden"), - translate("ucicommit1", [[Beim Anwenden -der Konfiguration aus der Oberflächliche heraus können automatisch die relevanten Dienste neugestart werden, -sodass Änderungen sofort nach dem Anwenden aktiv werden und der Router nicht erst neugestartet werden muss.]])) -u.dynamic = true - -f = m:section(NamedSection, "flash_keep", "extern", translate("keepflash", "Zu übernehmende Dateien bei Firmwareupgrade"), - translate("keepflash1", [[Die folgenden Dateien und Verzeichnisse werden beim Aktualisieren der Firmware -über die Oberfläche automatisch in die neue Firmware übernommen.]])) -f.dynamic = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/dhcp.lua b/modules/admin-core/src/model/cbi/admin_network/dhcp.lua deleted file mode 100644 index 63ef0aa3d..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/dhcp.lua +++ /dev/null @@ -1,41 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -require("luci.model.uci") -require("luci.sys") - -m = Map("dhcp", "DHCP", [[Mit Hilfe von DHCP können Netzteilnehmer automatisch -ihre Netzwerkkonfiguration (IP-Adresse, Netzmaske, DNS-Server, DHCP, ...) beziehen.]]) - -s = m:section(TypedSection, "dhcp") -s.addremove = true -s.anonymous = true - -iface = s:option(ListValue, "interface", "Schnittstelle") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - s:depends("interface", k) -- Only change sections with existing interfaces - end -end - -s:option(Value, "start", "Start", "Erste vergebene Adresse (letztes Oktett)").rmempty = true - -s:option(Value, "limit", "Limit", "Anzahl zu vergebender Adressen -1").rmempty = true - -s:option(Value, "leasetime", "Laufzeit").rmempty = true - -s:option(Flag, "dynamicdhcp", "Dynamisches DHCP").rmempty = true - -s:option(Value, "name", "Name").optional = true - -s:option(Flag, "ignore", "Schnittstelle ignorieren", "DHCP für dieses Netzwerk deaktivieren").optional = true - -s:option(Value, "netmask", "Netzmaske").optional = true - -s:option(Flag, "force", "Start erzwingen").optional = true - -for i, line in pairs(luci.sys.execl("dnsmasq --help dhcp")) do - k, v = line:match("([^ ]+) +([^ ]+)") - s:option(Value, "dhcp"..k, v).optional = true -end - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/ifaces.lua b/modules/admin-core/src/model/cbi/admin_network/ifaces.lua deleted file mode 100644 index 2dd190957..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/ifaces.lua +++ /dev/null @@ -1,43 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("network", "Schnittstellen", [[An dieser Stelle können die einzelnen Schnittstellen -des Netzwerkes konfiguriert werden. Es können mehrere Schnittstellen zu einer Brücke zusammengefasst werden, -indem diese durch Leerzeichen getrennt aufgezählt werden und ein entsprechender Haken im Feld Netzwerkbrücke -gesetzt wird. Es können VLANs in der Notation SCHNITTSTELLE.VLANNR (z.B.: eth0.1) verwendet werden.]]) - -s = m:section(TypedSection, "interface") -s.addremove = true -s:exclude("loopback") -s:depends("proto", "static") -s:depends("proto", "dhcp") - -p = s:option(ListValue, "proto", "Protokoll") -p:value("static", "statisch") -p:value("dhcp", "DHCP") -p.default = "static" - -br = s:option(Flag, "type", "Netzwerkbrücke", "überbrückt angegebene Schnittstelle(n)") -br.enabled = "bridge" -br.rmempty = true - -s:option(Value, "ifname", "Schnittstelle") - -s:option(Value, "ipaddr", "IP-Adresse") - -s:option(Value, "netmask", "Netzmaske"):depends("proto", "static") - -gw = s:option(Value, "gateway", "Gateway") -gw:depends("proto", "static") -gw.rmempty = true - -dns = s:option(Value, "dns", "DNS-Server") -dns:depends("proto", "static") -dns.optional = true - -mtu = s:option(Value, "mtu", "MTU") -mtu.optional = true -mtu.isinteger = true - -mac = s:option(Value, "macaddr", "MAC-Adresse") -mac.optional = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/ptp.lua b/modules/admin-core/src/model/cbi/admin_network/ptp.lua deleted file mode 100644 index 6a627f268..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/ptp.lua +++ /dev/null @@ -1,33 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("network", "Punkt-zu-Punkt Verbindungen", [[Punkt-zu-Punkt Verbindungen -über PPPoE oder PPTP werden häufig dazu verwendet, um über DSL o.ä. Techniken eine -Verbindung zum Internetgateway eines Internetzugangsanbieters aufzubauen.]]) - -s = m:section(TypedSection, "interface") -s.addremove = true -s:depends("proto", "pppoe") -s:depends("proto", "pptp") - -p = s:option(ListValue, "proto", "Protokoll") -p:value("pppoe", "PPPoE") -p:value("pptp", "PPTP") -p.default = "pppoe" - -s:option(Value, "ifname", "Schnittstelle") - -s:option(Value, "username", "Benutzername") -s:option(Value, "password", "Passwort") - -s:option(Value, "keepalive", "Keep-Alive", "Bei einer Verbindungstrennung automatisch neu verbinden").optional = true - -s:option(Value, "demand", "Dial on Demand (idle time)", "Zeit nach der die Verbindung bei Inaktivität getrennt wird").optional = true - -srv = s:option(Value, "server", "PPTP-Server") -srv:depends("proto", "pptp") -srv.optional = true - -mtu = s:option(Value, "mtu", "MTU") -mtu.optional = true -mtu.isinteger = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/qos.lua b/modules/admin-core/src/model/cbi/admin_network/qos.lua deleted file mode 100644 index d58130f10..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/qos.lua +++ /dev/null @@ -1,56 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("qos", "Quality of Service", [[Mit Hilfe von QoS kann einzelnen Rechnern oder Netzwerkdiensten -eine höhere oder niedrigere Priorität zugewiesen werden.]]) - -s = m:section(TypedSection, "interface", "Schnittstellen") -s.addremove = true - -s:option(Flag, "enabled", "aktiviert") - -c = s:option(ListValue, "classgroup", "Klassifizierung") -c:value("Default", "standard") -c.default = "Default" - -s:option(Flag, "overhead", "Overheadberechnung") - -s:option(Value, "download", "Downlink", "kb/s") - -s:option(Value, "upload", "Uplink", "kb/s") - -s = m:section(TypedSection, "classify", "Klassifizierung") - -s.anonymous = true -s.addremove = true - -t = s:option(ListValue, "target", "Klasse") -t:value("Priority") -t:value("Express") -t:value("Normal") -t:value("Bulk") -t.default = "Normal" - -s:option(Value, "srchost", "Quelladresse", "Quellhost / Quellnetz").optional = true -s:option(Value, "dsthost", "Zieladresse", "Zielhost / Zielnetz").optional = true -s:option(Value, "layer7", "Layer 7").optional = true - -p2p = s:option(ListValue, "ipp2p", "P2P") -p2p:value("") -p2p:value("all", "Alle") -p2p:value("bit", "Bittorrent") -p2p:value("dc", "DirectConnect") -p2p:value("edk", "eDonkey") -p2p:value("gnu", "Gnutella") -p2p:value("kazaa", "Kazaa") -p2p.optional = true - -p = s:option(ListValue, "proto", "Protokoll") -p:value("") -p:value("tcp", "TCP") -p:value("udp", "UDP") -p:value("icmp", "ICMP") -p.optional = true - -s:option(Value, "ports", "Port").optional = true -s:option(Value, "portrange", "Portbereich").optional = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/routes.lua b/modules/admin-core/src/model/cbi/admin_network/routes.lua deleted file mode 100644 index a2a27eb26..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/routes.lua +++ /dev/null @@ -1,24 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("network", "Statische Routen", [[Statische Routen geben an, -über welche Schnittstelle und welches Gateway ein bestimmter Host -oder ein bestimmtes Netzwerk erreicht werden kann.]]) - -s = m:section(TypedSection, "route") -s.addremove = true -s.anonymous = true -s.template = "cbi/tblsection" - -iface = s:option(ListValue, "interface", "Schnittstelle") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - iface:value(k) - end -end - -s:option(Value, "target", "Ziel", "Host-IP oder Netzwerk") - -s:option(Value, "netmask", "Netzmaske", "falls Ziel ein Netzwerk ist").rmemepty = true - -s:option(Value, "gateway", "Gateway") - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_network/vlan.lua b/modules/admin-core/src/model/cbi/admin_network/vlan.lua deleted file mode 100644 index 7b493643b..000000000 --- a/modules/admin-core/src/model/cbi/admin_network/vlan.lua +++ /dev/null @@ -1,17 +0,0 @@ --- ToDo: Autodetect things, maybe use MultiValue instead, Translate, Add descriptions -m = Map("network", "VLAN", [[Die Netzwerkschnittstellen am Router -können zu verschienden VLANs zusammengefasst werden, in denen Geräte miteinander direkt -kommunizieren können. VLANs werden auch häufig dazu genutzt, um Netzwerke voneiander zu trennen. -So ist oftmals eine Schnittstelle als Uplink zu einem größerem Netz, wie dem Internet vorkonfiguriert -und die anderen Schnittstellen bilden ein VLAN für das lokale Netzwerk.]]) - -s = m:section(TypedSection, "switch", nil, [[Die zu einem VLAN gehörenden Schnittstellen -werden durch Leerzeichen getrennt. Die Schnittstelle mit der höchsten Nummer (meistens 5) bildet -in der Regel die Verbindung zur internen Netzschnittstelle des Routers. Bei Geräten mit 5 Schnittstellen -ist in der Regel die Schnittstelle mit der niedrigsten Nummer (0) die standardmäßige Uplinkschnittstelle des Routers.]]) - -for i = 0, 15 do - s:option(Value, "vlan"..i, "vlan"..i).optional = true -end - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_services/dnsmasq.lua b/modules/admin-core/src/model/cbi/admin_services/dnsmasq.lua deleted file mode 100644 index 86716ff9f..000000000 --- a/modules/admin-core/src/model/cbi/admin_services/dnsmasq.lua +++ /dev/null @@ -1,29 +0,0 @@ -m = Map("dhcp", "Dnsmasq", "Dnsmasq ist ein kombinierter DHCP-Server und DNS-Forwarder für NAT-Firewalls.") - -s = m:section(TypedSection, "dnsmasq", "Einstellungen") -s.anonymous = true - -s:option(Flag, "domainneeded", "Anfragen nur mit Domain", "Anfragen ohne Domainnamen nicht weiterleiten") -s:option(Flag, "authoritative", "Authoritativ", "Dies ist der einzige DHCP im lokalen Netz") -s:option(Flag, "boguspriv", "Private Anfragen filtern", "Reverse DNS-Anfragen für lokalen Netze nicht weiterleiten") -s:option(Flag, "filterwin2k", "Windowsanfragen filtern", "nutzlose DNS-Anfragen aktueller Windowssysteme filtern") -s:option(Flag, "localise_queries", "Lokalisiere Anfragen", "Gibt die Adresse eines Hostnamen entsprechend seines Subnetzes zurück") -s:option(Value, "local", "Lokale Server") -s:option(Value, "domain", "Lokale Domain") -s:option(Flag, "expandhosts", "Erweitere Hosts", "Fügt Domainnamen zu einfachen Hosteinträgen in der Resolvdatei hinzu") -s:option(Flag, "nonegcache", "Unbekannte nicht cachen", "Negative DNS-Antworten nicht zwischenspeichern") -s:option(Flag, "readethers", "Verwende /etc/ethers", "Lese Informationen aus /etc/ethers um den DHCP-Server zu konfigurieren") -s:option(Value, "leasefile", "Leasedatei", "Speicherort für vergebenen DHCP-Adressen") -s:option(Value, "resolvfile", "Resolvdatei", "Lokale DNS-Datei") -s:option(Flag, "nohosts", "Ignoriere /etc/hosts").optional = true -s:option(Flag, "strictorder", "Strikte Reihenfolge", "DNS-Server werden strikt der Reihenfolge in der Resolvdatei nach abgefragt").optional = true -s:option(Flag, "logqueries", "Schreibe Abfragelog").optional = true -s:option(Flag, "noresolv", "Ignoriere Resolvdatei").optional = true -s:option(Value, "dnsforwardmax", "gleichzeitige Abfragen").optional = true -s:option(Value, "port", "DNS-Port").optional = true -s:option(Value, "ednspacket_max", "max. EDNS.0 Paketgröße").optional = true -s:option(Value, "dhcpleasemax", "max. DHCP-Leases").optional = true -s:option(Value, "addnhosts", "Zusätzliche Hostdatei").optional = true -s:option(Value, "queryport", "Abfrageport").optional = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_services/dropbear.lua b/modules/admin-core/src/model/cbi/admin_services/dropbear.lua deleted file mode 100644 index 3ecf95335..000000000 --- a/modules/admin-core/src/model/cbi/admin_services/dropbear.lua +++ /dev/null @@ -1,15 +0,0 @@ --- ToDo: Translate, Add descriptions -m = Map("dropbear", "SSH-Server", [[Der SSH-Server ermöglicht Shell-Zugriff -über das Netzwerk und bietet einen integrierten SCP-Dienst.]]) - -s = m:section(TypedSection, "dropbear") -s.anonymous = true - -port = s:option(Value, "Port", "Port") -port.isinteger = true - -pwauth = s:option(Flag, "PasswordAuth", "Passwortanmeldung", "Erlaube Anmeldung per Passwort") -pwauth.enabled = 'on' -pwauth.disabled = 'off' - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_services/httpd.lua b/modules/admin-core/src/model/cbi/admin_services/httpd.lua deleted file mode 100644 index 3bd49a2d7..000000000 --- a/modules/admin-core/src/model/cbi/admin_services/httpd.lua +++ /dev/null @@ -1,18 +0,0 @@ --- ToDo: Translate, Add descriptions -m = Map("httpd", "HTTP-Server", "Der HTTP-Server ist u.a. für die Bereitstellung dieser Obefläche zuständig.") - -s = m:section(TypedSection, "httpd") -s.anonymous = true - -port = s:option(Value, "port", "Port") -port.isinteger = true - -s:option(Value, "home", "Wurzelverzeichnis") - -config = s:option(Value, "c_file", "Konfigurationsdatei", "/etc/httpd.conf wenn leer") -config.rmempty = true - -realm = s:option(Value, "realm", "Anmeldeaufforderung", "Aufforderungstext zum Anmelden im Administrationsbereich") -realm.rmempty = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_services/olsrd.lua b/modules/admin-core/src/model/cbi/admin_services/olsrd.lua deleted file mode 100644 index a1a197808..000000000 --- a/modules/admin-core/src/model/cbi/admin_services/olsrd.lua +++ /dev/null @@ -1,89 +0,0 @@ --- ToDo: Autodetect things, Translate, Add descriptions -require("luci.fs") - -m = Map("olsr", "OLSR", [[OLSR ist ein flexibles Routingprotokoll, -dass den Aufbau von mobilen Ad-Hoc Netzen unterstützt.]]) - -s = m:section(NamedSection, "general", "olsr", "Allgemeine Einstellungen") - -debug = s:option(ListValue, "DebugLevel", "Debugmodus") -for i=0, 9 do - debug:value(i) -end - -ipv = s:option(ListValue, "IpVersion", "Internet Protokoll") -ipv:value("4", "IPv4") -ipv:value("6", "IPv6") - -noint = s:option(Flag, "AllowNoInt", "Start ohne Netzwerk") -noint.enabled = "yes" -noint.disabled = "no" - -s:option(Value, "Pollrate", "Abfragerate (Pollrate)", "s") - -tcr = s:option(ListValue, "TcRedundancy", "TC-Redundanz") -tcr:value("0", "MPR-Selektoren") -tcr:value("1", "MPR-Selektoren und MPR") -tcr:value("2", "Alle Nachbarn") - -s:option(Value, "MprCoverage", "MPR-Erfassung") - -lql = s:option(ListValue, "LinkQualityLevel", "VQ-Level") -lql:value("0", "deaktiviert") -lql:value("1", "MPR-Auswahl") -lql:value("2", "MPR-Auswahl und Routing") - -lqfish = s:option(Flag, "LinkQualityFishEye", "VQ-Fisheye") - -s:option(Value, "LinkQualityWinSize", "VQ-Fenstergröße") - -s:option(Value, "LinkQualityDijkstraLimit", "VQ-Dijkstralimit") - -hyst = s:option(Flag, "UseHysteresis", "Hysterese aktivieren") -hyst.enabled = "yes" -hyst.disabled = "no" - - -i = m:section(TypedSection, "Interface", "Schnittstellen") -i.anonymous = true -i.addremove = true -i.dynamic = true - -network = i:option(ListValue, "Interface", "Netzwerkschnittstellen") -network:value("") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - network:value(k) - end -end - -i:option(Value, "HelloInterval", "Hello-Intervall") - -i:option(Value, "HelloValidityTime", "Hello-Gültigkeit") - -i:option(Value, "TcInterval", "TC-Intervall") - -i:option(Value, "TcValidityTime", "TC-Gültigkeit") - -i:option(Value, "MidInterval", "MID-Intervall") - -i:option(Value, "MidValidityTime", "MID-Gültigkeit") - -i:option(Value, "HnaInterval", "HNA-Intervall") - -i:option(Value, "HnaValidityTime", "HNA-Gültigkeit") - - -p = m:section(TypedSection, "LoadPlugin", "Plugins") -p.addremove = true -p.dynamic = true - -lib = p:option(ListValue, "Library", "Bibliothek") -lib:value("") -for k, v in pairs(luci.fs.dir("/usr/lib")) do - if v:sub(1, 6) == "olsrd_" then - lib:value(v) - end -end - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_system/fstab.lua b/modules/admin-core/src/model/cbi/admin_system/fstab.lua deleted file mode 100644 index d705743a0..000000000 --- a/modules/admin-core/src/model/cbi/admin_system/fstab.lua +++ /dev/null @@ -1,25 +0,0 @@ -m = Map("fstab", "Einhängepunkte") - -mount = m:section(TypedSection, "mount", "Einhängepunkte", [[Einhängepunkte bestimmen, an welcher Stelle des Dateisystems -bestimmte Laufwerke und Speicher zur Verwendung eingebunden werden.]]) -mount.anonymous = true -mount.addremove = true - -mount:option(Flag, "enabled", "aktivieren") -mount:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)") -mount:option(Value, "target", "Einhängepunkt", "Die Stelle an der der Speicher in das Dateisystem eingehängt wird.") -mount:option(Value, "fstype", "Dateisystem", "Das Dateisystem mit dem der Speicher formatiert ist (z.B.: ext3)") -mount:option(Value, "options", "Optionen", "Weitere Optionen (siehe das Handbuch des Befehls 'mount')") - - -swap = m:section(TypedSection, "swap", "SWAP", [[Falls der Arbeitsspeicher des Routers nicht ausreicht, -kann dieser nicht benutzte Daten zeitweise auf einem SWAP-Laufwerk auslagern um so die -effektive Größe des Arbeitsspeichers zu erhöhen. Die Auslagerung der Daten ist natürlich bedeutend langsamer -als direkte Arbeitsspeicherzugriffe.]]) -swap.anonymous = true -swap.addremove = true - -swap:option(Flag, "enabled", "aktivieren") -swap:option(Value, "device", "Gerät", "Die Gerätedatei des Speichers oder der Partition (z.B.: /dev/sda)") - -return m diff --git a/modules/admin-core/src/model/cbi/admin_system/hostname.lua b/modules/admin-core/src/model/cbi/admin_system/hostname.lua deleted file mode 100644 index c9e159d05..000000000 --- a/modules/admin-core/src/model/cbi/admin_system/hostname.lua +++ /dev/null @@ -1,9 +0,0 @@ -m = Map("system", "Hostname", [[Definiert den Hostnamen des Routers. -Der Hostname ist eine im Netzwerk eindeutige Kennung, die dieses Gerät identifiziert.]]) - -s = m:section(TypedSection, "system") -s.anonymous = true - -s:option(Value, "hostname", "Hostname") - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_wifi/devices.lua b/modules/admin-core/src/model/cbi/admin_wifi/devices.lua deleted file mode 100644 index 2931a6e55..000000000 --- a/modules/admin-core/src/model/cbi/admin_wifi/devices.lua +++ /dev/null @@ -1,52 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts - -m = Map("wireless", "Geräte", [[An dieser Stelle können eingebaute WLAN-Geräte konfiguriert werden.]]) - -s = m:section(TypedSection, "wifi-device") ---s.addremove = true - -en = s:option(Flag, "disabled", "Aktivieren") -en.enabled = "0" -en.disabled = "1" - -t = s:option(ListValue, "type", "Typ") -t:value("broadcom") -t:value("atheros") -t:value("mac80211") -t:value("prism2") ---[[ -require("luci.sys") -local c = ". /etc/functions.sh;for i in /lib/wifi/*;do . $i;done;echo $DRIVERS" -for driver in luci.sys.execl(c)[1]:gmatch("[^ ]+") do - t:value(driver) -end -]]-- - -mode = s:option(ListValue, "mode", "Modus") -mode:value("", "standard") -mode:value("11b", "802.11b") -mode:value("11g", "802.11g") -mode:value("11a", "802.11a") -mode:value("11bg", "802.11b+g") -mode.rmempty = true - -s:option(Value, "channel", "Funkkanal") - -s:option(Value, "txantenna", "Sendeantenne").rmempty = true - -s:option(Value, "rxantenna", "Empfangsantenne").rmempty = true - -s:option(Value, "distance", "Distanz", - "Distanz zum am weitesten entfernten Funkpartner (m)").rmempty = true - -s:option(Value, "diversity", "Diversität"):depends("type", "atheros") - -country = s:option(Value, "country", "Ländercode") -country.optional = true -country:depends("type", "broadcom") - -maxassoc = s:option(Value, "maxassoc", "Verbindungslimit") -maxassoc:depends("type", "broadcom") -maxassoc.optional = true - -return m \ No newline at end of file diff --git a/modules/admin-core/src/model/cbi/admin_wifi/networks.lua b/modules/admin-core/src/model/cbi/admin_wifi/networks.lua deleted file mode 100644 index a5be6f502..000000000 --- a/modules/admin-core/src/model/cbi/admin_wifi/networks.lua +++ /dev/null @@ -1,77 +0,0 @@ --- ToDo: Translate, Add descriptions and help texts -m = Map("wireless", "Netze", [[Pro WLAN-Gerät können mehrere Netze bereitgestellt werden. -Es sollte beachtet werden, dass es hardware- / treiberspezifische Einschränkungen gibt. -So kann pro WLAN-Gerät in der Regel entweder 1 Ad-Hoc-Zugang ODER bis zu 3 Access-Point und 1 Client-Zugang -gleichzeitig erstellt werden.]]) - -s = m:section(TypedSection, "wifi-iface") -s.addremove = true -s.anonymous = true - -s:option(Value, "ssid", "Netzkennung (ESSID)").maxlength = 32 - -device = s:option(ListValue, "device", "Gerät") -local d = luci.model.uci.sections("wireless") -if d then - for k, v in pairs(d) do - if v[".type"] == "wifi-device" then - device:value(k) - end - end -end - -network = s:option(ListValue, "network", "Netzwerk", "WLAN-Netz zu Netzwerk hinzufügen") -network:value("") -for k, v in pairs(luci.model.uci.sections("network")) do - if v[".type"] == "interface" and k ~= "loopback" then - network:value(k) - end -end - -mode = s:option(ListValue, "mode", "Modus") -mode:value("ap", "Access Point") -mode:value("adhoc", "Ad-Hoc") -mode:value("sta", "Client") -mode:value("wds", "WDS") - -s:option(Value, "bssid", "BSSID").optional = true - -s:option(Value, "txpower", "Sendeleistung", "dbm").rmempty = true - -s:option(Flag, "frameburst", "Broadcom-Frameburst").optional = true -s:option(Flag, "bursting", "Atheros-Frameburst").optional = true - - -encr = s:option(ListValue, "encryption", "Verschlüsselung") -encr:value("none", "keine") -encr:value("wep", "WEP") -encr:value("psk", "WPA-PSK") -encr:value("wpa", "WPA-Radius") -encr:value("psk2", "WPA2-PSK") -encr:value("wpa2", "WPA2-Radius") - -key = s:option(Value, "key", "Schlüssel") -key:depends("encryption", "wep") -key:depends("encryption", "psk") -key:depends("encryption", "wpa") -key:depends("encryption", "psk2") -key:depends("encryption", "wpa2") -key.rmempty = true - -server = s:option(Value, "server", "Radius-Server") -server:depends("encryption", "wpa") -server:depends("encryption", "wpa2") -server.rmempty = true - -port = s:option(Value, "port", "Radius-Port") -port:depends("encryption", "wpa") -port:depends("encryption", "wpa2") -port.rmempty = true - -s:option(Flag, "isolate", "AP-Isolation", "Unterbindet Client-Client-Verkehr").optional = true - -s:option(Flag, "hidden", "ESSID verstecken").optional = true - - - -return m \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_index/index.htm b/modules/admin-core/src/view/admin_index/index.htm deleted file mode 100644 index 2e5c7c374..000000000 --- a/modules/admin-core/src/view/admin_index/index.htm +++ /dev/null @@ -1,11 +0,0 @@ -<%+header%> -

<%:hello Hallo!%>

-

<%:admin1 Dies ist der Administrationsbereich von LuCI.%>

-

<%:admin2 LuCI ist eine freie, flexible und benutzerfreundliche grafische Oberfläche zur Konfiguration von OpenWRT Kamikaze.%>
-<%:admin3 Auf den folgenden Seiten können alle wichtigen Einstellungen des Routers vorgenommen werden.%>

-

<%:admin4 Auf der linken Seite befindet sich eine Navigation, die zu den einzelnen Konfigurationsseiten führt.%>

-

<%:admin5 Wir sind natürlich stets darum bemüht, diese Oberfläche -noch besser und intuitiver zu Gestalten und freuen uns über jegliche Art von Feedback oder Verbesserungsvorschlägen.%>

-

<%:admin6 Und nun wünschen wir viel Spaß mit dem Router!%>

-

<%:team Das LuCI-Team%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_network/index.htm b/modules/admin-core/src/view/admin_network/index.htm deleted file mode 100644 index 7fa4f5565..000000000 --- a/modules/admin-core/src/view/admin_network/index.htm +++ /dev/null @@ -1,11 +0,0 @@ -<%+header%> -

<%:network Netzwerk%>

-

<%:network1 In diesem Bereich finden sich alle netzwerkbezogenen Einstellungen.%>

-

<%:network2 Der Netzwerkswitch kann bei den meisten Routern frei konfiguriert -und in mehrere VLANs aufgeteilt werden. %>

-

<%:network3 Schnittstellen und PPPoE/PPTP-Einstellungen ermöglichen -die freie Organisation des Netzwerks und die Anbindung an ein WAN.%>

-

<%:network4 DHCP ermöglichst die automatische Netzwerkkonfiguration von Rechnern im (W)LAN.%>

-

<%:network5 Portweiterleitung und Firewall erlauben eine effektive Absicherung des Netzes, bei gleichzeitiger -Bereitstellung von externen Diensten.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_services/index.htm b/modules/admin-core/src/view/admin_services/index.htm deleted file mode 100644 index a06fe1056..000000000 --- a/modules/admin-core/src/view/admin_services/index.htm +++ /dev/null @@ -1,8 +0,0 @@ -<%+header%> -

<%:services Dienste%>

-

<%:services1 Dienste und Dämonen stellen bestimmte Funktionalitäten auf dem Router zur Verfügung.%>

-

<%:services2 Es handelt sich hierbei meist um Netzwerkserver, die verschiedene Aufgaben auf dem Router erfüllen, -beispielsweise Shell-Zugang ermöglichen oder diese Weboberfläche per HTTP anbieten.%>

-

<%:servcies3 In diesen Bereich fallen auch die Meshnetzwerkdienste wie OLSR und BATMAN, die dabei helfen, -ein autarkes Ad-Hoc Netzwerk aufzubauen.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_status/index.htm b/modules/admin-core/src/view/admin_status/index.htm deleted file mode 100644 index 984093693..000000000 --- a/modules/admin-core/src/view/admin_status/index.htm +++ /dev/null @@ -1,7 +0,0 @@ -<%+header%> -

<%:status Status%>

-

<%:status1 Hier finden sich Informationen über den aktuellen Status des Systems, beispielsweise -Prozessortakt, Speicherauslastung und Netzwerkschnittstellen.%>

-

<%:status2 Zusätzlich können hier Protokolldaten, des Kernels und diverser Systemdienste eingesehen werden, -um deren Zustand zu kontrollieren.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_status/syslog.htm b/modules/admin-core/src/view/admin_status/syslog.htm deleted file mode 100644 index 905161be2..000000000 --- a/modules/admin-core/src/view/admin_status/syslog.htm +++ /dev/null @@ -1,5 +0,0 @@ -<%+header%> -

<%:status Status%>

-

<%:syslog Systemprotokoll%>

-<%=syslog%> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/editor.htm b/modules/admin-core/src/view/admin_system/editor.htm deleted file mode 100644 index ef3e0d8ab..000000000 --- a/modules/admin-core/src/view/admin_system/editor.htm +++ /dev/null @@ -1,14 +0,0 @@ -<%+header%> -

<%:texteditor Texteditor%>

-
-
<%:file Datei%>: -<% if msg then %><%:error Fehler%>: <%=msg%><% end %>
-
-
-
-
- - -
-
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/index.htm b/modules/admin-core/src/view/admin_system/index.htm deleted file mode 100644 index 3e9a28221..000000000 --- a/modules/admin-core/src/view/admin_system/index.htm +++ /dev/null @@ -1,9 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:system1 Hier finden sich Einstellungen, die das System selbst, dessen Kennung, -installierte Software und Hardware, Authentifizierung oder eingehängte Speicher betreffen.%>

-

<%:system2 Diese Einstellungen definieren die Grundlage des Systems, auf dem die -installierte Software aufbaut.%>

-

<%:system3 Beachte bitte, dass eine fehlerhafte Konfiguration den Start -des Routers verhindern oder dich vom Zugriff auf diesen ausschließen kann.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/ipkg.htm b/modules/admin-core/src/view/admin_system/ipkg.htm deleted file mode 100644 index 9a88ee57b..000000000 --- a/modules/admin-core/src/view/admin_system/ipkg.htm +++ /dev/null @@ -1,26 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:ipkg IPKG-Konfiguration%>

- -
- -
<%:ipkg_pkglists Paketlisten%>:src Name URL
-
<%:ipkg_targets Installationsziele%>:dest Name Pfad
- -
- -
-
-
-
- -
-
-
-
- - -
- <% if msg then %>
<%:error Fehler%>: <%=msg%>
<% end %> -
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/packages.htm b/modules/admin-core/src/view/admin_system/packages.htm deleted file mode 100644 index 52da37040..000000000 --- a/modules/admin-core/src/view/admin_system/packages.htm +++ /dev/null @@ -1,77 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:packages Paketverwaltung%>

- -
- -<% if install or remove or update or upgrade then %> -
<%:status Status%>:
-<% if update then %> - <%:packages_update Paketlisten aktualisieren%>: <% if update == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=update%>)<% end %>
-<% end %> -<% if upgrade then%> - <%:packages_upgrade Installierte Pakete aktualisieren%>: <% if upgrade == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=upgrade%>)<% end %>
-<% end %> -<% if install then for k,v in pairs(install) do %> - <%:packages_install Installation von%> '<%=k%>': <% if v == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=v%>)<% end %>
-<% end end %> -<% if remove then for k,v in pairs(remove) do %> - <%:packages_remove Deinstallation von%> '<%=k%>': <% if v == 0 then %><%:ok OK%><% else %><%:error Fehler%> (<%:code Code%> <%=v%>)<% end %>
-<% end end %> -
-
-<% end %> - - - -
-
- -
-
- <%:packages_installurl Paket herunterladen und installieren%>:
- - -
- -
-
- -
- <%:filter Filter%>: - - - -
- -
-
- -
- - - - - - - - - <% for k, pkg in pairs(pkgs) do %> - - - - - - - - <% end %> -
<%:packages_name Paketname%><%:version Version%><%:install Installieren%><%:delete Löschen%><%:descr Beschreibung%>
<%=pkg.Package%><%=pkg.Version%><% if not pkg.Status or not pkg.Status.installed then %><% else %><%:installed installiert%><% end %><% if pkg.Status and pkg.Status.installed then %><% else %><%:notinstalled nicht installiert%><% end %><%=pkg.Description%>
-
-
- -
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/passwd.htm b/modules/admin-core/src/view/admin_system/passwd.htm deleted file mode 100644 index 87b253368..000000000 --- a/modules/admin-core/src/view/admin_system/passwd.htm +++ /dev/null @@ -1,35 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:passwd Passwort ändern%>

-

<%:passwd1 Ändert das Passwort des Systemverwalters (Benutzer "root")%>

-

-<% if stat then %> - <% if stat == 0 then %> - <%:password_changed Passwort erfolgreich geändert!%> - <% elseif stat == 10 then %> - <%:password_nomatch Passwörter stimmen nicht überein! %> - <% else %> - <%:unknown_error Unbekannter Fehler!%> - <% end %> -<% end %> -<% if not stat or stat == 10 then %> -
-
-
-
<%:password Passwort%>
-
-
-
-
<%:confirmation Bestätigung%>
-
-
-
-
- - -
-
-
-<% end %> -
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/reboot.htm b/modules/admin-core/src/view/admin_system/reboot.htm deleted file mode 100644 index e81be408c..000000000 --- a/modules/admin-core/src/view/admin_system/reboot.htm +++ /dev/null @@ -1,11 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:reboot Neu starten%>

-

<%:reboot1 Startet das Betriebssystem des Routers neu.%>

-<% if not reboot then %> -

<%:reboot_do Neustart durchführen%>

-<% else %> -

<%:reboot_running Bitte warten: Neustart wird durchgeführt...%>

- -<% end %> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/sshkeys.htm b/modules/admin-core/src/view/admin_system/sshkeys.htm deleted file mode 100644 index 3765e1eea..000000000 --- a/modules/admin-core/src/view/admin_system/sshkeys.htm +++ /dev/null @@ -1,26 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:sshkeys SSH-Schlüssel%>

- -
- -
<%:sshkeys_descr Hier können öffentliche SSH-Schlüssel (einer pro Zeile) - zur Authentifizierung abgelegt werden.%>
- -
- -
-
-
-
- -
-
-
-
- - -
- <% if msg then %>
<%:error Fehler%>: <%=msg%>
<% end %> -
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_system/upgrade.htm b/modules/admin-core/src/view/admin_system/upgrade.htm deleted file mode 100644 index 185e03124..000000000 --- a/modules/admin-core/src/view/admin_system/upgrade.htm +++ /dev/null @@ -1,34 +0,0 @@ -<%+header%> -

<%:system System%>

-

<%:upgrade Upgrade%>

-

<%:upgrade1 Ersetzt die installierte Firmware (das Betriebssystem des Routers) durch ein neues. -Das Format der Firmware ist plattformabhängig.%>

-
-<% if sysupgrade and not ret then %> -
-
-
-
<%:fwimage Firmwareimage%>
-
-
-
-
- - <%:keepcfg Konfigurationsdateien übernehmen%> -
-
-
- -
-
-
-<% elseif ret then %> - <% if ret == 0 then %> -
<%:flashed Flashvorgang erfolgreich. Router startet neu...%>
- <% else %> -
<%:flasherr Flashvorgang fehlgeschlagen!%> (<%:code Code%> <%=ret%>)
- <% end %> -<% else %> -
<%:notimplemented Diese Funktion steht leider (noch) nicht zur Verfügung.%>
-<% end %> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_uci/apply.htm b/modules/admin-core/src/view/admin_uci/apply.htm deleted file mode 100644 index 090967a2d..000000000 --- a/modules/admin-core/src/view/admin_uci/apply.htm +++ /dev/null @@ -1,6 +0,0 @@ -<%+header%> -

<%:config Konfiguration%>

-

<%:uci_applied Die folgenden Änderungen wurden übernommen%>:

-<%=(changes or "-")%> -<%=output%> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_uci/changes.htm b/modules/admin-core/src/view/admin_uci/changes.htm deleted file mode 100644 index 43a48e3fc..000000000 --- a/modules/admin-core/src/view/admin_uci/changes.htm +++ /dev/null @@ -1,11 +0,0 @@ -<%+header%> -

<%:config Konfiguration%>

-

<%:changes Änderungen%>

-<%=luci.model.uci.changes()%> -
- -
-
- -
-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_uci/revert.htm b/modules/admin-core/src/view/admin_uci/revert.htm deleted file mode 100644 index 39aaabcd8..000000000 --- a/modules/admin-core/src/view/admin_uci/revert.htm +++ /dev/null @@ -1,5 +0,0 @@ -<%+header%> -

<%:config Konfiguration%>

-

<%:uci_reverted Die folgenden Änderungen wurden verworfen%>:

-<%=(changes or "-")%> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/admin_wifi/index.htm b/modules/admin-core/src/view/admin_wifi/index.htm deleted file mode 100644 index 6a6059835..000000000 --- a/modules/admin-core/src/view/admin_wifi/index.htm +++ /dev/null @@ -1,9 +0,0 @@ -<%+header%> -

<%:wifi Drahtlos%>

-

<%:wifi1 Hier finden sich Konfiugrationsmöglichkeiten für Drahtlos-Netzwerke nach dem WLAN-Standard.%>

-

<%:wifi2 802.11b/g/a/n-Geräte können so einfach in das bestehende physische Netzwerk integriert werden. -Die Unterstützung von virtuellen Adaptern ermöglicht auch den Einsatz als Wireless-Repeater oder von -mehreren Netzwerken gleichzeitig auf einem Gerät.%>

-

<%:wifi3 Es werden Managed, Client, Ad-Hoc und WDS-Modus unterstützt sowie WPA und WPA2-Verschlüsselung zur gesicherten -Kommunikation.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/error404.htm b/modules/admin-core/src/view/error404.htm deleted file mode 100644 index 60daee2cb..000000000 --- a/modules/admin-core/src/view/error404.htm +++ /dev/null @@ -1,5 +0,0 @@ -<%+header%> -

404 Not Found

-

Sorry, the object you requested was not found.

-Unable to dispatch: <%=luci.http.env.PATH_INFO%> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/error500.htm b/modules/admin-core/src/view/error500.htm deleted file mode 100644 index 8af22e8f2..000000000 --- a/modules/admin-core/src/view/error500.htm +++ /dev/null @@ -1,5 +0,0 @@ -<%+header%> -

500 Internal Server Error

-

Sorry, the server encountered an unexpected error.

-<%=message%> -<%+footer%> \ No newline at end of file diff --git a/modules/admin-core/src/view/footer.htm b/modules/admin-core/src/view/footer.htm deleted file mode 100644 index c8506ac5c..000000000 --- a/modules/admin-core/src/view/footer.htm +++ /dev/null @@ -1,7 +0,0 @@ -
-
-
- - - - \ No newline at end of file diff --git a/modules/admin-core/src/view/header.htm b/modules/admin-core/src/view/header.htm deleted file mode 100644 index 5f876781f..000000000 --- a/modules/admin-core/src/view/header.htm +++ /dev/null @@ -1,137 +0,0 @@ -<% -require("luci.sys") -local load1, load5, load15 = luci.sys.loadavg() - -local request = require("luci.dispatcher").request -local category = request[1] -local tree = luci.dispatcher.node() -local cattree = category and luci.dispatcher.node(category) -local node = luci.dispatcher.dispatched - -local c = tree -for i,r in ipairs(request) do - if c.nodes and c.nodes[r] then - c = c.nodes[r] - c._menu_selected = true - end -end - -require("luci.i18n").loadc("default") - -require("luci.http").prepare_content("text/html") -%> - - - - - <% if node and node.css then %><% end %> - - - LuCI - Lua Configuration Interface - - - - -
-<%:path Pfad%>: <% -local c = tree -local url = controller -for k,v in pairs(request) do - if c.nodes and c.nodes[v] then - c = c.nodes[v] - url = url .. "/" .. v - %><%=c.title or v%> <% if k ~= #request then %>» <% end - end -end -%> -
- -
- -<% end - end -end -%> -
- -
\ No newline at end of file diff --git a/modules/freifunk/luasrc/controller/freifunk/freifunk.lua b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua new file mode 100644 index 000000000..104f6cdfc --- /dev/null +++ b/modules/freifunk/luasrc/controller/freifunk/freifunk.lua @@ -0,0 +1,68 @@ +module("luci.controller.freifunk.freifunk", package.seeall) + +function index() + local page = node() + page.target = alias("freifunk") + + local page = node("freifunk") + page.title = "Freifunk" + page.target = alias("freifunk", "index") + page.order = 5 + page.setuser = "nobody" + page.setgroup = "nogroup" + + local page = node("freifunk", "index") + page.target = template("freifunk/index") + page.title = "Übersicht" + page.order = 10 + + local page = node("freifunk", "index", "contact") + page.target = template("freifunk/contact") + page.title = "Kontakt" + + + local page = node("freifunk", "status") + page.target = action_status + page.title = "Status" + page.order = 20 + page.setuser = false + page.setgroup = false + + local page = node("freifunk", "status", "routes") + page.target = template("public_status/routes") + page.title = "Routingtabelle" + page.order = 10 + + local page = node("freifunk", "status", "iwscan") + page.target = template("public_status/iwscan") + page.title = "WLAN-Scan" + page.order = 20 + + local page = node("admin", "index", "freifunk") + page.target = cbi("freifunk/freifunk") + page.title = "Freifunk" + page.order = 30 + + local page = node("admin", "index", "contact") + page.target = cbi("freifunk/contact") + page.title = "Kontakt" + page.order = 40 +end + +function action_status() + local data = {} + + data.s, data.m, data.r = luci.sys.sysinfo() + + data.wifi = luci.sys.wifi.getiwconfig() + + data.routes = {} + for i, r in pairs(luci.sys.net.routes()) do + if r.Destination == "00000000" then + table.insert(data.routes, r) + end + end + + + luci.template.render("public_status/index", data) +end \ No newline at end of file diff --git a/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua b/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua new file mode 100644 index 000000000..aabab19a1 --- /dev/null +++ b/modules/freifunk/luasrc/controller/freifunk/luciinfo.lua @@ -0,0 +1,45 @@ +module("luci.controller.freifunk.luciinfo", package.seeall) + +function index() + node("freifunk", "luciinfo").target = action_index +end + +function action_index() + local uci = luci.model.uci.StateSession() + + luci.http.prepare_content("text/plain") + + -- General + print("luciinfo.api=1") + print("luciinfo.version=" .. tostring(require("luci").__version__)) + + -- Sysinfo + local s, m, r = luci.sys.sysinfo() + local dr = luci.sys.net.defaultroute() + dr = dr and luci.sys.net.hexip4(dr.Gateway) or "" + local l1, l5, l15 = luci.sys.loadavg() + + print("sysinfo.system=" .. sanitize(s)) + print("sysinfo.cpu=" .. sanitize(m)) + print("sysinfo.ram=" .. sanitize(r)) + print("sysinfo.hostname=" .. sanitize(luci.sys.hostname())) + print("sysinfo.load1=" .. tostring(l1)) + print("sysinfo.load5=" .. tostring(l5)) + print("sysinfo.load15=" .. tostring(l15)) + print("sysinfo.defaultgw=" .. dr) + + + -- Freifunk + local ff = uci:sections("freifunk") or {} + for k, v in pairs(ff) do + for i, j in pairs(v) do + if i:sub(1, 1) ~= "." then + print("freifunk." .. k .. "." .. i .. "=" .. j) + end + end + end +end + +function sanitize(val) + return val:gsub("\n", "\t") +end \ No newline at end of file diff --git a/modules/freifunk/luasrc/controller/freifunk/olsr.lua b/modules/freifunk/luasrc/controller/freifunk/olsr.lua new file mode 100644 index 000000000..29858fc0e --- /dev/null +++ b/modules/freifunk/luasrc/controller/freifunk/olsr.lua @@ -0,0 +1,164 @@ +module("luci.controller.freifunk.olsr", package.seeall) +require("luci.sys") + +function index() + local page = node("freifunk", "olsr") + page.target = action_index + page.title = "OLSR" + page.order = 30 + + local page = node("freifunk", "olsr", "routes") + page.target = action_routes + page.title = "Routen" + page.order = 10 + + local page = node("freifunk", "olsr", "topology") + page.target = action_topology + page.title = "Topologie" + page.order = 20 + + local page = node("freifunk", "olsr", "hna") + page.target = action_hna + page.title = "HNA" + page.order = 30 + + local page = node("freifunk", "olsr", "mid") + page.target = action_mid + page.title = "MID" + page.order = 50 +end + +function action_index() + local data = fetch_txtinfo("links") + + if not data or not data.Links then + luci.template.render("freifunk-olsr/error_olsr") + return nil + end + + local function compare(a, b) + if tonumber(a.ETX) == 0 then + return false + end + + if tonumber(b.ETX) == 0 then + return true + end + + return tonumber(a.ETX) < tonumber(b.ETX) + end + + table.sort(data.Links, compare) + + luci.template.render("freifunk-olsr/index", {links=data.Links}) +end + +function action_routes() + local data = fetch_txtinfo("routes") + + if not data or not data.Routes then + luci.template.render("freifunk-olsr/error_olsr") + return nil + end + + local function compare(a, b) + if tonumber(a.ETX) == 0 then + return false + end + + if tonumber(b.ETX) == 0 then + return true + end + + return tonumber(a.ETX) < tonumber(b.ETX) + end + + table.sort(data.Routes, compare) + + luci.template.render("freifunk-olsr/routes", {routes=data.Routes}) +end + +function action_topology() + local data = fetch_txtinfo("topology") + + if not data or not data.Topology then + luci.template.render("freifunk-olsr/error_olsr") + return nil + end + + local function compare(a, b) + return a["Destination IP"] < b["Destination IP"] + end + + table.sort(data.Topology, compare) + + luci.template.render("freifunk-olsr/topology", {routes=data.Topology}) +end + +function action_hna() + local data = fetch_txtinfo("hna") + + if not data or not data.HNA then + luci.template.render("freifunk-olsr/error_olsr") + return nil + end + + local function compare(a, b) + return a.Network < b.Network + end + + table.sort(data.HNA, compare) + + luci.template.render("freifunk-olsr/hna", {routes=data.HNA}) +end + +function action_mid() + local data = fetch_txtinfo("mid") + + if not data or not data.MID then + luci.template.render("freifunk-olsr/error_olsr") + return nil + end + + local function compare(a, b) + return a.IP < b.IP + end + + table.sort(data.MID, compare) + + luci.template.render("freifunk-olsr/mid", {mids=data.MID}) +end + + +-- Internal +function fetch_txtinfo(otable) + otable = otable or "" + local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable) + + if #rawdata == 0 then + return nil + end + + local data = {} + + local tables = luci.util.split(luci.util.trim(rawdata), "\n\n") + + + for i, tbl in ipairs(tables) do + local lines = luci.util.split(tbl, "\n") + local name = table.remove(lines, 1):sub(8) + local keys = luci.util.split(table.remove(lines, 1), "\t") + + data[name] = {} + + for j, line in ipairs(lines) do + local fields = luci.util.split(line, "\t") + data[name][j] = {} + for k, key in pairs(keys) do + data[name][j][key] = fields[k] + end + end + end + + return data +end \ No newline at end of file diff --git a/modules/freifunk/luasrc/i18n/admin_index_contact.en b/modules/freifunk/luasrc/i18n/admin_index_contact.en new file mode 100644 index 000000000..e2402e91f --- /dev/null +++ b/modules/freifunk/luasrc/i18n/admin_index_contact.en @@ -0,0 +1,11 @@ +contact1 = [[This information will be available on the public contact page. +As stated in the Picopeering Agreement you should at least enter your e-mail address. +To display your router on any topography map, please enter your geographical coordinates or at least +your street and house number in the location field.]] +nickname = "Nickname" +mail1 = "This field is essential!" +phone = "Phone" +location = "Location" +coord = "Coordinates" +coord1 = "Latitude;Longitude (e.g. 51.5;12.9)" +note = "Note" \ No newline at end of file diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua b/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua new file mode 100644 index 000000000..66a1ec4bd --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/contact.lua @@ -0,0 +1,18 @@ +-- Todo: Translate +m = Map("freifunk", translate("contact", "Kontakt"), translate("contact1", [[Diese Daten sind +auf der öffentlichen Kontaktseite sichtbar. Bitte gib an, wie man dich am besten kontaktieren kann. +Diese Informationen sollten nach der Picopeering Vereinbarung mindestens deine E-Mail-Adresse enthalten. +Damit dein Knoten durch Topographieprogramme erfasst werden kann, gib bitte deine Geokoordinaten oder +zumindest deine Straße und Hausnummer unter Standort an.]])) + +c = m:section(NamedSection, "contact", "public") + +c:option(Value, "nickname", translate("nickname", "Pseudonym")) +c:option(Value, "name", translate("name", "Name")) +c:option(Value, "mail", translate("mail", "E-Mail"), translate("mail1", "Bitte unbedingt angeben!")) +c:option(Value, "phone", translate("phone", "Telefon")) +c:option(Value, "location", translate("location", "Standort")) +c:option(Value, "geo", translate("coord", "Koordinaten"), translate("coord1", "Bitte als Breite;Länge (z.B: 51.5;12.9) angeben")) +c:option(Value, "note", translate("note", "Notiz")) + +return m \ No newline at end of file diff --git a/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua new file mode 100644 index 000000000..fe9e285b4 --- /dev/null +++ b/modules/freifunk/luasrc/model/cbi/freifunk/freifunk.lua @@ -0,0 +1,19 @@ +-- Todo: Translate +m = Map("freifunk", "Freifunk") + +c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen +für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration +des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]]) +c:option(Value, "name", "Gemeinschaft") +c:option(Value, "homepage", "Webseite") +c:option(Value, "essid", "ESSID") +c:option(Value, "bssid", "BSSID") +c:option(Value, "channel", "Funkkanal") +c:option(Value, "realm", "Realm") +c:option(Value, "net", "Adressbereich") +c:option(Value, "mask", "Netzmaske") +c:option(Value, "dns", "DNS-Server") +c:option(Value, "dhcp", "DHCP-Bereich") +c:option(Value, "dhcpmask", "DHCP-Maske") + +return m \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/error_olsr.htm b/modules/freifunk/luasrc/view/freifunk-olsr/error_olsr.htm new file mode 100644 index 000000000..25426f50d --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/error_olsr.htm @@ -0,0 +1,6 @@ +<%+header%> +

<%:olsr OLSR%>

+

<%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%>

+

<%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet +und das Plugin "txtinfo" geladen sein.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/hna.htm b/modules/freifunk/luasrc/view/freifunk-olsr/hna.htm new file mode 100644 index 000000000..c13369f42 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/hna.htm @@ -0,0 +1,17 @@ +<%+header%> +

<%:olsrhna OLSR-HNA%>

+
+ + + + + +<% for k, route in ipairs(routes) do %> + + + + +<% end %> +
<%:destination Ziel%><%:gateway Gateway%>
<%=route.Network%>/<%=route.Netmask%><%=route.Gateway%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/index.htm b/modules/freifunk/luasrc/view/freifunk-olsr/index.htm new file mode 100644 index 000000000..0633d1f45 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/index.htm @@ -0,0 +1,43 @@ +<%+header%> +

<%:olsrlinks OLSR-Verbindungen%>

+

<%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%>

+
+ + + + + + + + +<% for k, link in ipairs(links) do + local color = "#bb3333" + + link.ETX = tonumber(link.ETX) + if link.ETX == 0 then + color = "#bb3333" + elseif link.ETX < 4 then + color = "#00cc00" + elseif link.ETX < 10 then + color = "#ffcb05" + elseif link.ETX < 100 then + color = "#ff6600" + end +%> + + + + + + + +<% end %> +
<%:destination Ziel%><%:local Lokal%>LQNLQETX
"><%=link["remote IP"]%><%=link["Local IP"]%><%=link.LinkQuality%><%=link.NLQ%><%=link.ETX%>
+
+

<%:legend Legende%>:

+
    +
  • LQ: <%:lq1 Erfolgsquote gesendeter Pakete%>
  • +
  • NLQ: <%:nlq1 Erfolgsquote empfangener Pakete%>
  • +
  • ETX: <%:etx1 Zu erwartende Sendeversuche pro Paket%>
  • +
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/mid.htm b/modules/freifunk/luasrc/view/freifunk-olsr/mid.htm new file mode 100644 index 000000000..6553237ea --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/mid.htm @@ -0,0 +1,17 @@ +<%+header%> +

<%:olsrmid OLSR-MID%>

+
+ + + + + +<% for k, mid in ipairs(mids) do %> + + + + +<% end %> +
<%:node Knoten%><%:aliases Aliasse%>
<%=mid.IP%><%=mid.Aliases%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/routes.htm b/modules/freifunk/luasrc/view/freifunk-olsr/routes.htm new file mode 100644 index 000000000..f3a0fd336 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/routes.htm @@ -0,0 +1,36 @@ +<%+header%> +

<%:olsrlinks OLSR-Routen%>

+
+ + + + + + + + +<% for k, route in ipairs(routes) do + local color = "#bb3333" + + route.ETX = tonumber(route.ETX) + if route.ETX == 0 then + color = "#bb3333" + elseif route.ETX < 4 then + color = "#00cc00" + elseif route.ETX < 10 then + color = "#ffcb05" + elseif route.ETX < 100 then + color = "#ff6600" + end +%> + + + + + + + +<% end %> +
<%:destination Ziel%><%:gateway Gateway%><%:interface Schnittstelle%><%:metric Metrik%>ETX
<%=route.Destination%><%=route.Gateway%><%=route.Interface%><%=route.Metric%><%=route.ETX%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk-olsr/topology.htm b/modules/freifunk/luasrc/view/freifunk-olsr/topology.htm new file mode 100644 index 000000000..c622026d4 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk-olsr/topology.htm @@ -0,0 +1,23 @@ +<%+header%> +

<%:olsrtopo OLSR-Topologie%>

+
+ + + + + + + + +<% for k, route in ipairs(routes) do %> + + + + + + + +<% end %> +
<%:destination Ziel%><%:lasthop Letzter Router%>LQILQETX
"><%=route["Destination IP"]%>"><%=route["Last hop IP"]%><%=route.LQ%><%=route.ILQ%><%=route.ETX%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk/contact.htm b/modules/freifunk/luasrc/view/freifunk/contact.htm new file mode 100644 index 000000000..c240916db --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk/contact.htm @@ -0,0 +1,13 @@ +<%+header%> +<% local contact = luci.model.uci.sections("freifunk").contact %> +

<%:contact Kontakt%>

+ + + + + + + + +
<%:nickname Pseudonym%>:<%=contact.nickname%>
<%:name Name%>:<%=contact.name%>
<%:mail E-Mail%>:<%=contact.mail%>
<%:phone Telefon%>:<%=contact.phone%>
<%:location Standort%>:<%=contact.location%>
<%:geocoord Geokoordinaten%>:<%=contact.geo%>
<%:note Notiz%>:<%=contact.note%>
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/freifunk/index.htm b/modules/freifunk/luasrc/view/freifunk/index.htm new file mode 100644 index 000000000..c5ee17b10 --- /dev/null +++ b/modules/freifunk/luasrc/view/freifunk/index.htm @@ -0,0 +1,11 @@ +<%+header%> +<% local ff = luci.model.uci.sections("freifunk") %> +

<%:hellonet Hallo und willkommen im Netz von%> <%=ff.community.name%>!

+

<%:public1 Wir sind eine Initiative zur Schaffung eines freien, offenen und unabhängigen Funknetzwerks auf WLAN-Basis.%>
+<%:public2 Dies ist der Zugangspunkt %><%=luci.sys.hostname()%>. <%:public3 Er wird betrieben von %> +<%=ff.contact.nickname%>.

+

<%:public4 Weitere Informationen zur globalen Freifunkinitiative findest du unter%> Freifunk.net.
+<%:public5 Hast du Interesse an diesem Projekt, dann wende dich an deine lokale Gemeinschaft%> <%=ff.community.name%>.

+

<%:note Hinweis%>: <%:public6 Der Internetzugang über das experimentelle Freifunknetz ist an technische und organisatorische Bedingungen geknüpft und deshalb möglicherweise +nicht (immer) gewährleistet.%>

+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/public_status/index.htm b/modules/freifunk/luasrc/view/public_status/index.htm new file mode 100644 index 000000000..653baf984 --- /dev/null +++ b/modules/freifunk/luasrc/view/public_status/index.htm @@ -0,0 +1,77 @@ +<%+header%> +

<%:status Status%>

+

<%:system System%>

+ +
+ + + + + + + + + + + + + +
<%:system_type Systemtyp%>:<%=s%>
<%:cpu Prozessor%>:<%=m%>
<%:ram Hauptspeicher%>:<%=r%>
+

+ +

<%:wifi Drahtlos%>

+
+ + + + + + + + + + + + + +<%for k, v in pairs(luci.sys.wifi.getiwconfig()) do +%> + + + + + + + + + + + + + + + + +<%end%> +
<%:name Name%><%:protocol Protokoll%><%:frequency Frequenz%><%:power Leistung%><%:bitrate Bitrate%><%:rts RTS%><%:frag Frag.%><%:link Verb.%><%:signal Signal%><%:noise Rausch%>
<%=k%><%=v[1]%><%=v.Frequency%><%=v["Tx-Power"]%><%=v["Bit Rate"]%><%=v["RTS thr"]%><%=v["Fragment thr"]%><%=v["Link Quality"]%><%=v["Signal level"]%><%=v["Noise level"]%>
ESSID: <%=v.ESSID%>BSSID: <%=(v.Cell or v["Access Point"])%>
+
+
+

<%:defroutes Standardrouten%>

+
+ + + + + + +<% +for i, rt in pairs(routes) do +%> + + +<% end %> +
<%:gateway Gateway%><%:metric Metrik%><%:iface Schnittstelle%>
<%=luci.sys.net.hexip4(rt.Gateway)%> +<%=rt.Metric%> +<%=rt.Iface%> +
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/public_status/iwscan.htm b/modules/freifunk/luasrc/view/public_status/iwscan.htm new file mode 100644 index 000000000..adba2d23e --- /dev/null +++ b/modules/freifunk/luasrc/view/public_status/iwscan.htm @@ -0,0 +1,38 @@ +<%+header%> +

<%:iwscan WLAN-Scan%>

+

<%:iwscan1 Drahtlosnetzwerke in der lokalen Umgebung des Routers:%>

+ +
+ + + + + + + + + + + + +<%for iface, cells in pairs(luci.sys.wifi.iwscan()) do + for i, cell in ipairs(cells) do +%> + + + + + + + + + + + +<% + end +end +%> +
<%:interface Schnittstelle%><%:essid ESSID%><%:bssid BSSID%><%:mode Modus%><%:channel Kanal%><%:encr Vers.%><%:link Verb.%><%:signal Signal%><%:noise Rausch%>
<%=iface%><%=cell.ESSID%><%=cell.Address%><%=cell.Mode%><%=(cell.Channel or cell.Frequency or "")%><%=cell["Encryption key"]%><%=cell.Quality%><%=cell["Signal level"]%><%=cell["Noise level"]%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/luasrc/view/public_status/routes.htm b/modules/freifunk/luasrc/view/public_status/routes.htm new file mode 100644 index 000000000..382b8290f --- /dev/null +++ b/modules/freifunk/luasrc/view/public_status/routes.htm @@ -0,0 +1,28 @@ +<%+header%> +

<%:routes Routen%>

+ +
+ + + + + + + + +<% +local routes = luci.sys.net.routes() + +for i, r in pairs(routes) do +%> + + + + + + + +<% end %> +
<%:target Ziel%><%:netmask Netzmaske%><%:gateway Gateway%><%:metric Metrik%><%:iface Schnittstelle%>
<%=luci.sys.net.hexip4(r.Destination)%><%=luci.sys.net.hexip4(r.Mask)%><%=luci.sys.net.hexip4(r.Gateway)%><%=r.Metric%><%=r.Iface%>
+
+<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/controller/freifunk/freifunk.lua b/modules/freifunk/src/controller/freifunk/freifunk.lua deleted file mode 100644 index 104f6cdfc..000000000 --- a/modules/freifunk/src/controller/freifunk/freifunk.lua +++ /dev/null @@ -1,68 +0,0 @@ -module("luci.controller.freifunk.freifunk", package.seeall) - -function index() - local page = node() - page.target = alias("freifunk") - - local page = node("freifunk") - page.title = "Freifunk" - page.target = alias("freifunk", "index") - page.order = 5 - page.setuser = "nobody" - page.setgroup = "nogroup" - - local page = node("freifunk", "index") - page.target = template("freifunk/index") - page.title = "Übersicht" - page.order = 10 - - local page = node("freifunk", "index", "contact") - page.target = template("freifunk/contact") - page.title = "Kontakt" - - - local page = node("freifunk", "status") - page.target = action_status - page.title = "Status" - page.order = 20 - page.setuser = false - page.setgroup = false - - local page = node("freifunk", "status", "routes") - page.target = template("public_status/routes") - page.title = "Routingtabelle" - page.order = 10 - - local page = node("freifunk", "status", "iwscan") - page.target = template("public_status/iwscan") - page.title = "WLAN-Scan" - page.order = 20 - - local page = node("admin", "index", "freifunk") - page.target = cbi("freifunk/freifunk") - page.title = "Freifunk" - page.order = 30 - - local page = node("admin", "index", "contact") - page.target = cbi("freifunk/contact") - page.title = "Kontakt" - page.order = 40 -end - -function action_status() - local data = {} - - data.s, data.m, data.r = luci.sys.sysinfo() - - data.wifi = luci.sys.wifi.getiwconfig() - - data.routes = {} - for i, r in pairs(luci.sys.net.routes()) do - if r.Destination == "00000000" then - table.insert(data.routes, r) - end - end - - - luci.template.render("public_status/index", data) -end \ No newline at end of file diff --git a/modules/freifunk/src/controller/freifunk/luciinfo.lua b/modules/freifunk/src/controller/freifunk/luciinfo.lua deleted file mode 100644 index aabab19a1..000000000 --- a/modules/freifunk/src/controller/freifunk/luciinfo.lua +++ /dev/null @@ -1,45 +0,0 @@ -module("luci.controller.freifunk.luciinfo", package.seeall) - -function index() - node("freifunk", "luciinfo").target = action_index -end - -function action_index() - local uci = luci.model.uci.StateSession() - - luci.http.prepare_content("text/plain") - - -- General - print("luciinfo.api=1") - print("luciinfo.version=" .. tostring(require("luci").__version__)) - - -- Sysinfo - local s, m, r = luci.sys.sysinfo() - local dr = luci.sys.net.defaultroute() - dr = dr and luci.sys.net.hexip4(dr.Gateway) or "" - local l1, l5, l15 = luci.sys.loadavg() - - print("sysinfo.system=" .. sanitize(s)) - print("sysinfo.cpu=" .. sanitize(m)) - print("sysinfo.ram=" .. sanitize(r)) - print("sysinfo.hostname=" .. sanitize(luci.sys.hostname())) - print("sysinfo.load1=" .. tostring(l1)) - print("sysinfo.load5=" .. tostring(l5)) - print("sysinfo.load15=" .. tostring(l15)) - print("sysinfo.defaultgw=" .. dr) - - - -- Freifunk - local ff = uci:sections("freifunk") or {} - for k, v in pairs(ff) do - for i, j in pairs(v) do - if i:sub(1, 1) ~= "." then - print("freifunk." .. k .. "." .. i .. "=" .. j) - end - end - end -end - -function sanitize(val) - return val:gsub("\n", "\t") -end \ No newline at end of file diff --git a/modules/freifunk/src/controller/freifunk/olsr.lua b/modules/freifunk/src/controller/freifunk/olsr.lua deleted file mode 100644 index 29858fc0e..000000000 --- a/modules/freifunk/src/controller/freifunk/olsr.lua +++ /dev/null @@ -1,164 +0,0 @@ -module("luci.controller.freifunk.olsr", package.seeall) -require("luci.sys") - -function index() - local page = node("freifunk", "olsr") - page.target = action_index - page.title = "OLSR" - page.order = 30 - - local page = node("freifunk", "olsr", "routes") - page.target = action_routes - page.title = "Routen" - page.order = 10 - - local page = node("freifunk", "olsr", "topology") - page.target = action_topology - page.title = "Topologie" - page.order = 20 - - local page = node("freifunk", "olsr", "hna") - page.target = action_hna - page.title = "HNA" - page.order = 30 - - local page = node("freifunk", "olsr", "mid") - page.target = action_mid - page.title = "MID" - page.order = 50 -end - -function action_index() - local data = fetch_txtinfo("links") - - if not data or not data.Links then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Links, compare) - - luci.template.render("freifunk-olsr/index", {links=data.Links}) -end - -function action_routes() - local data = fetch_txtinfo("routes") - - if not data or not data.Routes then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - if tonumber(a.ETX) == 0 then - return false - end - - if tonumber(b.ETX) == 0 then - return true - end - - return tonumber(a.ETX) < tonumber(b.ETX) - end - - table.sort(data.Routes, compare) - - luci.template.render("freifunk-olsr/routes", {routes=data.Routes}) -end - -function action_topology() - local data = fetch_txtinfo("topology") - - if not data or not data.Topology then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a["Destination IP"] < b["Destination IP"] - end - - table.sort(data.Topology, compare) - - luci.template.render("freifunk-olsr/topology", {routes=data.Topology}) -end - -function action_hna() - local data = fetch_txtinfo("hna") - - if not data or not data.HNA then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.Network < b.Network - end - - table.sort(data.HNA, compare) - - luci.template.render("freifunk-olsr/hna", {routes=data.HNA}) -end - -function action_mid() - local data = fetch_txtinfo("mid") - - if not data or not data.MID then - luci.template.render("freifunk-olsr/error_olsr") - return nil - end - - local function compare(a, b) - return a.IP < b.IP - end - - table.sort(data.MID, compare) - - luci.template.render("freifunk-olsr/mid", {mids=data.MID}) -end - - --- Internal -function fetch_txtinfo(otable) - otable = otable or "" - local rawdata = luci.sys.httpget("http://127.0.0.1:2006/"..otable) - - if #rawdata == 0 then - return nil - end - - local data = {} - - local tables = luci.util.split(luci.util.trim(rawdata), "\n\n") - - - for i, tbl in ipairs(tables) do - local lines = luci.util.split(tbl, "\n") - local name = table.remove(lines, 1):sub(8) - local keys = luci.util.split(table.remove(lines, 1), "\t") - - data[name] = {} - - for j, line in ipairs(lines) do - local fields = luci.util.split(line, "\t") - data[name][j] = {} - for k, key in pairs(keys) do - data[name][j][key] = fields[k] - end - end - end - - return data -end \ No newline at end of file diff --git a/modules/freifunk/src/i18n/admin_index_contact.en b/modules/freifunk/src/i18n/admin_index_contact.en deleted file mode 100644 index e2402e91f..000000000 --- a/modules/freifunk/src/i18n/admin_index_contact.en +++ /dev/null @@ -1,11 +0,0 @@ -contact1 = [[This information will be available on the public contact page. -As stated in the Picopeering Agreement you should at least enter your e-mail address. -To display your router on any topography map, please enter your geographical coordinates or at least -your street and house number in the location field.]] -nickname = "Nickname" -mail1 = "This field is essential!" -phone = "Phone" -location = "Location" -coord = "Coordinates" -coord1 = "Latitude;Longitude (e.g. 51.5;12.9)" -note = "Note" \ No newline at end of file diff --git a/modules/freifunk/src/model/cbi/freifunk/contact.lua b/modules/freifunk/src/model/cbi/freifunk/contact.lua deleted file mode 100644 index 66a1ec4bd..000000000 --- a/modules/freifunk/src/model/cbi/freifunk/contact.lua +++ /dev/null @@ -1,18 +0,0 @@ --- Todo: Translate -m = Map("freifunk", translate("contact", "Kontakt"), translate("contact1", [[Diese Daten sind -auf der öffentlichen Kontaktseite sichtbar. Bitte gib an, wie man dich am besten kontaktieren kann. -Diese Informationen sollten nach der Picopeering Vereinbarung mindestens deine E-Mail-Adresse enthalten. -Damit dein Knoten durch Topographieprogramme erfasst werden kann, gib bitte deine Geokoordinaten oder -zumindest deine Straße und Hausnummer unter Standort an.]])) - -c = m:section(NamedSection, "contact", "public") - -c:option(Value, "nickname", translate("nickname", "Pseudonym")) -c:option(Value, "name", translate("name", "Name")) -c:option(Value, "mail", translate("mail", "E-Mail"), translate("mail1", "Bitte unbedingt angeben!")) -c:option(Value, "phone", translate("phone", "Telefon")) -c:option(Value, "location", translate("location", "Standort")) -c:option(Value, "geo", translate("coord", "Koordinaten"), translate("coord1", "Bitte als Breite;Länge (z.B: 51.5;12.9) angeben")) -c:option(Value, "note", translate("note", "Notiz")) - -return m \ No newline at end of file diff --git a/modules/freifunk/src/model/cbi/freifunk/freifunk.lua b/modules/freifunk/src/model/cbi/freifunk/freifunk.lua deleted file mode 100644 index fe9e285b4..000000000 --- a/modules/freifunk/src/model/cbi/freifunk/freifunk.lua +++ /dev/null @@ -1,19 +0,0 @@ --- Todo: Translate -m = Map("freifunk", "Freifunk") - -c = m:section(NamedSection, "community", "public", "Gemeinschaft", [[Dies sind die Grundeinstellungen -für die lokale Freifunkgemeinschaft. Diese Werte wirken sich NICHT auf die Konfiguration -des Routers aus, sondern definieren nur die Vorgaben für den Freifunkassistenten.]]) -c:option(Value, "name", "Gemeinschaft") -c:option(Value, "homepage", "Webseite") -c:option(Value, "essid", "ESSID") -c:option(Value, "bssid", "BSSID") -c:option(Value, "channel", "Funkkanal") -c:option(Value, "realm", "Realm") -c:option(Value, "net", "Adressbereich") -c:option(Value, "mask", "Netzmaske") -c:option(Value, "dns", "DNS-Server") -c:option(Value, "dhcp", "DHCP-Bereich") -c:option(Value, "dhcpmask", "DHCP-Maske") - -return m \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/error_olsr.htm b/modules/freifunk/src/view/freifunk-olsr/error_olsr.htm deleted file mode 100644 index 25426f50d..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/error_olsr.htm +++ /dev/null @@ -1,6 +0,0 @@ -<%+header%> -

<%:olsr OLSR%>

-

<%:olsrerror1 Es konnte keine Verbindung zum OLSR-Daemon hergestellt werden!%>

-

<%:olsrerror2 Um die Statusinformationen abfragen zu können muss der OLSR-Daemon gestartet -und das Plugin "txtinfo" geladen sein.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/hna.htm b/modules/freifunk/src/view/freifunk-olsr/hna.htm deleted file mode 100644 index c13369f42..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/hna.htm +++ /dev/null @@ -1,17 +0,0 @@ -<%+header%> -

<%:olsrhna OLSR-HNA%>

-
- - - - - -<% for k, route in ipairs(routes) do %> - - - - -<% end %> -
<%:destination Ziel%><%:gateway Gateway%>
<%=route.Network%>/<%=route.Netmask%><%=route.Gateway%>
-
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/index.htm b/modules/freifunk/src/view/freifunk-olsr/index.htm deleted file mode 100644 index 0633d1f45..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/index.htm +++ /dev/null @@ -1,43 +0,0 @@ -<%+header%> -

<%:olsrlinks OLSR-Verbindungen%>

-

<%:olsrlinks1 Übersicht über aktuell bestehende OLSR-Verbindungen%>

-
- - - - - - - - -<% for k, link in ipairs(links) do - local color = "#bb3333" - - link.ETX = tonumber(link.ETX) - if link.ETX == 0 then - color = "#bb3333" - elseif link.ETX < 4 then - color = "#00cc00" - elseif link.ETX < 10 then - color = "#ffcb05" - elseif link.ETX < 100 then - color = "#ff6600" - end -%> - - - - - - - -<% end %> -
<%:destination Ziel%><%:local Lokal%>LQNLQETX
"><%=link["remote IP"]%><%=link["Local IP"]%><%=link.LinkQuality%><%=link.NLQ%><%=link.ETX%>
-
-

<%:legend Legende%>:

-
    -
  • LQ: <%:lq1 Erfolgsquote gesendeter Pakete%>
  • -
  • NLQ: <%:nlq1 Erfolgsquote empfangener Pakete%>
  • -
  • ETX: <%:etx1 Zu erwartende Sendeversuche pro Paket%>
  • -
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/mid.htm b/modules/freifunk/src/view/freifunk-olsr/mid.htm deleted file mode 100644 index 6553237ea..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/mid.htm +++ /dev/null @@ -1,17 +0,0 @@ -<%+header%> -

<%:olsrmid OLSR-MID%>

-
- - - - - -<% for k, mid in ipairs(mids) do %> - - - - -<% end %> -
<%:node Knoten%><%:aliases Aliasse%>
<%=mid.IP%><%=mid.Aliases%>
-
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/routes.htm b/modules/freifunk/src/view/freifunk-olsr/routes.htm deleted file mode 100644 index f3a0fd336..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/routes.htm +++ /dev/null @@ -1,36 +0,0 @@ -<%+header%> -

<%:olsrlinks OLSR-Routen%>

-
- - - - - - - - -<% for k, route in ipairs(routes) do - local color = "#bb3333" - - route.ETX = tonumber(route.ETX) - if route.ETX == 0 then - color = "#bb3333" - elseif route.ETX < 4 then - color = "#00cc00" - elseif route.ETX < 10 then - color = "#ffcb05" - elseif route.ETX < 100 then - color = "#ff6600" - end -%> - - - - - - - -<% end %> -
<%:destination Ziel%><%:gateway Gateway%><%:interface Schnittstelle%><%:metric Metrik%>ETX
<%=route.Destination%><%=route.Gateway%><%=route.Interface%><%=route.Metric%><%=route.ETX%>
-
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk-olsr/topology.htm b/modules/freifunk/src/view/freifunk-olsr/topology.htm deleted file mode 100644 index c622026d4..000000000 --- a/modules/freifunk/src/view/freifunk-olsr/topology.htm +++ /dev/null @@ -1,23 +0,0 @@ -<%+header%> -

<%:olsrtopo OLSR-Topologie%>

-
- - - - - - - - -<% for k, route in ipairs(routes) do %> - - - - - - - -<% end %> -
<%:destination Ziel%><%:lasthop Letzter Router%>LQILQETX
"><%=route["Destination IP"]%>"><%=route["Last hop IP"]%><%=route.LQ%><%=route.ILQ%><%=route.ETX%>
-
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk/contact.htm b/modules/freifunk/src/view/freifunk/contact.htm deleted file mode 100644 index c240916db..000000000 --- a/modules/freifunk/src/view/freifunk/contact.htm +++ /dev/null @@ -1,13 +0,0 @@ -<%+header%> -<% local contact = luci.model.uci.sections("freifunk").contact %> -

<%:contact Kontakt%>

- - - - - - - - -
<%:nickname Pseudonym%>:<%=contact.nickname%>
<%:name Name%>:<%=contact.name%>
<%:mail E-Mail%>:<%=contact.mail%>
<%:phone Telefon%>:<%=contact.phone%>
<%:location Standort%>:<%=contact.location%>
<%:geocoord Geokoordinaten%>:<%=contact.geo%>
<%:note Notiz%>:<%=contact.note%>
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/freifunk/index.htm b/modules/freifunk/src/view/freifunk/index.htm deleted file mode 100644 index c5ee17b10..000000000 --- a/modules/freifunk/src/view/freifunk/index.htm +++ /dev/null @@ -1,11 +0,0 @@ -<%+header%> -<% local ff = luci.model.uci.sections("freifunk") %> -

<%:hellonet Hallo und willkommen im Netz von%> <%=ff.community.name%>!

-

<%:public1 Wir sind eine Initiative zur Schaffung eines freien, offenen und unabhängigen Funknetzwerks auf WLAN-Basis.%>
-<%:public2 Dies ist der Zugangspunkt %><%=luci.sys.hostname()%>. <%:public3 Er wird betrieben von %> -<%=ff.contact.nickname%>.

-

<%:public4 Weitere Informationen zur globalen Freifunkinitiative findest du unter%> Freifunk.net.
-<%:public5 Hast du Interesse an diesem Projekt, dann wende dich an deine lokale Gemeinschaft%> <%=ff.community.name%>.

-

<%:note Hinweis%>: <%:public6 Der Internetzugang über das experimentelle Freifunknetz ist an technische und organisatorische Bedingungen geknüpft und deshalb möglicherweise -nicht (immer) gewährleistet.%>

-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/public_status/index.htm b/modules/freifunk/src/view/public_status/index.htm deleted file mode 100644 index 653baf984..000000000 --- a/modules/freifunk/src/view/public_status/index.htm +++ /dev/null @@ -1,77 +0,0 @@ -<%+header%> -

<%:status Status%>

-

<%:system System%>

- -
- - - - - - - - - - - - - -
<%:system_type Systemtyp%>:<%=s%>
<%:cpu Prozessor%>:<%=m%>
<%:ram Hauptspeicher%>:<%=r%>
-

- -

<%:wifi Drahtlos%>

-
- - - - - - - - - - - - - -<%for k, v in pairs(luci.sys.wifi.getiwconfig()) do -%> - - - - - - - - - - - - - - - - -<%end%> -
<%:name Name%><%:protocol Protokoll%><%:frequency Frequenz%><%:power Leistung%><%:bitrate Bitrate%><%:rts RTS%><%:frag Frag.%><%:link Verb.%><%:signal Signal%><%:noise Rausch%>
<%=k%><%=v[1]%><%=v.Frequency%><%=v["Tx-Power"]%><%=v["Bit Rate"]%><%=v["RTS thr"]%><%=v["Fragment thr"]%><%=v["Link Quality"]%><%=v["Signal level"]%><%=v["Noise level"]%>
ESSID: <%=v.ESSID%>BSSID: <%=(v.Cell or v["Access Point"])%>
-
-
-

<%:defroutes Standardrouten%>

-
- - - - - - -<% -for i, rt in pairs(routes) do -%> - - -<% end %> -
<%:gateway Gateway%><%:metric Metrik%><%:iface Schnittstelle%>
<%=luci.sys.net.hexip4(rt.Gateway)%> -<%=rt.Metric%> -<%=rt.Iface%> -
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/public_status/iwscan.htm b/modules/freifunk/src/view/public_status/iwscan.htm deleted file mode 100644 index adba2d23e..000000000 --- a/modules/freifunk/src/view/public_status/iwscan.htm +++ /dev/null @@ -1,38 +0,0 @@ -<%+header%> -

<%:iwscan WLAN-Scan%>

-

<%:iwscan1 Drahtlosnetzwerke in der lokalen Umgebung des Routers:%>

- -
- - - - - - - - - - - - -<%for iface, cells in pairs(luci.sys.wifi.iwscan()) do - for i, cell in ipairs(cells) do -%> - - - - - - - - - - - -<% - end -end -%> -
<%:interface Schnittstelle%><%:essid ESSID%><%:bssid BSSID%><%:mode Modus%><%:channel Kanal%><%:encr Vers.%><%:link Verb.%><%:signal Signal%><%:noise Rausch%>
<%=iface%><%=cell.ESSID%><%=cell.Address%><%=cell.Mode%><%=(cell.Channel or cell.Frequency or "")%><%=cell["Encryption key"]%><%=cell.Quality%><%=cell["Signal level"]%><%=cell["Noise level"]%>
-
-<%+footer%> \ No newline at end of file diff --git a/modules/freifunk/src/view/public_status/routes.htm b/modules/freifunk/src/view/public_status/routes.htm deleted file mode 100644 index 382b8290f..000000000 --- a/modules/freifunk/src/view/public_status/routes.htm +++ /dev/null @@ -1,28 +0,0 @@ -<%+header%> -

<%:routes Routen%>

- -
- - - - - - - - -<% -local routes = luci.sys.net.routes() - -for i, r in pairs(routes) do -%> - - - - - - - -<% end %> -
<%:target Ziel%><%:netmask Netzmaske%><%:gateway Gateway%><%:metric Metrik%><%:iface Schnittstelle%>
<%=luci.sys.net.hexip4(r.Destination)%><%=luci.sys.net.hexip4(r.Mask)%><%=luci.sys.net.hexip4(r.Gateway)%><%=r.Metric%><%=r.Iface%>
-
-<%+footer%> \ No newline at end of file