mirror of https://github.com/lindes/ttyload.git
FreeBSD now works! :-)
This commit is contained in:
parent
df6903d7d9
commit
fac8a6ca46
5
README
5
README
|
@ -61,13 +61,14 @@ Thanks,
|
|||
ttyload has been shown to run on systems running, at least:
|
||||
|
||||
- Linux (at least some configs of it -- I'm using a SuSE 6.x box
|
||||
to build it on.)
|
||||
to build it on, with a 2.2.x kernel)
|
||||
- IRIX 6.5 (and possibly other versions?)
|
||||
- FreeBSD (some version or other, I'm not familiar with their
|
||||
numbering system... 4.4, I think.)
|
||||
|
||||
Hopefully soon it will also run on:
|
||||
|
||||
- Solaris
|
||||
- FreeBSD
|
||||
|
||||
Feel free, if you like, to submit patches to add more platforms,
|
||||
and please let me know also if it runs unmodified on any other
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* ttyload/arch/FreeBSD/getload.c -- getload() implimentation for the
|
||||
* FreeBSD platform.
|
||||
*
|
||||
* Copyright 2001, David Lindes. All rights reserved.
|
||||
*/
|
||||
|
||||
#include "ttyload.h"
|
||||
|
||||
#include <stdio.h> /* for perror */
|
||||
#include <stdlib.h> /* for exit(), and, on FreeBSD,
|
||||
* getloadavg(), too. */
|
||||
#include <unistd.h> /* for sleep() */
|
||||
|
||||
void getload(load_list *loadavgs)
|
||||
{
|
||||
double theload[3];
|
||||
int ret;
|
||||
|
||||
if((ret = getloadavg(theload, 3)) < 0)
|
||||
{
|
||||
perror("getloadavg() failed");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* so the caller _can_ (maybe not _will_) know how we did */
|
||||
loadavgs->numloads = ret;
|
||||
loadavgs->one_minute = theload[0] * 1024;
|
||||
loadavgs->five_minute = theload[1] * 1024;
|
||||
loadavgs->fifteen_minute = theload[2] * 1024;
|
||||
|
||||
switch(ret)
|
||||
{
|
||||
case 2:
|
||||
fprintf(stderr, "15 minute Load average is unreliable.\n");
|
||||
sleep(5);
|
||||
break;
|
||||
case 1:
|
||||
fprintf(stderr, "5 and 15 minute load averages are unreliable.\n");
|
||||
sleep(5);
|
||||
break;
|
||||
case 0:
|
||||
fprintf(stderr, "Sorry, couldn't get any load "
|
||||
"averages. This is, therefore, pointless.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue