From: Jo-Philipp Wich
Date: Sat, 17 May 2008 17:43:49 +0000 (+0000)
Subject: * ffluci: first work on statistics application based on collectd
X-Git-Tag: 0.8.0~1030
X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=191848dae080ba19390925b7acefe99e00968ec3;p=oweals%2Fluci.git
* ffluci: first work on statistics application based on collectd
---
diff --git a/applications/luci-statistics/Makefile b/applications/luci-statistics/Makefile
new file mode 100644
index 000000000..81a96f6a8
--- /dev/null
+++ b/applications/luci-statistics/Makefile
@@ -0,0 +1,2 @@
+include ../../build/config.mk
+include ../../build/module.mk
\ No newline at end of file
diff --git a/applications/luci-statistics/root/etc/config/luci_statistics b/applications/luci-statistics/root/etc/config/luci_statistics
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/root/etc/init.d/luci_statistics b/applications/luci-statistics/root/etc/init.d/luci_statistics
new file mode 100644
index 000000000..20f7865fd
--- /dev/null
+++ b/applications/luci-statistics/root/etc/init.d/luci_statistics
@@ -0,0 +1,85 @@
+#!/bin/sh /etc/rc.common
+START=70
+
+iface_add() {
+ local cfg="$1"
+
+ config_get net "$cfg" network
+ [ -n "$net" ] || return 0
+
+ config_get iface "$net" ifname
+ [ -n "$iface" ] || return 0
+ iface="${iface%%:*}"
+
+ config_get ipaddr "$net" ipaddr
+ [ -n "$ipaddr" ] || return 0
+
+ config_get netmask "$net" netmask
+ [ -n "$netmask" ] || return 0
+
+ eval "$(ipcalc.sh $ipaddr $netmask)"
+
+ iptables -t nat -A luci_splash -i "$iface" -s "$NETWORK/$PREFIX" -j luci_splash_portal
+ iptables -t nat -A luci_splash_portal -i "$iface" -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport --dports 22,80,443 -j RETURN
+}
+
+blacklist_add() {
+ local cfg="$1"
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
+}
+
+whitelist_add() {
+ local cfg="$1"
+
+ config_get mac "$cfg" mac
+ [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
+}
+
+start() {
+ ### Read chains from config
+ include /lib/network
+ scan_interfaces
+ config_load luci_splash
+
+ ### Create subchains
+ iptables -t nat -N luci_splash
+ iptables -t nat -N luci_splash_portal
+ iptables -t nat -N luci_splash_leases
+
+ ### Build the main and portal rule
+ config_foreach blacklist_add blacklist
+ config_foreach whitelist_add whitelist
+ config_foreach iface_add iface
+
+ ### Build the portal rule
+ iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
+ iptables -t nat -A luci_splash_portal -j luci_splash_leases
+
+ ### Build the leases rule
+ iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
+ iptables -t nat -A luci_splash_leases -j DROP
+
+ ### Start the splash httpd
+ httpd -c /etc/luci_splash_httpd.conf -p 8082 -h /usr/lib/luci-splash/htdocs
+
+ ### Hook in the chain
+ iptables -t nat -A prerouting_rule -j luci_splash
+}
+
+stop() {
+ ### Hook out the chain
+ iptables -t nat -D prerouting_rule -j luci_splash
+
+ ### Clear subchains
+ iptables -t nat -F luci_splash_leases
+ iptables -t nat -F luci_splash_portal
+ iptables -t nat -F luci_splash
+
+ ### Delete subchains
+ iptables -t nat -X luci_splash_leases
+ iptables -t nat -X luci_splash_portal
+ iptables -t nat -X luci_splash
+}
+
diff --git a/applications/luci-statistics/src/controller/admin/statistics.lua b/applications/luci-statistics/src/controller/admin/statistics.lua
new file mode 100644
index 000000000..3318f70cd
--- /dev/null
+++ b/applications/luci-statistics/src/controller/admin/statistics.lua
@@ -0,0 +1 @@
+module("ffluci.controller.admin.statistics", package.seeall)
diff --git a/applications/luci-statistics/src/controller/public/statistics.lua b/applications/luci-statistics/src/controller/public/statistics.lua
new file mode 100644
index 000000000..d7ed1e327
--- /dev/null
+++ b/applications/luci-statistics/src/controller/public/statistics.lua
@@ -0,0 +1 @@
+module("ffluci.controller.public.statistics", package.seeall)
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/csv.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/csv.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/dns.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/dns.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/exec.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/exec.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/index.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/index.lua
new file mode 100644
index 000000000..743909c18
--- /dev/null
+++ b/applications/luci-statistics/src/model/cbi/admin_statistics/index.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("ffluci.sys")
+
+
+m = Map("collectd", "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", "collectd", "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 in 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 = ffluci.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/admin_statistics/interface.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/interface.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/iptables.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/ping.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/ping.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/processes.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/processes.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/cbi/admin_statistics/tcpconns.lua b/applications/luci-statistics/src/model/cbi/admin_statistics/tcpconns.lua
new file mode 100644
index 000000000..e69de29bb
diff --git a/applications/luci-statistics/src/model/menu/70luci-statistics.lua b/applications/luci-statistics/src/model/menu/70luci-statistics.lua
new file mode 100644
index 000000000..ded0b8676
--- /dev/null
+++ b/applications/luci-statistics/src/model/menu/70luci-statistics.lua
@@ -0,0 +1,40 @@
+add( "admin", "statistics", "Statistiken", 70 )
+--act( "apache", "Apache" )
+--act( "apcups", "Apcups" )
+--act( "ascent", "Ascent" )
+--act( "cpufreq", "Cpufreq" )
+act( "csv", "CSV" )
+--act( "df", "Speicher" )
+--act( "disk", "Festplatte" )
+act( "dns", "DNS" )
+--act( "email", "E-Mail" )
+act( "exec", "Exec" )
+--act( "hddtemp", "Festplattentemperatur" )
+act( "interface", "Netzwerkschnittstellen" )
+act( "iptables", "Firewall" )
+--act( "irq", "Interrupts" )
+--act( "libvirt", "Virtualisierung" )
+--act( "logfile", "Protokolldateien" )
+--act( "mbmon", "Mainboardsensoren" )
+--act( "memcached", "Memcached" )
+--act( "mysql", "MySQL" )
+--act( "netlink", "Netlink" )
+--act( "network", "Netzwerk" )
+--act( "nginx", "nginx Server" )
+--act( "ntpd", "NTP Server" )
+--act( "nut", "Nut" )
+--act( "perl", "Perl" )
+act( "ping", "Ping" )
+--act( "powerdns", "Powerdns Server" )
+act( "processes", "Prozessüberwachung" )
+--act( "rrdtool", "RRD Tool" )
+--act( "sensors", "Sensoren" )
+--act( "snmp", "SNMP Datenquellen" )
+--act( "syslog", "Systemlog" )
+--act( "tail", "Dateiverfolgung" )
+--act( "teamspeak2", "TeamSpeak 2" )
+act( "tcpconns", "TCP Verbindungen" )
+--act( "unixsock", "UNIX Sockets" )
+--act( "uuid", "UUID" )
+--act( "vmem", "Vmem" )
+--act( "vserver", "VServer" )
diff --git a/applications/luci-statistics/src/view/public_statistics/index.htm b/applications/luci-statistics/src/view/public_statistics/index.htm
new file mode 100644
index 000000000..db4bd0f78
--- /dev/null
+++ b/applications/luci-statistics/src/view/public_statistics/index.htm
@@ -0,0 +1,31 @@
+<%:welcome Willkommen%>!
+
+Du bist jetzt mit dem freien Funknetz
+<%~freifunk.community.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:
+
+- bitte keine Filesharing-Programme betreiben!
+- bitte keine unnötigen Downloads oder Streams starten!
+- bitte keine illegalen Aktivitäten!
+
+
+
+
+Wenn Du unsere Idee gut findest, kannst Du uns unterstützen:
+
+
+
+
+Mit einem Klick auf <%:accept Annehmen%> kannst du für <%~luci_splash.general.leasetime%> Stunden
+über unser Netz das Internet verwenden. Dann wirst du erneut aufgefordet, diese Bedingungen zu akzeptieren.
+
\ No newline at end of file