mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-11-24 08:46:54 +08:00
move DiskStatus and MemStatus to protobuf
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user