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.

216 lines
6.3 KiB

10 years ago
10 years ago
10 years ago
10 years ago
6 years ago
5 years ago
5 years ago
10 years ago
10 years ago
10 years ago
  1. package volume_server_ui
  2. import (
  3. "fmt"
  4. "github.com/chrislusf/seaweedfs/weed/util"
  5. "html/template"
  6. "strconv"
  7. "strings"
  8. )
  9. func percentFrom(total uint64, part_of uint64) string {
  10. return fmt.Sprintf("%.2f", (float64(part_of)/float64(total))*100)
  11. }
  12. func join(data []int64) string {
  13. var ret []string
  14. for _, d := range data {
  15. ret = append(ret, strconv.Itoa(int(d)))
  16. }
  17. return strings.Join(ret, ",")
  18. }
  19. var funcMap = template.FuncMap{
  20. "join": join,
  21. "bytesToHumanReadable": util.BytesToHumanReadable,
  22. "percentFrom": percentFrom,
  23. }
  24. var StatusTpl = template.Must(template.New("status").Funcs(funcMap).Parse(`<!DOCTYPE html>
  25. <html>
  26. <head>
  27. <title>SeaweedFS {{ .Version }}</title>
  28. <link rel="stylesheet" href="/seaweedfsstatic/bootstrap/3.3.1/css/bootstrap.min.css">
  29. <script type="text/javascript" src="/seaweedfsstatic/javascript/jquery-2.1.3.min.js"></script>
  30. <script type="text/javascript" src="/seaweedfsstatic/javascript/jquery-sparklines/2.1.2/jquery.sparkline.min.js"></script>
  31. <script type="text/javascript">
  32. $(function() {
  33. var periods = ['second', 'minute', 'hour', 'day'];
  34. for (i = 0; i < periods.length; i++) {
  35. var period = periods[i];
  36. $('.inlinesparkline-'+period).sparkline('html', {
  37. type: 'line',
  38. barColor: 'red',
  39. tooltipSuffix:' request per '+period,
  40. });
  41. }
  42. });
  43. </script>
  44. <style>
  45. #jqstooltip{
  46. height: 28px !important;
  47. width: 150px !important;
  48. }
  49. </style>
  50. </head>
  51. <body>
  52. <div class="container">
  53. <div class="page-header">
  54. <h1>
  55. <a href="https://github.com/chrislusf/seaweedfs"><img src="/seaweedfsstatic/seaweed50x50.png"></img></a>
  56. SeaweedFS <small>{{ .Version }}</small>
  57. </h1>
  58. </div>
  59. <div class="row">
  60. <div class="col-sm-6">
  61. <h2>Disk Stats</h2>
  62. <table class="table table-striped">
  63. <thead>
  64. <tr>
  65. <th>Path</th>
  66. <th>Disk</th>
  67. <th>Total</th>
  68. <th>Free</th>
  69. <th>Usage</th>
  70. </tr>
  71. </thead>
  72. <tbody>
  73. {{ range .DiskStatuses }}
  74. <tr>
  75. <td>{{ .Dir }}</td>
  76. <td>{{ .DiskType }}</td>
  77. <td>{{ bytesToHumanReadable .All }}</td>
  78. <td>{{ bytesToHumanReadable .Free }}</td>
  79. <td>{{ percentFrom .All .Used}}%</td>
  80. </tr>
  81. {{ end }}
  82. </tbody>
  83. </table>
  84. </div>
  85. <div class="col-sm-6">
  86. <h2>System Stats</h2>
  87. <table class="table table-condensed table-striped">
  88. <tr>
  89. <th>Masters</th>
  90. <td>{{.Masters}}</td>
  91. </tr>
  92. <tr>
  93. <th>Weekly # ReadRequests</th>
  94. <td><span class="inlinesparkline-day">{{ .Counters.ReadRequests.WeekCounter.ToList | join }}</span></td>
  95. </tr>
  96. <tr>
  97. <th>Daily # ReadRequests</th>
  98. <td><span class="inlinesparkline-hour">{{ .Counters.ReadRequests.DayCounter.ToList | join }}</span></td>
  99. </tr>
  100. <tr>
  101. <th>Hourly # ReadRequests</th>
  102. <td><span class="inlinesparkline-minute">{{ .Counters.ReadRequests.HourCounter.ToList | join }}</span></td>
  103. </tr>
  104. <tr>
  105. <th>Last Minute # ReadRequests</th>
  106. <td><span class="inlinesparkline-second">{{ .Counters.ReadRequests.MinuteCounter.ToList | join }}</span></td>
  107. </tr>
  108. {{ range $key, $val := .Stats }}
  109. <tr>
  110. <th>{{ $key }}</th>
  111. <td>{{ $val }}</td>
  112. </tr>
  113. {{ end }}
  114. </table>
  115. </div>
  116. </div>
  117. <div class="row">
  118. <h2>Volumes</h2>
  119. <table class="table table-striped">
  120. <thead>
  121. <tr>
  122. <th>Id</th>
  123. <th>Collection</th>
  124. <th>Disk</th>
  125. <th>Data Size</th>
  126. <th>Files</th>
  127. <th>Trash</th>
  128. <th>TTL</th>
  129. <th>ReadOnly</th>
  130. </tr>
  131. </thead>
  132. <tbody>
  133. {{ range .Volumes }}
  134. <tr>
  135. <td><code>{{ .Id }}</code></td>
  136. <td>{{ .Collection }}</td>
  137. <td>{{ .DiskType }}</td>
  138. <td>{{ bytesToHumanReadable .Size }}</td>
  139. <td>{{ .FileCount }}</td>
  140. <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td>
  141. <td>{{ .Ttl }}</td>
  142. <td>{{ .ReadOnly }}</td>
  143. </tr>
  144. {{ end }}
  145. </tbody>
  146. </table>
  147. </div>
  148. <div class="row">
  149. <h2>Remote Volumes</h2>
  150. <table class="table table-striped">
  151. <thead>
  152. <tr>
  153. <th>Id</th>
  154. <th>Collection</th>
  155. <th>Size</th>
  156. <th>Files</th>
  157. <th>Trash</th>
  158. <th>Remote</th>
  159. <th>Key</th>
  160. </tr>
  161. </thead>
  162. <tbody>
  163. {{ range .RemoteVolumes }}
  164. <tr>
  165. <td><code>{{ .Id }}</code></td>
  166. <td>{{ .Collection }}</td>
  167. <td>{{ bytesToHumanReadable .Size }}</td>
  168. <td>{{ .FileCount }}</td>
  169. <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td>
  170. <td>{{ .RemoteStorageName }}</td>
  171. <td>{{ .RemoteStorageKey }}</td>
  172. </tr>
  173. {{ end }}
  174. </tbody>
  175. </table>
  176. </div>
  177. <div class="row">
  178. <h2>Erasure Coding Shards</h2>
  179. <table class="table table-striped">
  180. <thead>
  181. <tr>
  182. <th>Id</th>
  183. <th>Collection</th>
  184. <th>Shard Size</th>
  185. <th>Shards</th>
  186. <th>CreatedAt</th>
  187. </tr>
  188. </thead>
  189. <tbody>
  190. {{ range .EcVolumes }}
  191. <tr>
  192. <td><code>{{ .VolumeId }}</code></td>
  193. <td>{{ .Collection }}</td>
  194. <td>{{ bytesToHumanReadable .ShardSize }}</td>
  195. <td>{{ .ShardIdList }}</td>
  196. <td>{{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}</td>
  197. </tr>
  198. {{ end }}
  199. </tbody>
  200. </table>
  201. </div>
  202. </div>
  203. </body>
  204. </html>
  205. `))