diagnostics.htm 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <%#
  2. Copyright 2010 Jo-Philipp Wich <jow@openwrt.org>
  3. Licensed to the public under the Apache License 2.0.
  4. -%>
  5. <%+header%>
  6. <%
  7. local fs = require "nixio.fs"
  8. local has_ping6 = fs.access("/bin/ping6") or fs.access("/usr/bin/ping6")
  9. local has_traceroute6 = fs.access("/usr/bin/traceroute6")
  10. %>
  11. <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
  12. <script type="text/javascript">//<![CDATA[
  13. var stxhr = new XHR();
  14. function update_status(field, proto)
  15. {
  16. var tool = field.name;
  17. var addr = field.value;
  18. var protocol = proto ? "6" : "";
  19. var legend = document.getElementById('diag-rc-legend');
  20. var output = document.getElementById('diag-rc-output');
  21. if (legend && output)
  22. {
  23. output.innerHTML =
  24. '<img src="<%=resource%>/icons/loading.gif" alt="<%:Loading%>" style="vertical-align:middle" /> ' +
  25. '<%:Waiting for command to complete...%>'
  26. ;
  27. legend.parentNode.style.display = 'block';
  28. legend.style.display = 'inline';
  29. stxhr.get('<%=luci.dispatcher.build_url("freifunk", "status")%>/diag_' + tool + protocol + '/' + addr, null,
  30. function(x)
  31. {
  32. if (x.responseText)
  33. {
  34. legend.style.display = 'none';
  35. output.innerHTML = String.format('<pre>%h</pre>', x.responseText);
  36. }
  37. else
  38. {
  39. legend.style.display = 'none';
  40. output.innerHTML = '<span class="error"><%:Bad address specified!%></span>';
  41. }
  42. }
  43. );
  44. }
  45. }
  46. //]]></script>
  47. <form method="post" action="<%=pcdata(luci.http.getenv("REQUEST_URI"))%>">
  48. <div class="cbi-map">
  49. <h2><a id="content" name="content"><%:Diagnostics%></a></h2>
  50. <fieldset class="cbi-section">
  51. <legend><%:Network Utilities%></legend>
  52. <br />
  53. <div style="width:30%; float:left">
  54. <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="ping" /><br />
  55. <% if has_ping6 then %>
  56. <select name="ping_proto" style="width:auto">
  57. <option value="" selected="selected"><%:IPv4%></option>
  58. <option value="6"><%:IPv6%></option>
  59. </select>
  60. <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping, this.form.ping_proto.selectedIndex)" />
  61. <% else %>
  62. <input type="button" value="<%:Ping%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.ping)" />
  63. <% end %>
  64. </div>
  65. <div style="width:33%; float:left">
  66. <input style="margin: 5px 0" type="text" value="dev.openwrt.org" name="traceroute" /><br />
  67. <% if has_traceroute6 then %>
  68. <select name="traceroute_proto" style="width:auto">
  69. <option value="" selected="selected"><%:IPv4%></option>
  70. <option value="6"><%:IPv6%></option>
  71. </select>
  72. <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute, this.form.traceroute_proto.selectedIndex)" />
  73. <% else %>
  74. <input type="button" value="<%:Traceroute%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.traceroute)" />
  75. <% end %>
  76. <% if not has_traceroute6 then %>
  77. <p>&#160;</p>
  78. <p><%:Install iputils-traceroute6 for IPv6 traceroute%></p>
  79. <% end %>
  80. </div>
  81. <div style="width:33%; float:left;">
  82. <input style="margin: 5px 0" type="text" value="openwrt.org" name="nslookup" /><br />
  83. <input type="button" value="<%:Nslookup%>" class="cbi-button cbi-button-apply" onclick="update_status(this.form.nslookup)" />
  84. </div>
  85. <br style="clear:both" /><br />
  86. </fieldset>
  87. </div>
  88. <fieldset class="cbi-section" style="display:none">
  89. <legend id="diag-rc-legend"><%:Collecting data...%></legend>
  90. <span id="diag-rc-output"></span>
  91. </fieldset>
  92. </form>
  93. <%+footer%>