mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
Issue 65: weed-fs 0.51 does not compile under windows
This commit is contained in:
parent
59f6a13609
commit
25a3c47def
|
@ -1,10 +1,6 @@
|
|||
// +build !windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
import ()
|
||||
|
||||
type DiskStatus struct {
|
||||
Dir string
|
||||
|
@ -15,13 +11,6 @@ type DiskStatus struct {
|
|||
|
||||
func NewDiskStatus(path string) (disk *DiskStatus) {
|
||||
disk = &DiskStatus{Dir: path}
|
||||
fs := syscall.Statfs_t{}
|
||||
err := syscall.Statfs(path, &fs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
disk.All = fs.Blocks * uint64(fs.Bsize)
|
||||
disk.Free = fs.Bfree * uint64(fs.Bsize)
|
||||
disk.Used = disk.All - disk.Free
|
||||
disk.fillInStatus()
|
||||
return
|
||||
}
|
||||
|
|
9
go/stats/disk_notsupported.go
Normal file
9
go/stats/disk_notsupported.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
// +build windows openbsd netbsd plan9
|
||||
|
||||
package stats
|
||||
|
||||
import ()
|
||||
|
||||
func (disk *DiskStatus) fillInStatus() {
|
||||
return
|
||||
}
|
19
go/stats/disk_supported.go
Normal file
19
go/stats/disk_supported.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
// +build !windows,!openbsd,!netbsd,!plan9
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (disk *DiskStatus) fillInStatus() {
|
||||
fs := syscall.Statfs_t{}
|
||||
err := syscall.Statfs(disk.Dir, &fs)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
disk.All = fs.Blocks * uint64(fs.Bsize)
|
||||
disk.Free = fs.Bfree * uint64(fs.Bsize)
|
||||
disk.Used = disk.All - disk.Free
|
||||
return
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type DiskStatus struct {
|
||||
Dir string
|
||||
All uint64
|
||||
Used uint64
|
||||
Free uint64
|
||||
}
|
||||
|
||||
func NewDiskStatus(path string) (disk *DiskStatus) {
|
||||
return
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
// +build !windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type MemStatus struct {
|
||||
|
@ -26,13 +23,6 @@ func MemStat() MemStatus {
|
|||
mem.Heap = memStat.HeapAlloc
|
||||
mem.Stack = memStat.StackInuse
|
||||
|
||||
//system memory usage
|
||||
sysInfo := new(syscall.Sysinfo_t)
|
||||
err := syscall.Sysinfo(sysInfo)
|
||||
if err == nil {
|
||||
mem.All = sysInfo.Totalram //* uint64(syscall.Getpagesize())
|
||||
mem.Free = sysInfo.Freeram //* uint64(syscall.Getpagesize())
|
||||
mem.Used = mem.All - mem.Free
|
||||
}
|
||||
mem.fillInStatus()
|
||||
return mem
|
||||
}
|
||||
|
|
9
go/stats/memory_notsupported.go
Normal file
9
go/stats/memory_notsupported.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
// +build !linux
|
||||
|
||||
package stats
|
||||
|
||||
import ()
|
||||
|
||||
func (mem *MemStatus) fillInStatus() {
|
||||
return
|
||||
}
|
18
go/stats/memory_supported.go
Normal file
18
go/stats/memory_supported.go
Normal file
|
@ -0,0 +1,18 @@
|
|||
// +build linux
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"syscall"
|
||||
)
|
||||
|
||||
func (mem *MemStatus) fillInStatus() {
|
||||
//system memory usage
|
||||
sysInfo := new(syscall.Sysinfo_t)
|
||||
err := syscall.Sysinfo(sysInfo)
|
||||
if err == nil {
|
||||
mem.All = uint64(sysInfo.Totalram) //* uint64(syscall.Getpagesize())
|
||||
mem.Free = uint64(sysInfo.Freeram) //* uint64(syscall.Getpagesize())
|
||||
mem.Used = mem.All - mem.Free
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
// +build windows
|
||||
|
||||
package stats
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type MemStatus struct {
|
||||
Goroutines uint32
|
||||
All uint32
|
||||
Used uint32
|
||||
Free uint32
|
||||
Self uint64
|
||||
Heap uint64
|
||||
Stack uint64
|
||||
}
|
||||
|
||||
func MemStat() MemStatus {
|
||||
memStat := new(runtime.MemStats)
|
||||
mem.Goroutines = runtime.NumGoroutine()
|
||||
runtime.ReadMemStats(memStat)
|
||||
mem := MemStatus{}
|
||||
mem.Self = memStat.Alloc
|
||||
mem.Heap = memStat.HeapAlloc
|
||||
mem.Stack = memStat.StackInuse
|
||||
|
||||
return mem
|
||||
}
|
Loading…
Reference in a new issue