|
|
@ -6,21 +6,44 @@ |
|
|
|
#include <unistd.h> |
|
|
|
#include <stdlib.h> |
|
|
|
#include <string.h> |
|
|
|
#include <curses.h> |
|
|
|
#include <time.h> |
|
|
|
|
|
|
|
#include "core/utils.h" |
|
|
|
#include "core/sysmetrics.h" |
|
|
|
#include "viz/curses/ecran.h" |
|
|
|
|
|
|
|
int verbosity; |
|
|
|
|
|
|
|
/* --------------------------------------------------------------- */ |
|
|
|
int affiche_loadavg(int nbloops, int k) |
|
|
|
{ |
|
|
|
int idx, foo; |
|
|
|
float lds[3]; |
|
|
|
|
|
|
|
for (idx=0; idx<nbloops; idx++) { |
|
|
|
|
|
|
|
foo = get_loadavg(lds); |
|
|
|
if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); |
|
|
|
|
|
|
|
foo = aff7segs_float(stdscr, 4, 9, lds[0]); |
|
|
|
foo = aff7segs_float(stdscr, 14, 9, lds[1]); |
|
|
|
foo = aff7segs_float(stdscr, 24, 9, lds[2]); |
|
|
|
|
|
|
|
usleep(200*1000); |
|
|
|
} |
|
|
|
return 0; |
|
|
|
} |
|
|
|
/* --------------------------------------------------------------- */ |
|
|
|
static void finish(int signal) |
|
|
|
{ |
|
|
|
endwin(); exit(0); |
|
|
|
} |
|
|
|
/* --------------------------------------------------------------- */ |
|
|
|
|
|
|
|
int main(int argc, char *argv[]) |
|
|
|
{ |
|
|
|
int opt, foo; |
|
|
|
double loads[3]; |
|
|
|
int il[3]; |
|
|
|
|
|
|
|
while ((opt = getopt(argc, argv, "v")) != -1) { |
|
|
|
switch (opt) { |
|
|
@ -29,15 +52,19 @@ while ((opt = getopt(argc, argv, "v")) != -1) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foo = get_loadavg(loads); |
|
|
|
if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); |
|
|
|
for (foo=0; foo<3; foo++) { |
|
|
|
il[foo] = ((int)(loads[foo] * 90.0)) & 0x3ff; |
|
|
|
if (verbosity) |
|
|
|
fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); |
|
|
|
} |
|
|
|
|
|
|
|
printf("%ld %d %d %d %d\n", time(NULL), getpid()%84, il[0], il[1], il[2]); |
|
|
|
initscr(); |
|
|
|
nonl(); cbreak(); noecho(); |
|
|
|
keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ |
|
|
|
fond_ecran(" Demonstrator "); |
|
|
|
|
|
|
|
affiche_loadavg(10000, 0); |
|
|
|
|
|
|
|
/* |
|
|
|
* plop, on a fini, il faut restaurer la console |
|
|
|
*/ |
|
|
|
finish(0); |
|
|
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|