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