From 45b2c4b2826a50ccedaabc459d55bd706e7baae0 Mon Sep 17 00:00:00 2001 From: coolsnowwolf Date: Mon, 8 Oct 2018 08:56:30 +0800 Subject: [PATCH] re-add autocore package for x86/x64 --- package/lean/autocore/Makefile | 37 + package/lean/autocore/files/autocore | 40 + package/lean/autocore/files/index.htm | 828 ++++++++++++++++++ .../luci-app-sfe/root/etc/uci-defaults/sfe | 2 +- 4 files changed, 906 insertions(+), 1 deletion(-) create mode 100644 package/lean/autocore/Makefile create mode 100755 package/lean/autocore/files/autocore create mode 100644 package/lean/autocore/files/index.htm diff --git a/package/lean/autocore/Makefile b/package/lean/autocore/Makefile new file mode 100644 index 000000000..091db206e --- /dev/null +++ b/package/lean/autocore/Makefile @@ -0,0 +1,37 @@ +# +# Copyright (C) 2010-2011 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# + +include $(TOPDIR)/rules.mk + +PKG_NAME:=autocore +PKG_VERSION:=1 +PKG_RELEASE:=11 + + +include $(INCLUDE_DIR)/package.mk + +define Package/autocore + TITLE:=x86/x64 auto core loadbalance script. + MAINTAINER:=Lean + DEPENDS:=@TARGET_x86 +bc +lm-sensors +endef + +define Package/autocore/description +A usb autoconfig hotplug script. +endef + +define Build/Compile +endef + +define Package/autocore/install + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/autocore $(1)/etc/init.d/autocore + $(INSTALL_DIR) $(1)/etc + $(INSTALL_DATA) ./files/index.htm $(1)/etc/index.htm +endef + +$(eval $(call BuildPackage,autocore)) diff --git a/package/lean/autocore/files/autocore b/package/lean/autocore/files/autocore new file mode 100755 index 000000000..7ba5ff01c --- /dev/null +++ b/package/lean/autocore/files/autocore @@ -0,0 +1,40 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2017 lean + +START=99 + +start() +{ + rfc=4096 + cc=$(grep -c processor /proc/cpuinfo) + rsfe=$(echo $cc*$rfc | bc) + sysctl -w net.core.rps_sock_flow_entries=$rsfe + for fileRps in $(ls /sys/class/net/eth*/queues/rx-*/rps_cpus) + do + echo $cc > $fileRps + done + + for fileRfc in $(ls /sys/class/net/eth*/queues/rx-*/rps_flow_cnt) + do + echo $rfc > $fileRfc + done + + for fileRps in $(ls /sys/class/net/eth*/queues/tx-*/xps_cpus) + do + echo $cc > $fileRps + done + + a=$(cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq) + b=$(echo -n ' : ') + c=$(cat /proc/cpuinfo | grep 'core id' | sort -u | wc -l) + d=$(echo -n ' Core ') + e=$(cat /proc/cpuinfo | grep 'processor' | wc -l) + f=$(echo -n ' Thread ') + g=${a}${b}${c}${d}${e}${f} + echo $g > /tmp/sysinfo/model + + [ -f /etc/index.htm ] && mv /etc/index.htm /usr/lib/lua/luci/view/admin_status/index.htm +} + + + diff --git a/package/lean/autocore/files/index.htm b/package/lean/autocore/files/index.htm new file mode 100644 index 000000000..7112337a9 --- /dev/null +++ b/package/lean/autocore/files/index.htm @@ -0,0 +1,828 @@ +<%# + 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("/proc/net/ipv6_route") + 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 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 rv = { + uptime = sysinfo.uptime or 0, + localtime = os.date(), + loadavg = sysinfo.load or { 0, 0, 0 }, + memory = meminfo, + 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 boardinfo.system or "?")%>
<%:CPU Temperature%><%=luci.sys.exec("sensors | grep 'Core 0' | cut -c10-24")%> @ <%=luci.sys.exec("grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'")%> MHz
<%:Firmware Version%> + <%=pcdata(ver.distname)%> <%=pcdata(ver.distversion)%> / + <%=pcdata(ver.luciname)%> (<%=pcdata(ver.luciversion)%>) +
<%:Kernel Version%><%=unameinfo.release or "?"%>
<%:Local Time%>-
<%:Uptime%>-
<%:Load Average%>-
+
+ +
+ <%:Memory%> + + + + + +
<%:Total Available%>-
<%:Free%>-
<%: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...%>
+
<%:Active Connections%>-
+
+ +<% if has_dhcp then %> +
+ <%:DHCP Leases%> + + + + + + + + + + + +
<%:Hostname%><%:IPv4-Address%><%:MAC-Address%><%:Leasetime remaining%>

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

?
<%:Collecting data...%>
+
+
+<% end %> + +<% if has_wifi then %> +
+ <%:Wireless%> + + + +
<%:Collecting data...%>
+
+ +
+ <%:Associated Stations%> + + + + + + + + + + + + + +
 <%:Network%><%:MAC-Address%><%:Host%><%:Signal%> / <%:Noise%><%:RX Rate%> / <%:TX Rate%>

<%:Collecting data...%>
+
+<% end %> + +<%- + local incdir = util.libpath() .. "/view/admin_status/index/" + if fs.access(incdir) then + local inc + for inc in fs.dir(incdir) do + if inc:match("%.htm$") then + include("admin_status/index/" .. inc:gsub("%.htm$", "")) + end + end + end +-%> + +<%+footer%> diff --git a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe index 5d2e653cb..444964d9b 100755 --- a/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe +++ b/package/lean/luci-app-sfe/root/etc/uci-defaults/sfe @@ -8,7 +8,7 @@ uci -q batch <<-EOF >/dev/null EOF sed -i '/dnscache-watchdog.sh/d' /etc/crontabs/root -echo '*/1 * * * * /usr/share/dnscache-watchdog.sh' >> /etc/crontabs/root +echo '*/60 * * * * /usr/share/dnscache-watchdog.sh' >> /etc/crontabs/root [ ! -f /usr/sbin/dnscache ] && ln /usr/sbin/pdnsd /usr/sbin/dnscache /etc/init.d/sfe enable