25 #ifndef CASA_HOSTINFOIRIX_H
26 #define CASA_HOSTINFOIRIX_H
28 # if defined(HOSTINFO_DO_IMPLEMENT)
41 #include <sys/types.h>
45 #include <sys/sysmp.h>
46 #include <sys/sysinfo.h>
70 #define pagetok(pages) ((((uint64_t) pages) * pagesize) >> 10)
72 class HostMachineInfo {
73 friend class HostInfo;
85 ptrdiff_t memory_total;
86 ptrdiff_t memory_used;
87 ptrdiff_t memory_free;
96 HostMachineInfo::HostMachineInfo( ) : valid(1) {
98 pagesize = getpagesize();
100 if ((cpus = sysmp(MP_NPROCS)) == -1) {
101 perror(
"sysmp(MP_NPROCS)");
106 struct rminfo realmem;
107 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem,
sizeof(realmem)) == -1) {
108 perror(
"sysmp(MP_SAGET,MPSA_RMINFO, ...)");
113 memory_total = pagetok(realmem.physmem);
116 void HostMachineInfo::update_info( ) {
118 struct rminfo realmem;
119 struct sysinfo sysinfo;
123 swapctl(SC_GETFREESWAP, &fswap);
124 swapctl(SC_GETSWAPTOT, &tswap);
126 if (sysmp(MP_SAGET, MPSA_RMINFO, &realmem,
sizeof(realmem)) == -1) {
127 perror(
"sysmp(MP_SAGET,MPSA_RMINFO, ...)");
132 memory_free = pagetok(realmem.freemem);
133 memory_used = memory_total - memory_free;
134 swap_total = tswap / 2;
135 swap_free = fswap / 2;
136 swap_used = swap_total - swap_free;