status.patch 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. --- a/package/feeds/luci/luci-base/root/usr/libexec/rpcd/luci
  2. +++ b/package/feeds/luci/luci-base/root/usr/libexec/rpcd/luci
  3. @@ -45,2 +45,29 @@
  4. + getCPUInfo = {
  5. + call = function()
  6. + local sys = require "luci.sys"
  7. + local rv = {}
  8. + rv.cpufreq = sys.exec("/sbin/cpuinfo")
  9. + rv.cpufree = (sys.exec("expr 100 - $(top -n 1 | grep 'CPU:' | awk -F '%' '{print$4}' | awk -F ' ' '{print$2}')") or "2.33") .. "%"
  10. + rv.cpumark = sys.exec("cat /etc/bench.log")
  11. + return rv
  12. + end
  13. + },
  14. +
  15. + getEthInfo = {
  16. + call = function()
  17. + local sys = require "luci.sys"
  18. + local result = sys.exec("ethinfo 2>/dev/null")
  19. + return { result = result }
  20. + end
  21. + },
  22. +
  23. + getUserInfo = {
  24. + call = function()
  25. + local sys = require "luci.sys"
  26. + local result = sys.exec("cat /proc/net/arp | grep 'br-lan' | grep '0x2' | wc -l")
  27. + return { result = result }
  28. + end
  29. + },
  30. +
  31. setLocaltime = {
  32. --- a/package/feeds/luci/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json
  33. +++ b/package/feeds/luci/luci-mod-system/root/usr/share/rpcd/acl.d/luci-mod-system.json
  34. @@ -3,7 +3,7 @@
  35. "description": "Grant access to system configuration",
  36. "read": {
  37. "ubus": {
  38. - "luci": [ "getInitList", "getLEDs", "getTimezones", "getUSBDevices" ],
  39. + "luci": [ "getInitList", "getLEDs", "getTimezones", "getUSBDevices", "getCPUInfo", "getEthInfo", "getUserInfo" ],
  40. "system": [ "info" ]
  41. },
  42. "uci": [ "luci", "system" ]
  43. --- a/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js
  44. +++ b/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/10_system.js
  45. @@ -15,17 +15,24 @@
  46. +var callCPUInfo = rpc.declare({
  47. + object: 'luci',
  48. + method: 'getCPUInfo'
  49. +});
  50. +
  51. return baseclass.extend({
  52. title: _('System'),
  53. load: function() {
  54. return Promise.all([
  55. L.resolveDefault(callSystemBoard(), {}),
  56. L.resolveDefault(callSystemInfo(), {}),
  57. + L.resolveDefault(callCPUInfo(), {}),
  58. fs.lines('/usr/lib/lua/luci/version.lua')
  59. ]);
  60. },
  61. render: function(data) {
  62. var boardinfo = data[0],
  63. systeminfo = data[1],
  64. - luciversion = data[2];
  65. + cpuinfo = data[2],
  66. + luciversion = data[3];
  67. @@ -54,9 +56,10 @@
  68. _('Hostname'), boardinfo.hostname,
  69. - _('Model'), boardinfo.model,
  70. + _('Model'), boardinfo.model + ' ' + cpuinfo.cpumark,
  71. _('Architecture'), boardinfo.system,
  72. _('Firmware Version'), (L.isObject(boardinfo.release) ? boardinfo.release.description + ' / ' : '') + (luciversion || ''),
  73. _('Kernel Version'), boardinfo.kernel,
  74. _('Local Time'), datestr,
  75. _('Uptime'), systeminfo.uptime ? '%t'.format(systeminfo.uptime) : null,
  76. - _('Load Average'), Array.isArray(systeminfo.load) ? '%.2f, %.2f, %.2f'.format(
  77. + _('CPU Info'), cpuinfo.cpufreq,
  78. + _('Load Average'), Array.isArray(systeminfo.load) ? '%.2f, %.2f, %.2f'.format(
  79. systeminfo.load[0] / 65535.0,
  80. --- a/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js
  81. +++ b/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/30_network.js
  82. @@ -2,6 +2,7 @@
  83. 'require baseclass';
  84. 'require fs';
  85. 'require network';
  86. +'require rpc';
  87. function progressbar(value, max, byte) {
  88. var vn = parseInt(value) || 0,
  89. @@ -59,6 +60,11 @@ function renderbox(ifc, ipv6) {
  90. ]);
  91. }
  92. +var callUserInfo = rpc.declare({
  93. + object: 'luci',
  94. + method: 'getUserInfo'
  95. +});
  96. +
  97. return baseclass.extend({
  98. title: _('Network'),
  99. @@ -67,7 +73,8 @@ return baseclass.extend({
  100. fs.trimmed('/proc/sys/net/netfilter/nf_conntrack_count'),
  101. fs.trimmed('/proc/sys/net/netfilter/nf_conntrack_max'),
  102. network.getWANNetworks(),
  103. - network.getWAN6Networks()
  104. + network.getWAN6Networks(),
  105. + L.resolveDefault(callUserInfo(), {})
  106. ]);
  107. },
  108. @@ -75,7 +82,8 @@ return baseclass.extend({
  109. var ct_count = +data[0],
  110. ct_max = +data[1],
  111. wan_nets = data[2],
  112. - wan6_nets = data[3];
  113. + wan6_nets = data[3],
  114. + userinfo = data[4];
  115. var fields = [
  116. _('Active Connections'), ct_max ? ct_count : null
  117. @@ -90,6 +98,10 @@ return baseclass.extend({
  118. (fields[i + 1] != null) ? progressbar(fields[i + 1], ct_max) : '?'
  119. ])
  120. ]));
  121. + ctstatus.appendChild(E('div', { 'class': 'tr' }, [
  122. + E('div', { 'class': 'td left' }, _('Online Users')),
  123. + E('div', { 'class': 'td left' }, userinfo.result)
  124. + ]));
  125. }
  126. var netstatus = E('div', { 'class': 'network-status-table' });
  127. --- a/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js
  128. +++ b/package/feeds/luci/luci-mod-status/htdocs/luci-static/resources/view/status/include/20_memory.js
  129. @@ -32,8 +32,7 @@ return baseclass.extend({
  130. swap = L.isObject(systeminfo.swap) ? systeminfo.swap : {};
  131. var fields = [
  132. - _('Total Available'), (mem.available) ? mem.available : (mem.total && mem.free && mem.buffered) ? mem.free + mem.buffered : null, mem.total,
  133. - _('Used'), (mem.total && mem.free) ? (mem.total - mem.free) : null, mem.total,
  134. + _('Used'), (mem.total && mem.available) ? (mem.total - mem.available) : null, mem.total,
  135. ];
  136. if (mem.buffered)
  137. @@ -43,9 +42,9 @@ return baseclass.extend({
  138. fields.push(_('Cached'), mem.cached, mem.total);
  139. if (swap.total > 0)
  140. - fields.push(_('Swap free'), swap.free, swap.total);
  141. + fields.push(_('Swap used'), swap.total - swap.free, swap.total);
  142. - var table = E('table', { 'class': 'table' });
  143. + var table = E('table', { 'class': 'table memory' });
  144. for (var i = 0; i < fields.length; i += 3) {
  145. table.appendChild(E('tr', { 'class': 'tr' }, [