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.

48 lines
948 B

  1. --- a/src/libs/zbxsysinfo/linux/cpu.c
  2. +++ b/src/libs/zbxsysinfo/linux/cpu.c
  3. @@ -62,6 +62,45 @@ int SYSTEM_CPU_DISCOVERY(AGENT_REQUEST *
  4. return SYSINFO_RET_OK;
  5. }
  6. +
  7. +/* uclibc and dietlibc do not have this junk -ReneR */
  8. +#if defined (__UCLIBC__) || defined (__dietlibc__)
  9. +static int getloadavg (double loadavg[], int nelem)
  10. +{
  11. + int fd;
  12. +
  13. + fd = open ("/proc/loadavg", O_RDONLY);
  14. + if (fd < 0)
  15. + return -1;
  16. + else
  17. + {
  18. + char buf[65], *p;
  19. + ssize_t nread;
  20. + int i;
  21. +
  22. + nread = read (fd, buf, sizeof buf - 1);
  23. + close (fd);
  24. + if (nread <= 0)
  25. + return -1;
  26. + buf[nread - 1] = '\0';
  27. +
  28. + if (nelem > 3)
  29. + nelem = 3;
  30. + p = buf;
  31. + for (i = 0; i < nelem; ++i)
  32. + {
  33. + char *endp;
  34. + loadavg[i] = strtod (p, &endp);
  35. + if (endp == p)
  36. + return -1;
  37. + p = endp;
  38. + }
  39. +
  40. + return i;
  41. + }
  42. +}
  43. +#endif
  44. +
  45. int SYSTEM_CPU_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
  46. {
  47. char *type;