2015-03-19 17:39:22 +00:00
|
|
|
package weed_server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/http"
|
|
|
|
"path/filepath"
|
2015-03-22 19:50:04 +00:00
|
|
|
"time"
|
2015-03-19 17:39:22 +00:00
|
|
|
|
2018-10-24 06:59:49 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
2018-05-27 18:52:26 +00:00
|
|
|
ui "github.com/chrislusf/seaweedfs/weed/server/volume_server_ui"
|
2016-06-03 01:09:14 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/stats"
|
2019-12-03 07:23:54 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage"
|
2016-06-03 01:09:14 +00:00
|
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
2015-03-19 17:39:22 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
|
2020-09-20 23:00:01 +00:00
|
|
|
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
|
2015-03-19 17:39:22 +00:00
|
|
|
infos := make(map[string]interface{})
|
2015-03-22 19:50:04 +00:00
|
|
|
infos["Up Time"] = time.Now().Sub(startTime).String()
|
2018-10-16 05:25:28 +00:00
|
|
|
var ds []*volume_server_pb.DiskStatus
|
2015-03-19 17:39:22 +00:00
|
|
|
for _, loc := range vs.store.Locations {
|
|
|
|
if dir, e := filepath.Abs(loc.Directory); e == nil {
|
2020-12-14 08:51:57 +00:00
|
|
|
newDiskStatus := stats.NewDiskStatus(dir)
|
|
|
|
newDiskStatus.DiskType = loc.GetDiskType()
|
|
|
|
ds = append(ds, newDiskStatus)
|
2015-03-19 17:39:22 +00:00
|
|
|
}
|
|
|
|
}
|
2019-12-03 07:23:54 +00:00
|
|
|
volumeInfos := vs.store.VolumeInfos()
|
|
|
|
var normalVolumeInfos, remoteVolumeInfos []*storage.VolumeInfo
|
|
|
|
for _, vinfo := range volumeInfos {
|
2019-12-04 05:36:42 +00:00
|
|
|
if vinfo.IsRemote() {
|
2019-12-03 07:23:54 +00:00
|
|
|
remoteVolumeInfos = append(remoteVolumeInfos, vinfo)
|
2019-12-04 05:36:42 +00:00
|
|
|
} else {
|
|
|
|
normalVolumeInfos = append(normalVolumeInfos, vinfo)
|
2019-12-03 07:23:54 +00:00
|
|
|
}
|
|
|
|
}
|
2015-03-19 17:39:22 +00:00
|
|
|
args := struct {
|
2019-12-03 07:23:54 +00:00
|
|
|
Version string
|
|
|
|
Masters []string
|
|
|
|
Volumes interface{}
|
|
|
|
EcVolumes interface{}
|
|
|
|
RemoteVolumes interface{}
|
|
|
|
DiskStatuses interface{}
|
|
|
|
Stats interface{}
|
|
|
|
Counters *stats.ServerStats
|
2015-03-19 17:39:22 +00:00
|
|
|
}{
|
2020-06-02 07:10:35 +00:00
|
|
|
util.Version(),
|
2019-05-28 04:22:23 +00:00
|
|
|
vs.SeedMasterNodes,
|
2019-12-03 07:23:54 +00:00
|
|
|
normalVolumeInfos,
|
2019-06-05 04:52:37 +00:00
|
|
|
vs.store.EcVolumes(),
|
2019-12-03 07:23:54 +00:00
|
|
|
remoteVolumeInfos,
|
2015-03-19 17:39:22 +00:00
|
|
|
ds,
|
|
|
|
infos,
|
2015-03-22 19:50:04 +00:00
|
|
|
serverStats,
|
2015-03-19 17:39:22 +00:00
|
|
|
}
|
|
|
|
ui.StatusTpl.Execute(w, args)
|
|
|
|
}
|