diff --git a/go/weed/weed_server/master_server.go b/go/weed/weed_server/master_server.go index dc79c733a..a89fca701 100644 --- a/go/weed/weed_server/master_server.go +++ b/go/weed/weed_server/master_server.go @@ -60,6 +60,7 @@ func NewMasterServer(r *mux.Router, port int, metaFolder string, ms.guard = security.NewGuard(whiteList, secureKey) + r.HandleFunc("/ui/index.html", ms.uiStatusHandler) r.HandleFunc("/dir/assign", ms.proxyToLeader(ms.guard.WhiteList(ms.dirAssignHandler))) r.HandleFunc("/dir/lookup", ms.proxyToLeader(ms.guard.WhiteList(ms.dirLookupHandler))) r.HandleFunc("/dir/join", ms.proxyToLeader(ms.guard.WhiteList(ms.dirJoinHandler))) diff --git a/go/weed/weed_server/master_server_handlers_ui.go b/go/weed/weed_server/master_server_handlers_ui.go new file mode 100644 index 000000000..3ba4bb053 --- /dev/null +++ b/go/weed/weed_server/master_server_handlers_ui.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) +} diff --git a/go/weed/weed_server/master_ui/templates.go b/go/weed/weed_server/master_ui/templates.go new file mode 100644 index 000000000..d292952aa --- /dev/null +++ b/go/weed/weed_server/master_ui/templates.go @@ -0,0 +1,90 @@ +package master_ui + +import ( + "html/template" +) + +var StatusTpl = template.Must(template.New("status").Parse(` + + + Seaweed File System {{ .Version }} + + + +
+ + +
+
+

Cluster status

+ + + + + + + + + + + + + + + +
Free{{ .Topology.Free }}
Max{{ .Topology.Max }}
    + {{ range .Peers }} +
  • {{ . }}
  • + {{ end }} +
+
+ +
+

System Stats

+ + {{ range $key, $val := .Stats }} + + + + + {{ end }} +
{{ $key }}{{ $val }}
+
+
+ +
+

Topology

+ + + + + + + + + + + + {{ range $dc_index, $dc := .Topology.DataCenters }} + {{ range $rack_index, $rack := $dc.Racks }} + {{ range $dn_index, $dn := $rack.DataNodes }} + + + + + + + + {{ end }} + {{ end }} + {{ end }} + +
Data CenterRackRemoteAddr#VolumesMax
{{ $dc.Id }}{{ $rack.Id }}{{ $dn.Url }}{{ $dn.Volumes }}{{ $dn.Max }}
+
+ +
+ + +`)) diff --git a/go/weed/weed_server/volume_server.go b/go/weed/weed_server/volume_server.go index f93ef6fa7..e3878fac4 100644 --- a/go/weed/weed_server/volume_server.go +++ b/go/weed/weed_server/volume_server.go @@ -41,6 +41,7 @@ func NewVolumeServer(adminMux, publicMux *http.ServeMux, ip string, vs.guard = security.NewGuard(whiteList, "") + adminMux.HandleFunc("/ui/index.html", vs.uiStatusHandler) adminMux.HandleFunc("/status", vs.guard.WhiteList(vs.statusHandler)) adminMux.HandleFunc("/admin/assign_volume", vs.guard.WhiteList(vs.assignVolumeHandler)) adminMux.HandleFunc("/admin/vacuum_volume_check", vs.guard.WhiteList(vs.vacuumVolumeCheckHandler)) diff --git a/go/weed/weed_server/volume_server_handlers_admin.go b/go/weed/weed_server/volume_server_handlers_admin.go index 5ffa24bdc..c84b72db0 100644 --- a/go/weed/weed_server/volume_server_handlers_admin.go +++ b/go/weed/weed_server/volume_server_handlers_admin.go @@ -60,6 +60,6 @@ func (vs *VolumeServer) statsDiskHandler(w http.ResponseWriter, r *http.Request) ds = append(ds, stats.NewDiskStatus(dir)) } } - m["DiskStatues"] = ds + m["DiskStatuses"] = ds writeJsonQuiet(w, r, http.StatusOK, m) } diff --git a/go/weed/weed_server/volume_server_handlers_ui.go b/go/weed/weed_server/volume_server_handlers_ui.go new file mode 100644 index 000000000..b033173bb --- /dev/null +++ b/go/weed/weed_server/volume_server_handlers_ui.go @@ -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) +} diff --git a/go/weed/weed_server/volume_server_ui/templates.go b/go/weed/weed_server/volume_server_ui/templates.go new file mode 100644 index 000000000..98e91bd25 --- /dev/null +++ b/go/weed/weed_server/volume_server_ui/templates.go @@ -0,0 +1,78 @@ +package master_ui + +import ( + "html/template" +) + +var StatusTpl = template.Must(template.New("status").Parse(` + + + Seaweed File System {{ .Version }} + + + +
+ + +
+
+

Disk Stats

+ + {{ range .DiskStatuses }} + + + + + {{ end }} +
{{ .Dir }}{{ .Free }}
+
+ +
+

System Stats

+ + + + + + {{ range $key, $val := .Stats }} + + + + + {{ end }} +
Master{{.Master}}
{{ $key }}{{ $val }}
+
+
+ +
+

Volumes

+ + + + + + + + + + + + {{ range .Volumes }} + + + + + + + + {{ end }} + +
IdSizeFilesTrashTTL
{{ .Id }}{{ .Size }}{{ .FileCount }}{{ .DeleteCount }} / {{.DeletedByteCount}} Bytes{{ .Ttl }}
+
+ +
+ + +`))