Skip to content

Instantly share code, notes, and snippets.

@thumphries
Created October 9, 2012 02:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thumphries/3856181 to your computer and use it in GitHub Desktop.
Save thumphries/3856181 to your computer and use it in GitHub Desktop.
proper load average binary for OS X / BSD
// loadavg.c
// Simple load average spewer for BSDs and Mac OS X
// tim at utf8.me
// (Why is there no system binary for this?)
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
double loads[3] = {0};
if(getloadavg(loads, 3)>0) {
printf("%.2f %.2f %.2f\n", loads[0], loads[1], loads[2]);
return EXIT_SUCCESS;
} else {
return EXIT_FAILURE;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment