volume_server_handlers_ui.go 1.6 KB

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