[packages] syslog-ng3: set IPv6 support explicitly, rebuild when CONFIG_IPV6 is chang...
[openwrt/svn-archive/archive.git] / admin / zabbix / patches / 002-uclibc_loadavg.patch
1 diff -urN zabbix-1.6/src/libs/zbxsysinfo/linux/cpu.c zabbix-1.6.new/src/libs/zbxsysinfo/linux/cpu.c
2 --- zabbix-1.6/src/libs/zbxsysinfo/linux/cpu.c 2008-09-18 22:15:26.000000000 +0200
3 +++ zabbix-1.6.new/src/libs/zbxsysinfo/linux/cpu.c 2008-09-30 19:32:54.000000000 +0200
4 @@ -22,6 +22,45 @@
5 #include "sysinfo.h"
6 #include "stats.h"
7
8 +
9 +/* uclibc and dietlibc do not have this junk -ReneR */
10 +#if defined (__UCLIBC__) || defined (__dietlibc__)
11 +static int getloadavg (double loadavg[], int nelem)
12 +{
13 + int fd;
14 +
15 + fd = open ("/proc/loadavg", O_RDONLY);
16 + if (fd < 0)
17 + return -1;
18 + else
19 + {
20 + char buf[65], *p;
21 + ssize_t nread;
22 + int i;
23 +
24 + nread = read (fd, buf, sizeof buf - 1);
25 + close (fd);
26 + if (nread <= 0)
27 + return -1;
28 + buf[nread - 1] = '\0';
29 +
30 + if (nelem > 3)
31 + nelem = 3;
32 + p = buf;
33 + for (i = 0; i < nelem; ++i)
34 + {
35 + char *endp;
36 + loadavg[i] = strtod (p, &endp);
37 + if (endp == p)
38 + return -1;
39 + p = endp;
40 + }
41 +
42 + return i;
43 + }
44 +}
45 +#endif
46 +
47 int SYSTEM_CPU_NUM(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
48 {
49 char mode[128];