diff --git a/package/lean/autocore/Makefile b/package/lean/autocore/Makefile index 36023155c3..952848b12d 100644 --- a/package/lean/autocore/Makefile +++ b/package/lean/autocore/Makefile @@ -9,31 +9,50 @@ include $(TOPDIR)/rules.mk PKG_NAME:=autocore PKG_VERSION:=1 -PKG_RELEASE:=31 +PKG_RELEASE:=32 include $(INCLUDE_DIR)/package.mk -define Package/autocore +define Package/autocore-raspberrypi + TITLE:=RaspberryPi auto core loadbalance script. + MAINTAINER:=CN_SZTL + DEPENDS:=@TARGET_bcm27xx +endef + +define Package/autocore-x86 TITLE:=x86/x64 auto core loadbalance script. MAINTAINER:=Lean DEPENDS:=@TARGET_x86 +bc +lm-sensors +ethtool endef define Package/autocore/description -A usb autoconfig hotplug script. + A usb autoconfig hotplug script. endef +Package/autocore-x86/description = $(call Package/autocore/description) +Package/autocore-raspberrypi/description = $(call Package/autocore/description) + define Build/Compile endef -define Package/autocore/install - $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_BIN) ./files/autocore $(1)/etc/init.d/autocore +define Package/autocore-raspberrypi/install $(INSTALL_DIR) $(1)/etc - $(INSTALL_DATA) ./files/index.htm $(1)/etc/index.htm + $(INSTALL_DATA) ./files/raspberrypi/index.htm $(1)/etc/index.htm + $(INSTALL_DIR) $(1)/etc/uci-defaults + $(INSTALL_BIN) ./files/raspberrypi/090-cover-index_htm $(1)/etc/uci-defaults/090-cover-index_htm $(INSTALL_DIR) $(1)/sbin - $(CP) ./files/sbin/* $(1)/sbin + $(CP) ./files/raspberrypi/sbin/* $(1)/sbin endef -$(eval $(call BuildPackage,autocore)) +define Package/autocore-x86/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/autocore + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) ./files/x86/index.htm $(1)/etc/index.htm + $(INSTALL_DIR) $(1)/sbin + $(CP) ./files/x86/sbin/* $(1)/sbin +endef + +$(eval $(call BuildPackage,autocore-raspberrypi)) +$(eval $(call BuildPackage,autocore-x86)) diff --git a/package/lean/autocore/files/raspberrypi/090-cover-index_htm b/package/lean/autocore/files/raspberrypi/090-cover-index_htm new file mode 100755 index 0000000000..9aee5eb548 --- /dev/null +++ b/package/lean/autocore/files/raspberrypi/090-cover-index_htm @@ -0,0 +1,5 @@ +#!/bin/sh + +[ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm + +exit 0 diff --git a/package/lean/autocore/files/raspberrypi/index.htm b/package/lean/autocore/files/raspberrypi/index.htm new file mode 100644 index 0000000000..746926885e --- /dev/null +++ b/package/lean/autocore/files/raspberrypi/index.htm @@ -0,0 +1,818 @@ +<%# + Copyright 2008 Steven Barth + Copyright 2008-2011 Jo-Philipp Wich + Licensed to the public under the Apache License 2.0. +-%> + +<% + local fs = require "nixio.fs" + local util = require "luci.util" + local stat = require "luci.tools.status" + local ver = require "luci.version" + + local has_ipv6 = fs.access("/usr/sbin/ip6tables") + local has_dhcp = fs.access("/etc/config/dhcp") + local has_wifi = ((fs.stat("/etc/config/wireless", "size") or 0) > 0) + + local sysinfo = luci.util.ubus("system", "info") or { } + local boardinfo = luci.util.ubus("system", "board") or { } + local unameinfo = nixio.uname() or { } + + local meminfo = sysinfo.memory or { + total = 0, + free = 0, + buffered = 0, + shared = 0 + } + + local mem_cached = luci.sys.exec("sed -e '/^Cached: /!d; s#Cached: *##; s# kB##g' /proc/meminfo") + + local swapinfo = sysinfo.swap or { + total = 0, + free = 0 + } + + local has_dsl = fs.access("/etc/init.d/dsl_control") + + if luci.http.formvalue("status") == "1" then + local ntm = require "luci.model.network".init() + local wan = ntm:get_wannet() + local wan6 = ntm:get_wan6net() + + local conn_count = tonumber( + fs.readfile("/proc/sys/net/netfilter/nf_conntrack_count") or "") or 0 + + local conn_max = tonumber(luci.sys.exec( + "sysctl -n -e net.nf_conntrack_max net.ipv4.netfilter.ip_conntrack_max" + ):match("%d+")) or 4096 + + local user_info = luci.sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l") + + local cpu_usage = (luci.sys.exec("expr 100 - $(top -n 1 | grep 'CPU:' | awk -F '%' '{print$4}' | awk -F ' ' '{print$2}')") or "6") .. "%" + + local cpu_info = luci.sys.exec("cpuinfo") + + local rv = { + cpuusage = cpu_usage, + cpuinfo = cpu_info, + userinfo = user_info, + systemp = sys_temp, + uptime = sysinfo.uptime or 0, + localtime = os.date(), + loadavg = sysinfo.load or { 0, 0, 0 }, + memory = meminfo, + memcached = mem_cached, + swap = swapinfo, + connmax = conn_max, + conncount = conn_count, + leases = stat.dhcp_leases(), + leases6 = stat.dhcp6_leases(), + wifinets = stat.wifi_networks() + } + + if wan then + rv.wan = { + ipaddr = wan:ipaddr(), + gwaddr = wan:gwaddr(), + netmask = wan:netmask(), + dns = wan:dnsaddrs(), + expires = wan:expires(), + uptime = wan:uptime(), + proto = wan:proto(), + ifname = wan:ifname(), + link = wan:adminlink() + } + end + + if wan6 then + rv.wan6 = { + ip6addr = wan6:ip6addr(), + gw6addr = wan6:gw6addr(), + dns = wan6:dns6addrs(), + ip6prefix = wan6:ip6prefix(), + uptime = wan6:uptime(), + proto = wan6:proto(), + ifname = wan6:ifname(), + link = wan6:adminlink() + } + end + + if has_dsl then + local dsl_stat = luci.sys.exec("/etc/init.d/dsl_control lucistat") + local dsl_func = loadstring(dsl_stat) + if dsl_func then + rv.dsl = dsl_func() + end + end + + luci.http.prepare_content("application/json") + luci.http.write_json(rv) + + return + elseif luci.http.formvalue("hosts") == "1" then + luci.http.prepare_content("application/json") + luci.http.write_json(luci.sys.net.host_hints()) + + return + end +-%> + +<%+header%> + + + + +

<%:Status%>

+ +
+ <%:System%> + + + + + + + + + + + + +
<%:Hostname%><%=luci.sys.hostname() or "?"%>
<%:Model%><%=pcdata(boardinfo.model or "?")%> <%=luci.sys.exec("cat /etc/bench.log") or " "%>
<%:Architecture%><%=pcdata(boardinfo.system or "ARMv8 Processor")%> x <%=luci.sys.exec("cat /proc/cpuinfo | grep 'processor' | wc -l") or "1"%>
<%:CPU Info%>-
<%:Firmware Version%> + <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> +
<%:Kernel Version%><%=unameinfo.release or "?"%>
<%:Local Time%>-
<%:Uptime%>-
<%:Load Average%>-
<%:CPU usage (%)%>-
+
+ +
+ <%:Memory%> + + + + +
<%:Total Available%>-
<%:Buffered%>-
+
+ +<% if swapinfo.total > 0 then %> +
+ <%:Swap%> + + + + +
<%:Total Available%>-
<%:Free%>-
+
+<% end %> + +
+ <%:Network%> + + + + <% if has_ipv6 then %> + + <% end %> + + +
<%:IPv4 WAN Status%> + + + +

?
<%:Collecting data...%>
+
<%:IPv6 WAN Status%> + + + +

?
<%:Collecting data...%>
+
<%:Online Users%>0
<%:Active Connections%>-
+
+ +<% if has_dhcp then %> +
+ <%:DHCP Leases%> + + + + + + + + + + + +
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Leasetime remaining%>

<%:Collecting data...%>
+
+ +<% if has_ipv6 then %> + +<% end %> +<% end %> + +<% if has_dsl then %> +
+ <%:DSL%> + + +
<%:DSL Status%> + + + +

?
<%:Collecting data...%>
+
+
+<% end %> + +<% if has_wifi then %> +
+ <%:Wireless%> + + + +
<%:Collecting data...%>
+
+<% end %> + +<%+footer%> diff --git a/package/lean/autocore/files/raspberrypi/sbin/cpuinfo b/package/lean/autocore/files/raspberrypi/sbin/cpuinfo new file mode 100755 index 0000000000..3456ad6a14 --- /dev/null +++ b/package/lean/autocore/files/raspberrypi/sbin/cpuinfo @@ -0,0 +1,11 @@ +#!/bin/sh + +if command -v vcgencmd >/dev/null; then + cpu_freq="$(vcgencmd get_config arm_freq | awk -F '=' '{print $2}')Mhz" + sys_temp="$(vcgencmd measure_temp | grep -Eo '[0-9.]+')°C" +else + cpu_freq="$(expr $(cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq) / 1000)Mhz" + sys_temp="$(awk "BEGIN{printf (\"%.1f\n\",$(cat /sys/class/thermal/thermal_zone0/temp)/1000) }")°C" +fi + +echo -n "${cpu_freq} | ${sys_temp}" diff --git a/package/lean/autocore/files/autocore b/package/lean/autocore/files/x86/autocore similarity index 100% rename from package/lean/autocore/files/autocore rename to package/lean/autocore/files/x86/autocore diff --git a/package/lean/autocore/files/index.htm b/package/lean/autocore/files/x86/index.htm similarity index 100% rename from package/lean/autocore/files/index.htm rename to package/lean/autocore/files/x86/index.htm diff --git a/package/lean/autocore/files/sbin/cpuinfo b/package/lean/autocore/files/x86/sbin/cpuinfo similarity index 100% rename from package/lean/autocore/files/sbin/cpuinfo rename to package/lean/autocore/files/x86/sbin/cpuinfo diff --git a/package/lean/autocore/files/sbin/ethinfo b/package/lean/autocore/files/x86/sbin/ethinfo similarity index 100% rename from package/lean/autocore/files/sbin/ethinfo rename to package/lean/autocore/files/x86/sbin/ethinfo diff --git a/package/lean/autocore/files/sbin/getcpu b/package/lean/autocore/files/x86/sbin/getcpu similarity index 100% rename from package/lean/autocore/files/sbin/getcpu rename to package/lean/autocore/files/x86/sbin/getcpu