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