mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Merge pull request #1207 from LazyDBA247-Anyvision/update-stats-and-status-volume-server
Update stats and status volume server
This commit is contained in:
commit
346a1cf0b9
|
@ -1505,10 +1505,12 @@ func (m *ReadVolumeFileStatusResponse) GetCollection() string {
|
|||
}
|
||||
|
||||
type DiskStatus struct {
|
||||
Dir string `protobuf:"bytes,1,opt,name=dir" json:"dir,omitempty"`
|
||||
All uint64 `protobuf:"varint,2,opt,name=all" json:"all,omitempty"`
|
||||
Used uint64 `protobuf:"varint,3,opt,name=used" json:"used,omitempty"`
|
||||
Free uint64 `protobuf:"varint,4,opt,name=free" json:"free,omitempty"`
|
||||
Dir string `protobuf:"bytes,1,opt,name=dir" json:"dir,omitempty"`
|
||||
All uint64 `protobuf:"varint,2,opt,name=all" json:"all,omitempty"`
|
||||
Used uint64 `protobuf:"varint,3,opt,name=used" json:"used,omitempty"`
|
||||
Free uint64 `protobuf:"varint,4,opt,name=free" json:"free,omitempty"`
|
||||
PercentFree float32 `protobuf:"fixed32,5,opt,name=percentFree" json:"percentFree,omitempty"`
|
||||
PercentUsed float32 `protobuf:"fixed32,6,opt,name=percentUsed" json:"percentUsed,omitempty"`
|
||||
}
|
||||
|
||||
func (m *DiskStatus) Reset() { *m = DiskStatus{} }
|
||||
|
@ -1544,6 +1546,20 @@ func (m *DiskStatus) GetFree() uint64 {
|
|||
return 0
|
||||
}
|
||||
|
||||
func (m *DiskStatus) GetPercentFree() float32 {
|
||||
if m != nil {
|
||||
return m.PercentFree
|
||||
}
|
||||
return float32(0.0)
|
||||
}
|
||||
|
||||
func (m *DiskStatus) GetPercentUsed() float32 {
|
||||
if m != nil {
|
||||
return m.PercentUsed
|
||||
}
|
||||
return float32(0.0)
|
||||
}
|
||||
|
||||
type MemStatus struct {
|
||||
Goroutines int32 `protobuf:"varint,1,opt,name=goroutines" json:"goroutines,omitempty"`
|
||||
All uint64 `protobuf:"varint,2,opt,name=all" json:"all,omitempty"`
|
||||
|
|
|
@ -12,6 +12,13 @@ import (
|
|||
func (vs *VolumeServer) statusHandler(w http.ResponseWriter, r *http.Request) {
|
||||
m := make(map[string]interface{})
|
||||
m["Version"] = util.VERSION
|
||||
var ds []*volume_server_pb.DiskStatus
|
||||
for _, loc := range vs.store.Locations {
|
||||
if dir, e := filepath.Abs(loc.Directory); e == nil {
|
||||
ds = append(ds, stats.NewDiskStatus(dir))
|
||||
}
|
||||
}
|
||||
m["DiskStatuses"] = ds
|
||||
m["Volumes"] = vs.store.VolumeInfos()
|
||||
writeJsonQuiet(w, r, http.StatusOK, m)
|
||||
}
|
||||
|
|
|
@ -17,5 +17,7 @@ func fillInDiskStatus(disk *volume_server_pb.DiskStatus) {
|
|||
disk.All = fs.Blocks * uint64(fs.Bsize)
|
||||
disk.Free = fs.Bfree * uint64(fs.Bsize)
|
||||
disk.Used = disk.All - disk.Free
|
||||
disk.PercentFree = float32((float64(disk.Free) / float64(disk.All)) * 100)
|
||||
disk.PercentUsed = float32((float64(disk.Used) / float64(disk.All)) * 100)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue