50 lines
1.1 KiB
Diff
50 lines
1.1 KiB
Diff
|
diff -urN zabbix-1.6/src/libs/zbxsysinfo/linux/cpu.c zabbix-1.6.new/src/libs/zbxsysinfo/linux/cpu.c
|
||
|
--- zabbix-1.6/src/libs/zbxsysinfo/linux/cpu.c 2008-09-18 22:15:26.000000000 +0200
|
||
|
+++ zabbix-1.6.new/src/libs/zbxsysinfo/linux/cpu.c 2008-09-30 19:32:54.000000000 +0200
|
||
|
@@ -22,6 +22,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(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result)
|
||
|
{
|
||
|
char mode[128];
|