https://github.com/bung87/psutil-nim/blob/master/src/psutil/psutil_macosx.nim
proc cpu_times*(): CPUTimes =
var count = HOST_CPU_LOAD_INFO_COUNT
let host_port = mach_host_self()
var r_load: host_cpu_load_info_data_t
let error = host_statistics(cint(host_port), HOST_CPU_LOAD_INFO, cast[
host_info_t](r_load.addr), count.addr)
if error != KERN_SUCCESS:
raise newException(OSError, "host_statistics(HOST_CPU_LOAD_INFO) syscall failed: $1" %
mach_error_string(error))
mach_port_deallocate(mach_task_self(), host_port)
result.user = r_load.cpu_ticks[CPU_STATE_USER].cdouble / CLK_TCK
result.nice = r_load.cpu_ticks[CPU_STATE_NICE].cdouble / CLK_TCK
result.system = r_load.cpu_ticks[CPU_STATE_SYSTEM].cdouble / CLK_TCK
result.idle = r_load.cpu_ticks[CPU_STATE_IDLE].cdouble / CLK_TCK
Seems like a pretty straightforward port, nothing looks wrong.
What's the error value that you're seeing from the host_statistics function? Can you
echo error
and see/show us what's printed?yeah, the Vmmeter declaration is very big , I found it from a freebsd code reviews https://reviews.freebsd.org/rS317061
host_statistics something wrong with it , I can't get output result from it.