volume_server_handlers_ui.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. infos := make(map[string]interface{})
  14. infos["Up Time"] = time.Now().Sub(startTime).String()
  15. var ds []*volume_server_pb.DiskStatus
  16. for _, loc := range vs.store.Locations {
  17. if dir, e := filepath.Abs(loc.Directory); e == nil {
  18. ds = append(ds, stats.NewDiskStatus(dir))
  19. }
  20. }
  21. volumeInfos := vs.store.VolumeInfos()
  22. var normalVolumeInfos, remoteVolumeInfos []*storage.VolumeInfo
  23. for _, vinfo := range volumeInfos {
  24. if vinfo.IsRemote() {
  25. remoteVolumeInfos = append(remoteVolumeInfos, vinfo)
  26. } else {
  27. normalVolumeInfos = append(normalVolumeInfos, vinfo)
  28. }
  29. }
  30. args := struct {
  31. Version string
  32. Masters []string
  33. Volumes interface{}
  34. EcVolumes interface{}
  35. RemoteVolumes interface{}
  36. DiskStatuses interface{}
  37. Stats interface{}
  38. Counters *stats.ServerStats
  39. }{
  40. util.VERSION,
  41. vs.SeedMasterNodes,
  42. normalVolumeInfos,
  43. vs.store.EcVolumes(),
  44. remoteVolumeInfos,
  45. ds,
  46. infos,
  47. serverStats,
  48. }
  49. ui.StatusTpl.Execute(w, args)
  50. }