update to host_statistics64 for Darwin meminfo (#1183)
Signed-off-by: tariqibrahim <tariq181290@gmail.com>
This commit is contained in:
parent
f9dd8e9b8c
commit
6bd51269b7
|
@ -21,18 +21,18 @@ import "C"
|
||||||
import (
|
import (
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
"fmt"
|
"fmt"
|
||||||
"syscall"
|
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
"golang.org/x/sys/unix"
|
"golang.org/x/sys/unix"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
|
func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
|
||||||
infoCount := C.mach_msg_type_number_t(C.HOST_VM_INFO_COUNT)
|
host := C.mach_host_self()
|
||||||
vmstat := C.vm_statistics_data_t{}
|
infoCount := C.mach_msg_type_number_t(C.HOST_VM_INFO64_COUNT)
|
||||||
ret := C.host_statistics(
|
vmstat := C.vm_statistics64_data_t{}
|
||||||
C.host_t(C.mach_host_self()),
|
ret := C.host_statistics64(
|
||||||
C.HOST_VM_INFO,
|
C.host_t(host),
|
||||||
|
C.HOST_VM_INFO64,
|
||||||
C.host_info_t(unsafe.Pointer(&vmstat)),
|
C.host_info_t(unsafe.Pointer(&vmstat)),
|
||||||
&infoCount,
|
&infoCount,
|
||||||
)
|
)
|
||||||
|
@ -46,9 +46,13 @@ func (c *meminfoCollector) getMemInfo() (map[string]float64, error) {
|
||||||
// Syscall removes terminating NUL which we need to cast to uint64
|
// Syscall removes terminating NUL which we need to cast to uint64
|
||||||
total := binary.LittleEndian.Uint64([]byte(totalb + "\x00"))
|
total := binary.LittleEndian.Uint64([]byte(totalb + "\x00"))
|
||||||
|
|
||||||
ps := float64(C.natural_t(syscall.Getpagesize()))
|
var pageSize C.vm_size_t
|
||||||
|
C.host_page_size(C.host_t(host), &pageSize)
|
||||||
|
|
||||||
|
ps := float64(pageSize)
|
||||||
return map[string]float64{
|
return map[string]float64{
|
||||||
"active_bytes": ps * float64(vmstat.active_count),
|
"active_bytes": ps * float64(vmstat.active_count),
|
||||||
|
"compressed_bytes": ps * float64(vmstat.compressor_page_count),
|
||||||
"inactive_bytes": ps * float64(vmstat.inactive_count),
|
"inactive_bytes": ps * float64(vmstat.inactive_count),
|
||||||
"wired_bytes": ps * float64(vmstat.wire_count),
|
"wired_bytes": ps * float64(vmstat.wire_count),
|
||||||
"free_bytes": ps * float64(vmstat.free_count),
|
"free_bytes": ps * float64(vmstat.free_count),
|
||||||
|
|
Loading…
Reference in New Issue