Merge pull request #308 from SaltwaterC/darwin-swap

Add Darwin swap meter
This commit is contained in:
Hisham Muhammad 2015-11-19 12:53:47 -02:00
commit ad5d9c2542
2 changed files with 10 additions and 5 deletions

View File

@ -102,6 +102,7 @@ MeterClass* Platform_meterTypes[] = {
&LoadAverageMeter_class, &LoadAverageMeter_class,
&LoadMeter_class, &LoadMeter_class,
&MemoryMeter_class, &MemoryMeter_class,
&SwapMeter_class,
&TasksMeter_class, &TasksMeter_class,
&BatteryMeter_class, &BatteryMeter_class,
&HostnameMeter_class, &HostnameMeter_class,
@ -226,7 +227,12 @@ void Platform_setMemoryValues(Meter* mtr) {
mtr->values[2] = (double)vm->inactive_count * page_K; mtr->values[2] = (double)vm->inactive_count * page_K;
} }
void Platform_setSwapValues(Meter* this) { void Platform_setSwapValues(Meter* mtr) {
(void) this; int mib[2] = {CTL_VM, VM_SWAPUSAGE};
} struct xsw_usage swapused;
size_t swlen = sizeof(swapused);
sysctl(mib, 2, &swapused, &swlen, NULL, 0);
mtr->total = swapused.xsu_total / 1024;
mtr->values[0] = swapused.xsu_used / 1024;
}

View File

@ -42,7 +42,6 @@ double Platform_setCPUValues(Meter* mtr, int cpu);
void Platform_setMemoryValues(Meter* mtr); void Platform_setMemoryValues(Meter* mtr);
void Platform_setSwapValues(Meter* this); void Platform_setSwapValues(Meter* mtr);
#endif #endif