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