github.com/lulzWill/go-agent@v2.1.2+incompatible/internal/sysinfo/memtotal_solaris.go (about) 1 package sysinfo 2 3 /* 4 #include <unistd.h> 5 */ 6 import "C" 7 8 // PhysicalMemoryBytes returns the total amount of host memory. 9 func PhysicalMemoryBytes() (uint64, error) { 10 // The function we're calling on Solaris is 11 // long sysconf(int name); 12 var pages C.long 13 var pagesizeBytes C.long 14 var err error 15 16 pagesizeBytes, err = C.sysconf(C._SC_PAGE_SIZE) 17 if pagesizeBytes < 1 { 18 return 0, err 19 } 20 pages, err = C.sysconf(C._SC_PHYS_PAGES) 21 if pages < 1 { 22 return 0, err 23 } 24 25 return uint64(pages) * uint64(pagesizeBytes), nil 26 }