diff options
| author | Chris Lu <chris.lu@gmail.com> | 2018-10-15 22:25:28 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2018-10-15 22:25:28 -0700 |
| commit | 46eb77f9bb629610fe90b8b9eb4d9fed2e6dda04 (patch) | |
| tree | d06c90b1460710e9b16e49b6b0b6825ec0ea9d1b /weed/stats | |
| parent | eec951cad2b276afb1a416152b049e380706ebed (diff) | |
| download | seaweedfs-46eb77f9bb629610fe90b8b9eb4d9fed2e6dda04.tar.xz seaweedfs-46eb77f9bb629610fe90b8b9eb4d9fed2e6dda04.zip | |
move DiskStatus and MemStatus to protobuf
Diffstat (limited to 'weed/stats')
| -rw-r--r-- | weed/stats/disk.go | 13 | ||||
| -rw-r--r-- | weed/stats/disk_notsupported.go | 4 | ||||
| -rw-r--r-- | weed/stats/disk_supported.go | 4 | ||||
| -rw-r--r-- | weed/stats/memory.go | 19 | ||||
| -rw-r--r-- | weed/stats/memory_notsupported.go | 4 | ||||
| -rw-r--r-- | weed/stats/memory_supported.go | 4 |
6 files changed, 21 insertions, 27 deletions
diff --git a/weed/stats/disk.go b/weed/stats/disk.go index 46d8c465e..e9d8baedd 100644 --- a/weed/stats/disk.go +++ b/weed/stats/disk.go @@ -1,14 +1,9 @@ package stats -type DiskStatus struct { - Dir string - All uint64 - Used uint64 - Free uint64 -} +import "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" -func NewDiskStatus(path string) (disk *DiskStatus) { - disk = &DiskStatus{Dir: path} - disk.fillInStatus() +func NewDiskStatus(path string) (disk *volume_server_pb.DiskStatus) { + disk = &volume_server_pb.DiskStatus{Dir: path} + fillInDiskStatus(disk) return } diff --git a/weed/stats/disk_notsupported.go b/weed/stats/disk_notsupported.go index e380d27ea..ace662f6a 100644 --- a/weed/stats/disk_notsupported.go +++ b/weed/stats/disk_notsupported.go @@ -2,6 +2,8 @@ package stats -func (disk *DiskStatus) fillInStatus() { +import "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" + +func fillInDiskStatus(status *volume_server_pb.DiskStatus) { return } diff --git a/weed/stats/disk_supported.go b/weed/stats/disk_supported.go index d68f0a32e..0537828b0 100644 --- a/weed/stats/disk_supported.go +++ b/weed/stats/disk_supported.go @@ -4,9 +4,11 @@ package stats import ( "syscall" + + "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" ) -func (disk *DiskStatus) fillInStatus() { +func fillInDiskStatus(disk *volume_server_pb.DiskStatus) { fs := syscall.Statfs_t{} err := syscall.Statfs(disk.Dir, &fs) if err != nil { diff --git a/weed/stats/memory.go b/weed/stats/memory.go index 0700d92de..52bbbe7af 100644 --- a/weed/stats/memory.go +++ b/weed/stats/memory.go @@ -2,27 +2,18 @@ package stats import ( "runtime" + "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" ) -type MemStatus struct { - Goroutines int - All uint64 - Used uint64 - Free uint64 - Self uint64 - Heap uint64 - Stack uint64 -} - -func MemStat() MemStatus { - mem := MemStatus{} - mem.Goroutines = runtime.NumGoroutine() +func MemStat() *volume_server_pb.MemStatus { + mem := &volume_server_pb.MemStatus{} + mem.Goroutines = int32(runtime.NumGoroutine()) memStat := new(runtime.MemStats) runtime.ReadMemStats(memStat) mem.Self = memStat.Alloc mem.Heap = memStat.HeapAlloc mem.Stack = memStat.StackInuse - mem.fillInStatus() + fillInMemStatus(mem) return mem } diff --git a/weed/stats/memory_notsupported.go b/weed/stats/memory_notsupported.go index ba8229364..2bed95266 100644 --- a/weed/stats/memory_notsupported.go +++ b/weed/stats/memory_notsupported.go @@ -2,6 +2,8 @@ package stats -func (mem *MemStatus) fillInStatus() { +import "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" + +func fillInMemStatus(status *volume_server_pb.MemStatus) { return } diff --git a/weed/stats/memory_supported.go b/weed/stats/memory_supported.go index fd0c36d72..91fdd005b 100644 --- a/weed/stats/memory_supported.go +++ b/weed/stats/memory_supported.go @@ -4,9 +4,11 @@ package stats import ( "syscall" + + "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb" ) -func (mem *MemStatus) fillInStatus() { +func fillInMemStatus(mem *volume_server_pb.MemStatus) { //system memory usage sysInfo := new(syscall.Sysinfo_t) err := syscall.Sysinfo(sysInfo) |
