volume_server_handlers_ui.go 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package weed_server
  2. import (
  3. "net/http"
  4. "path/filepath"
  5. "time"
  6. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  7. ui "github.com/chrislusf/seaweedfs/weed/server/volume_server_ui"
  8. "github.com/chrislusf/seaweedfs/weed/stats"
  9. "github.com/chrislusf/seaweedfs/weed/storage"
  10. "github.com/chrislusf/seaweedfs/weed/util"
  11. )
  12. func (vs *VolumeServer) uiStatusHandler(w http.ResponseWriter, r *http.Request) {
  13. w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
  14. infos := make(map[string]interface{})
  15. infos["Up Time"] = time.Now().Sub(startTime).String()
  16. var ds []*volume_server_pb.DiskStatus
  17. for _, loc := range vs.store.Locations {
  18. if dir, e := filepath.Abs(loc.Directory); e == nil {
  19. ds = append(ds, stats.NewDiskStatus(dir))
  20. }
  21. }
  22. volumeInfos := vs.store.VolumeInfos()
  23. var normalVolumeInfos, remoteVolumeInfos []*storage.VolumeInfo
  24. for _, vinfo := range volumeInfos {
  25. if vinfo.IsRemote() {
  26. remoteVolumeInfos = append(remoteVolumeInfos, vinfo)
  27. } else {
  28. normalVolumeInfos = append(normalVolumeInfos, vinfo)
  29. }
  30. }
  31. args := struct {
  32. Version string
  33. Masters []string
  34. Volumes interface{}
  35. EcVolumes interface{}
  36. RemoteVolumes interface{}
  37. DiskStatuses interface{}
  38. Stats interface{}
  39. Counters *stats.ServerStats
  40. }{
  41. util.Version(),
  42. vs.SeedMasterNodes,
  43. normalVolumeInfos,
  44. vs.store.EcVolumes(),
  45. remoteVolumeInfos,
  46. ds,
  47. infos,
  48. serverStats,
  49. }
  50. ui.StatusTpl.Execute(w, args)
  51. }