commit a80bc0825e990b15e41bc954d565710a4b811e03 Author: lindes Date: Sat Jun 15 20:30:09 1996 +0000 Initial revision diff --git a/ttyload.c b/ttyload.c new file mode 100644 index 0000000..88e0252 --- /dev/null +++ b/ttyload.c @@ -0,0 +1,195 @@ +#include +#include +#include +#include +#include +#include +#include + +#define MIN(a,b) ((a)<(b)?(a):(b)) +#define MAX(a,b) ((a)>(b)?(a):(b)) + +#define ONE 01; +#define FIVE 02; +#define FIFTEEN 04; + +char *loadstrings[] = { " ", "+", "x", "*", ".", "=", "X", "@" }; + +typedef long load_t; + +typedef struct load_list { + load_t one_minute; + load_t five_minute; + load_t fifteen_minute; + int height1; + int height5; + int height15; + } load_list; + +/* The following variables should probably be assigned using + some sort of real logic, rather than these hard-coded + defaults, but the defaults work for now... */ +int rows = 40, + cols = 80, + height = 35, + width = 70, + intsec = 1, + i,j,k; + + +char *kmemfile = "/dev/kmem"; + +void getload(long,long,load_list *); +int compute_height(load_t,load_t,int); + +int main(argc,argv,envp) + int argc; + char *argv[], + *envp[]; +{ + int kmemfd, + omin,omax, + lmin,lmax; + float multiplier; + load_t loadaddr; + load_list min = {LONG_MAX,LONG_MAX,LONG_MAX}, + max = {0,0,0}, + *loadavgs; + + loadavgs = (load_list *)calloc(width,sizeof(load_list)); + + if(!loadavgs) + { + perror("malloc for loadavgs failed"); + } + + loadaddr = sysmp(MP_KERNADDR,MPKA_AVENRUN); + + if(loadaddr == -1) + { + perror("Couldn't determine load address"); + exit(1); + } + + kmemfd = open(kmemfile,O_RDONLY); + + if(kmemfd < 0) + { + perror("Couldn't open memory file"); + exit(1); + } + + for(i=0;i