Kagera Web Interface
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

overview.cbsi 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #!/usr/bin/cbsi
  2. <%
  3. . /etc/version && . /etc/openwrt_release
  4. MEM_FREE=$(sed -e '/^MemFree: /!d; s#MemFree: *##; s# kB##g' /proc/meminfo | awk '{printf "%.2f", $1/1000}')
  5. MEM_TOTAL=$(sed -e '/^MemTotal: /!d; s#MemTotal: *##; s# kB##g' /proc/meminfo | awk '{printf "%.2f", $1/1000}')
  6. MEM_PERCENT=$(echo "${MEM_FREE} ${MEM_TOTAL}" | awk '{printf "%.2f", $1*100/$2}')
  7. UPTIME=$(cat /proc/uptime | cut -d '.' -f1)
  8. UPTIME_S=$(printf "%02d" $((UPTIME%60)))
  9. UPTIME_M=$(printf "%02d" $((UPTIME/60%60)))
  10. UPTIME_H=$(printf "%02d" $((UPTIME/60/60%24)))
  11. UPTIME_D=$((UPTIME/60/60/24))
  12. if [ -f /sbin/swconfig ]; then
  13. BOARD=$(cat /tmp/sysinfo/board_name)
  14. case "${BOARD}" in
  15. routerstation-pro)
  16. SWPORTS="4 3 2"
  17. WANPORT="eth0";;
  18. *)
  19. SWPORTS="";;
  20. esac
  21. if [ "${SWPORTS}" != "" ]; then
  22. if [ "$(ethtool ${WANPORT} | grep "Link detected" | cut -d" " -f3)" == "no" ]; then
  23. STATUS="-----"
  24. IMG="off"
  25. else
  26. LINK=$(ethtool ${WANPORT} | grep "Speed" | cut -d" " -f2)
  27. IMG="on"
  28. case "${LINK}" in
  29. "1000Mb/s") STATUS="1 Gbit/s";;
  30. "100Mb/s") STATUS="100 Mbit/s";;
  31. *) STATUS="10 Mbit/s";;
  32. esac
  33. fi
  34. PORTNO="${PORTNO}<td>WAN</td><td></td>"
  35. PORTIMG="${PORTIMG}<td><img src=\"themes/kagera/images/rj45${IMG}.gif\" alt=\"${IMG}\" /></td><td></td>"
  36. PORTSPEED="${PORTSPEED}<td>${STATUS}</td><td></td>"
  37. for PORT in ${SWPORTS}; do
  38. LINK=$(swconfig dev switch0 port $PORT get link | cut -f2,3 -d" ")
  39. N=$((N+1))
  40. case "${LINK}" in
  41. "link:up speed:1000baseT") STATUS="1 Gbit/s" IMG="on";;
  42. "link:up speed:100baseT") STATUS="100 Mbit/s" IMG="on";;
  43. "link:up speed:10baseT") STATUS="10 Mbit/s" IMG="on";;
  44. "link:down") STATUS="-----" IMG="off";;
  45. esac
  46. PORTNO="${PORTNO}<td>LAN ${N}</td>"
  47. PORTIMG="${PORTIMG}<td><img src=\"themes/kagera/images/rj45${IMG}.gif\" alt=\"${IMG}\" /></td>"
  48. PORTSPEED="${PORTSPEED}<td>${STATUS}</td>"
  49. done
  50. fi
  51. fi
  52. %>
  53. <h1><%@ System Overview %></h1>
  54. <table class="confdata">
  55. <tr>
  56. <td class="name"><%@ Router Model %></td>
  57. <td class="value"><% [ -e /tmp/sysinfo/model ] && cat /tmp/sysinfo/model || %><%@ Unknown %></td>
  58. </tr>
  59. <tr>
  60. <td class="name"><%@ Chipset %></td>
  61. <td class="value"><% cat /proc/cpuinfo | sed 2,20d | cut -c16- %></td>
  62. </tr>
  63. <tr>
  64. <td class="name"><%@ CPU Frequency %></td>
  65. <td class="value"><% dmesg | grep Clocks: | awk -F: '{print $3}' | cut -d. -f1 %> <small>MHz</small></td>
  66. </tr>
  67. <tr>
  68. <td class="name"><%@ Flash Size %></td>
  69. <td class="value"><% dmesg | grep m25p80 | grep Kbytes | cut -d '(' -f2 | cut -d ' ' -f1 | awk '{print $1/1024}' %> <small>MB</small></td>
  70. </tr>
  71. <tr>
  72. <td class="name"><%@ Firmware Version %></td>
  73. <td class="value"><%: ${SYSTEM_VERSION} %>, <%@ built on %>&nbsp;<%: ${SYSTEM_BUILDDATE} %></td>
  74. </tr>
  75. <tr>
  76. <td class="name"><%@ OpenWrt Revision %></td>
  77. <td class="value"><%: ${DISTRIB_REVISION} %></td>
  78. </tr>
  79. <tr>
  80. <td class="spacer" colspan="2"></td>
  81. </tr>
  82. <tr>
  83. <td class="name"><%@ Current Date & Time %></td>
  84. <td class="value"><% date "+%d/%m/%Y %H:%M:%S %Z" %></td>
  85. </tr>
  86. <tr>
  87. <td class="name"><%@ System Uptime %></td>
  88. <td class="value"><%: ${UPTIME_D} %>&nbsp;<%@ days %>, <%: ${UPTIME_H}:${UPTIME_M}:${UPTIME_S} %></td>
  89. </tr>
  90. <tr>
  91. <td class="name"><%@ Total / Free Memory %></td>
  92. <td class="value"><%: ${MEM_TOTAL} %> <small>MB</small> / <%: ${MEM_FREE} %> <small>MB (<%: ${MEM_PERCENT}% %>)</small></td>
  93. </tr>
  94. <tr>
  95. <td class="name"><%@ CPU Load <small>(1 / 5 / 15 mins)</small> %></td>
  96. <td class="value"><% awk '{print $1 " / " $2 " / " $3}' /proc/loadavg %></td>
  97. </tr>
  98. </table>
  99. <% if [ "${SWPORTS}" != "" ]; then %>
  100. <h2><%@ Ethernet Ports State %></h2>
  101. <table class="portstate">
  102. <tr class="portno">
  103. <%: ${PORTNO} %>
  104. </tr>
  105. <tr class="portimg">
  106. <%: ${PORTIMG} %>
  107. </tr>
  108. <tr class="portspeed">
  109. <%: ${PORTSPEED} %>
  110. </tr>
  111. </table>
  112. <% fi %>