diff options
author | Arnaud Degroote <degroote@NetBSD.org> | 2013-10-06 18:13:29 +0000 |
---|---|---|
committer | Michael Stapelberg <michael@stapelberg.de> | 2013-10-07 19:31:01 +0200 |
commit | 32551729e886a7a6bae4cf53cadceb3079c6cac2 (patch) | |
tree | 3c1f49f8ce9a9655fceff9ec23454d56e730eddb | |
parent | cf2fb619110bd3f3d161b081e4b18c346a75eb94 (diff) |
Allow to print cpu usage on NetBSD
-rw-r--r-- | src/print_cpu_usage.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/print_cpu_usage.c b/src/print_cpu_usage.c index ecc81a2..80944c5 100644 --- a/src/print_cpu_usage.c +++ b/src/print_cpu_usage.c @@ -20,6 +20,13 @@ #include <sys/resource.h> #endif +#if defined(__NetBSD__) +#include <sys/param.h> +#include <sys/resource.h> +#include <sys/sysctl.h> +#include <sys/sched.h> +#endif + #include "i3status.h" static int prev_total = 0; @@ -50,9 +57,9 @@ void print_cpu_usage(yajl_gen json_gen, char *buffer, const char *format) { diff_usage = (diff_total ? (1000 * (diff_total - diff_idle)/diff_total + 5)/10 : 0); prev_total = curr_total; prev_idle = curr_idle; -#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) -#if defined(__FreeBSD__) || defined(__DragonFly__) +#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__NetBSD__) size_t size; long cp_time[CPUSTATES]; size = sizeof cp_time; |