chrislusf
10 years ago
7 changed files with 232 additions and 1 deletions
-
1go/weed/weed_server/master_server.go
-
26go/weed/weed_server/master_server_handlers_ui.go
-
90go/weed/weed_server/master_ui/templates.go
-
1go/weed/weed_server/volume_server.go
-
2go/weed/weed_server/volume_server_handlers_admin.go
-
35go/weed/weed_server/volume_server_handlers_ui.go
-
78go/weed/weed_server/volume_server_ui/templates.go
@ -0,0 +1,26 @@ |
|||
package weed_server |
|||
|
|||
import ( |
|||
"net/http" |
|||
|
|||
"github.com/chrislusf/weed-fs/go/util" |
|||
ui "github.com/chrislusf/weed-fs/go/weed/weed_server/master_ui" |
|||
) |
|||
|
|||
func (ms *MasterServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) { |
|||
stats := make(map[string]interface{}) |
|||
stats["Version"] = util.VERSION |
|||
args := struct { |
|||
Version string |
|||
Topology interface{} |
|||
Peers interface{} |
|||
Stats interface{} |
|||
}{ |
|||
util.VERSION, |
|||
ms.Topo.ToMap(), |
|||
ms.Topo.RaftServer.Peers(), |
|||
stats, |
|||
//serverStats,
|
|||
} |
|||
ui.StatusTpl.Execute(w, args) |
|||
} |
@ -0,0 +1,90 @@ |
|||
package master_ui |
|||
|
|||
import ( |
|||
"html/template" |
|||
) |
|||
|
|||
var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Seaweed File System {{ .Version }}</title> |
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> |
|||
</head> |
|||
<body> |
|||
<div class="container"> |
|||
<div class="page-header"> |
|||
<h1>Seaweed File System <small>{{ .Version }}</small></h1> |
|||
</div> |
|||
|
|||
<div class="row"> |
|||
<div class="col-sm-6"> |
|||
<h2>Cluster status</h2> |
|||
<table class="table"> |
|||
<tbody> |
|||
<tr> |
|||
<th>Free</th> |
|||
<td>{{ .Topology.Free }}</td> |
|||
</tr> |
|||
<tr> |
|||
<th>Max</th> |
|||
<td>{{ .Topology.Max }}</td> |
|||
</tr> |
|||
<tr> |
|||
<td class="col-sm-2 field-label"><label>Peers:</label></td> |
|||
<td class="col-sm-10"><ul class="list-unstyled"> |
|||
{{ range .Peers }} |
|||
<li><a href="https://{{ . }}">{{ . }}</a></li> |
|||
{{ end }} |
|||
</ul></td> |
|||
</tr> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="col-sm-6"> |
|||
<h2>System Stats</h2> |
|||
<table class="table table-condensed table-striped"> |
|||
{{ range $key, $val := .Stats }} |
|||
<tr> |
|||
<th>{{ $key }}</th> |
|||
<td>{{ $val }}</td> |
|||
</tr> |
|||
{{ end }} |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row"> |
|||
<h2>Topology</h2> |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Data Center</th> |
|||
<th>Rack</th> |
|||
<th>RemoteAddr</th> |
|||
<th>#Volumes</th> |
|||
<th>Max</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
{{ range $dc_index, $dc := .Topology.DataCenters }} |
|||
{{ range $rack_index, $rack := $dc.Racks }} |
|||
{{ range $dn_index, $dn := $rack.DataNodes }} |
|||
<tr> |
|||
<td><code>{{ $dc.Id }}</code></td> |
|||
<td>{{ $rack.Id }}</td> |
|||
<td><a href="http://{{ $dn.Url }}/ui/index.html">{{ $dn.Url }}</a></td> |
|||
<td>{{ $dn.Volumes }}</td> |
|||
<td>{{ $dn.Max }}</td> |
|||
</tr> |
|||
{{ end }} |
|||
{{ end }} |
|||
{{ end }} |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
</div> |
|||
</body> |
|||
</html> |
|||
`)) |
@ -0,0 +1,35 @@ |
|||
package weed_server |
|||
|
|||
import ( |
|||
"net/http" |
|||
"path/filepath" |
|||
|
|||
"github.com/chrislusf/weed-fs/go/stats" |
|||
"github.com/chrislusf/weed-fs/go/util" |
|||
ui "github.com/chrislusf/weed-fs/go/weed/weed_server/volume_server_ui" |
|||
) |
|||
|
|||
func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) { |
|||
infos := make(map[string]interface{}) |
|||
infos["Version"] = util.VERSION |
|||
var ds []*stats.DiskStatus |
|||
for _, loc := range vs.store.Locations { |
|||
if dir, e := filepath.Abs(loc.Directory); e == nil { |
|||
ds = append(ds, stats.NewDiskStatus(dir)) |
|||
} |
|||
} |
|||
args := struct { |
|||
Version string |
|||
Master string |
|||
Volumes interface{} |
|||
DiskStatuses interface{} |
|||
Stats interface{} |
|||
}{ |
|||
util.VERSION, |
|||
vs.masterNode, |
|||
vs.store.Status(), |
|||
ds, |
|||
infos, |
|||
} |
|||
ui.StatusTpl.Execute(w, args) |
|||
} |
@ -0,0 +1,78 @@ |
|||
package master_ui |
|||
|
|||
import ( |
|||
"html/template" |
|||
) |
|||
|
|||
var StatusTpl = template.Must(template.New("status").Parse(`<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<title>Seaweed File System {{ .Version }}</title> |
|||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"> |
|||
</head> |
|||
<body> |
|||
<div class="container"> |
|||
<div class="page-header"> |
|||
<h1>Seaweed File System <small>{{ .Version }}</small></h1> |
|||
</div> |
|||
|
|||
<div class="row"> |
|||
<div class="col-sm-6"> |
|||
<h2>Disk Stats</h2> |
|||
<table class="table table-condensed table-striped"> |
|||
{{ range .DiskStatuses }} |
|||
<tr> |
|||
<th>{{ .Dir }}</th> |
|||
<td>{{ .Free }}</td> |
|||
</tr> |
|||
{{ end }} |
|||
</table> |
|||
</div> |
|||
|
|||
<div class="col-sm-6"> |
|||
<h2>System Stats</h2> |
|||
<table class="table table-condensed table-striped"> |
|||
<tr> |
|||
<th>Master</th> |
|||
<td><a href="http://{{.Master}}/ui/index.html">{{.Master}}</a></td> |
|||
</tr> |
|||
{{ range $key, $val := .Stats }} |
|||
<tr> |
|||
<th>{{ $key }}</th> |
|||
<td>{{ $val }}</td> |
|||
</tr> |
|||
{{ end }} |
|||
</table> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row"> |
|||
<h2>Volumes</h2> |
|||
<table class="table table-striped"> |
|||
<thead> |
|||
<tr> |
|||
<th>Id</th> |
|||
<th>Size</th> |
|||
<th>Files</th> |
|||
<th>Trash</th> |
|||
<th>TTL</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
{{ range .Volumes }} |
|||
<tr> |
|||
<td><code>{{ .Id }}</code></td> |
|||
<td>{{ .Size }}</td> |
|||
<td>{{ .FileCount }}</td> |
|||
<td>{{ .DeleteCount }} / {{.DeletedByteCount}} Bytes</td> |
|||
<td>{{ .Ttl }}</td> |
|||
</tr> |
|||
{{ end }} |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
</div> |
|||
</body> |
|||
</html> |
|||
`)) |
Write
Preview
Loading…
Cancel
Save
Reference in new issue