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.

212 lines
6.1 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 master_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>Total</th>
  67. <th>Free</th>
  68. <th>Usage</th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. {{ range .DiskStatuses }}
  73. <tr>
  74. <td>{{ .Dir }}</td>
  75. <td>{{ bytesToHumanReadable .All }}</td>
  76. <td>{{ bytesToHumanReadable .Free }}</td>
  77. <td>{{ percentFrom .All .Used}}%</td>
  78. </tr>
  79. {{ end }}
  80. </tbody>
  81. </table>
  82. </div>
  83. <div class="col-sm-6">
  84. <h2>System Stats</h2>
  85. <table class="table table-condensed table-striped">
  86. <tr>
  87. <th>Masters</th>
  88. <td>{{.Masters}}</td>
  89. </tr>
  90. <tr>
  91. <th>Weekly # ReadRequests</th>
  92. <td><span class="inlinesparkline-day">{{ .Counters.ReadRequests.WeekCounter.ToList | join }}</span></td>
  93. </tr>
  94. <tr>
  95. <th>Daily # ReadRequests</th>
  96. <td><span class="inlinesparkline-hour">{{ .Counters.ReadRequests.DayCounter.ToList | join }}</span></td>
  97. </tr>
  98. <tr>
  99. <th>Hourly # ReadRequests</th>
  100. <td><span class="inlinesparkline-minute">{{ .Counters.ReadRequests.HourCounter.ToList | join }}</span></td>
  101. </tr>
  102. <tr>
  103. <th>Last Minute # ReadRequests</th>
  104. <td><span class="inlinesparkline-second">{{ .Counters.ReadRequests.MinuteCounter.ToList | join }}</span></td>
  105. </tr>
  106. {{ range $key, $val := .Stats }}
  107. <tr>
  108. <th>{{ $key }}</th>
  109. <td>{{ $val }}</td>
  110. </tr>
  111. {{ end }}
  112. </table>
  113. </div>
  114. </div>
  115. <div class="row">
  116. <h2>Volumes</h2>
  117. <table class="table table-striped">
  118. <thead>
  119. <tr>
  120. <th>Id</th>
  121. <th>Collection</th>
  122. <th>Data Size</th>
  123. <th>Files</th>
  124. <th>Trash</th>
  125. <th>TTL</th>
  126. <th>ReadOnly</th>
  127. </tr>
  128. </thead>
  129. <tbody>
  130. {{ range .Volumes }}
  131. <tr>
  132. <td><code>{{ .Id }}</code></td>
  133. <td>{{ .Collection }}</td>
  134. <td>{{ bytesToHumanReadable .Size }}</td>
  135. <td>{{ .FileCount }}</td>
  136. <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td>
  137. <td>{{ .Ttl }}</td>
  138. <td>{{ .ReadOnly }}</td>
  139. </tr>
  140. {{ end }}
  141. </tbody>
  142. </table>
  143. </div>
  144. <div class="row">
  145. <h2>Remote Volumes</h2>
  146. <table class="table table-striped">
  147. <thead>
  148. <tr>
  149. <th>Id</th>
  150. <th>Collection</th>
  151. <th>Size</th>
  152. <th>Files</th>
  153. <th>Trash</th>
  154. <th>Remote</th>
  155. <th>Key</th>
  156. </tr>
  157. </thead>
  158. <tbody>
  159. {{ range .RemoteVolumes }}
  160. <tr>
  161. <td><code>{{ .Id }}</code></td>
  162. <td>{{ .Collection }}</td>
  163. <td>{{ bytesToHumanReadable .Size }}</td>
  164. <td>{{ .FileCount }}</td>
  165. <td>{{ .DeleteCount }} / {{bytesToHumanReadable .DeletedByteCount}}</td>
  166. <td>{{ .RemoteStorageName }}</td>
  167. <td>{{ .RemoteStorageKey }}</td>
  168. </tr>
  169. {{ end }}
  170. </tbody>
  171. </table>
  172. </div>
  173. <div class="row">
  174. <h2>Erasure Coding Shards</h2>
  175. <table class="table table-striped">
  176. <thead>
  177. <tr>
  178. <th>Id</th>
  179. <th>Collection</th>
  180. <th>Shard Size</th>
  181. <th>Shards</th>
  182. <th>CreatedAt</th>
  183. </tr>
  184. </thead>
  185. <tbody>
  186. {{ range .EcVolumes }}
  187. <tr>
  188. <td><code>{{ .VolumeId }}</code></td>
  189. <td>{{ .Collection }}</td>
  190. <td>{{ bytesToHumanReadable .ShardSize }}</td>
  191. <td>{{ .ShardIdList }}</td>
  192. <td>{{ .CreatedAt.Format "02 Jan 06 15:04 -0700" }}</td>
  193. </tr>
  194. {{ end }}
  195. </tbody>
  196. </table>
  197. </div>
  198. </div>
  199. </body>
  200. </html>
  201. `))