Created
October 9, 2012 02:12
-
-
Save thumphries/3856181 to your computer and use it in GitHub Desktop.
proper load average binary for OS X / BSD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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