udp2raw_status.htm 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <%
  2. local function get_udp2raw_version(name)
  3. local info = luci.util.split(luci.sys.exec("%s -h 2>/dev/null" %{name}), "\n")
  4. local version = string.match(info[2], "git version:(%w+)")
  5. local build = string.match(info[2], "build date:(.+)")
  6. return info[1] == "udp2raw-tunnel" and version or "", info[1] == "udp2raw-tunnel" and build or ""
  7. end
  8. local udp2raw_version, udp2raw_build = get_udp2raw_version("udp2raw")
  9. -%>
  10. <fieldset class="cbi-section">
  11. <legend><%:Running Status%></legend>
  12. <table width="100%" cellspacing="10" id="_udp2raw_status_table">
  13. <tr>
  14. <td width="33%"><%:Binary Version%></td>
  15. <td>
  16. <% if udp2raw_version == "" then -%>
  17. <em><%:Invalid Binary File.%></em>
  18. <% else -%>
  19. <%=pcdata(udp2raw_version)%>
  20. <%- end %>
  21. </td>
  22. </tr>
  23. <% if udp2raw_build ~= "" then -%>
  24. <tr><td width="33%"><%:Build Time%></td><td><%=pcdata(udp2raw_build)%></td></tr>
  25. <% end -%>
  26. <tr><td width="33%"><%:Running Status%></td><td id="_udp2raw_status"><em><%:Collecting data...%></em></td></tr>
  27. </table>
  28. </fieldset>
  29. <script type="text/javascript">//<![CDATA[
  30. var udp2raw_status = document.getElementById('_udp2raw_status');
  31. XHR.poll(5, '<%=luci.dispatcher.build_url("admin", "services", "udp2raw", "status")%>', null, function(x, status) {
  32. if ( x && x.status == 200 ) {
  33. udp2raw_status.innerHTML = status.running ? '<%:RUNNING%>' : '<%:NOT RUNNING%>';
  34. }
  35. });
  36. //]]></script>