From 8895f09880f441c2075b703cdec0643ac70790aa Mon Sep 17 00:00:00 2001 From: SaltwaterC Date: Mon, 16 Nov 2015 17:32:22 +0000 Subject: Add Darwin swap meter. --- darwin/Platform.c | 12 +++++++++--- darwin/Platform.h | 3 +-- 2 files changed, 10 insertions(+), 5 deletions(-) (limited to 'darwin') diff --git a/darwin/Platform.c b/darwin/Platform.c index 4a36fe05..73b47c4c 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -102,6 +102,7 @@ MeterClass* Platform_meterTypes[] = { &LoadAverageMeter_class, &LoadMeter_class, &MemoryMeter_class, + &SwapMeter_class, &TasksMeter_class, &BatteryMeter_class, &HostnameMeter_class, @@ -226,7 +227,12 @@ void Platform_setMemoryValues(Meter* mtr) { mtr->values[2] = (double)vm->inactive_count * page_K; } -void Platform_setSwapValues(Meter* this) { - (void) this; -} +void Platform_setSwapValues(Meter* mtr) { + 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; +} diff --git a/darwin/Platform.h b/darwin/Platform.h index fdf8b35b..d1b9ea5e 100644 --- a/darwin/Platform.h +++ b/darwin/Platform.h @@ -42,7 +42,6 @@ double Platform_setCPUValues(Meter* mtr, int cpu); void Platform_setMemoryValues(Meter* mtr); -void Platform_setSwapValues(Meter* this); - +void Platform_setSwapValues(Meter* mtr); #endif -- cgit v1.2.3