Monitoring du Phytotron
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

funcs.c 931B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * funcs.c
  3. */
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <sys/time.h>
  7. #include "funcs.h"
  8. extern int verbosity;
  9. /* --------------------------------------------------------------- */
  10. int random1000(int foo)
  11. {
  12. int value;
  13. if (verbosity)
  14. fprintf(stderr, ">>> %s(%d)\n", __func__, foo);
  15. value = rand() % 1000;
  16. return value;
  17. }
  18. /* --------------------------------------------------------------- */
  19. double dtime(void)
  20. {
  21. struct timeval tv;
  22. int foo;
  23. foo = gettimeofday(&tv, NULL);
  24. if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__);
  25. return (double)tv.tv_sec + (double)tv.tv_usec / 1e6;
  26. }
  27. /* --------------------------------------------------------------- */
  28. double get_loadavg(int foo)
  29. {
  30. FILE *fp;
  31. if ( ! (fp=fopen("/proc/loadavg", "r")) ) {
  32. perror("read loadavg");
  33. return -42.51;
  34. }
  35. fclose(fp);
  36. return -42.51;
  37. }
  38. /* --------------------------------------------------------------- */