templates.go 5.4 KB

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