mirror of
https://github.com/xzeldon/htop.git
synced 2024-12-23 22:55:46 +00:00
Load averages for FreeBSD!
This commit is contained in:
parent
96e03739c4
commit
6d92d7f73d
@ -20,6 +20,8 @@ in the source distribution for its full text.
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <vm/vm_param.h>
|
||||
#include <time.h>
|
||||
|
||||
/*{
|
||||
@ -64,3 +66,20 @@ int Platform_getUptime() {
|
||||
|
||||
return (int) difftime(currTime.tv_sec, bootTime.tv_sec);
|
||||
}
|
||||
|
||||
void Platform_getLoadAverage(double* one, double* five, double* fifteen) {
|
||||
struct loadavg loadAverage;
|
||||
int mib[2] = { CTL_VM, VM_LOADAVG };
|
||||
size_t size = sizeof(loadAverage);
|
||||
|
||||
int err = sysctl(mib, 2, &loadAverage, &size, NULL, 0);
|
||||
if (err) {
|
||||
*one = 0;
|
||||
*five = 0;
|
||||
*fifteen = 0;
|
||||
return;
|
||||
}
|
||||
*one = (double) loadAverage.ldavg[0] / loadAverage.fscale;
|
||||
*five = (double) loadAverage.ldavg[1] / loadAverage.fscale;
|
||||
*fifteen = (double) loadAverage.ldavg[2] / loadAverage.fscale;
|
||||
}
|
||||
|
@ -17,4 +17,6 @@ extern MeterClass* Platform_meterTypes[];
|
||||
|
||||
int Platform_getUptime();
|
||||
|
||||
void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
||||
|
||||
#endif
|
||||
|
@ -17,4 +17,6 @@ extern MeterClass* Platform_meterTypes[];
|
||||
|
||||
int Platform_getUptime();
|
||||
|
||||
void Platform_getLoadAverage(double* one, double* five, double* fifteen);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user