DD2-monitor/essai.c

46 lines
933 B
C
Raw Normal View History

2018-12-08 13:02:24 +01:00
/*
* essai.c
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
2019-01-17 18:37:30 +01:00
#include <string.h>
2019-01-18 15:39:07 +01:00
#include <time.h>
2018-12-08 13:02:24 +01:00
2019-01-17 18:37:30 +01:00
#include "core/utils.h"
2019-01-28 16:57:45 +01:00
#include "core/sysmetrics.h"
2018-12-08 13:02:24 +01:00
2019-01-17 18:37:30 +01:00
int verbosity;
/* --------------------------------------------------------------- */
2018-12-08 13:02:24 +01:00
/* --------------------------------------------------------------- */
int main(int argc, char *argv[])
{
int opt, foo;
double loads[3];
2019-01-18 15:39:07 +01:00
int il[3];
2018-12-08 13:02:24 +01:00
2019-01-17 18:37:30 +01:00
while ((opt = getopt(argc, argv, "v")) != -1) {
2018-12-08 13:02:24 +01:00
switch (opt) {
case 'v': verbosity++; break;
default: break;
}
}
foo = get_loadavg(loads);
if (foo) fprintf(stderr, "get loadavg -> %d\n", foo);
2019-01-18 15:39:07 +01:00
for (foo=0; foo<3; foo++) {
2019-01-18 17:56:27 +01:00
il[foo] = ((int)(loads[foo] * 90.0)) & 0x3ff;
2019-01-28 16:57:45 +01:00
if (verbosity)
fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]);
2019-01-18 15:39:07 +01:00
}
2018-12-08 13:02:24 +01:00
2019-01-18 17:56:27 +01:00
printf("%ld %d %d %d %d\n", time(NULL), getpid()%84, il[0], il[1], il[2]);
2018-12-08 13:02:24 +01:00
return 0;
}
/* --------------------------------------------------------------- */