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.

134 lines
3.8 KiB

10 years ago
10 years ago
10 years ago
6 years ago
10 years ago
10 years ago
10 years ago
10 years ago
  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>Size</th>
  104. <th>Files</th>
  105. <th>Trash</th>
  106. <th>TTL</th>
  107. </tr>
  108. </thead>
  109. <tbody>
  110. {{ range .Volumes }}
  111. <tr>
  112. <td><code>{{ .Id }}</code></td>
  113. <td>{{ .Collection }}</td>
  114. <td>{{ .Size }} Bytes</td>
  115. <td>{{ .FileCount }}</td>
  116. <td>{{ .DeleteCount }} / {{.DeletedByteCount}} Bytes</td>
  117. <td>{{ .Ttl }}</td>
  118. </tr>
  119. {{ end }}
  120. </tbody>
  121. </table>
  122. </div>
  123. </div>
  124. </body>
  125. </html>
  126. `))