aboutsummaryrefslogtreecommitdiffstats
path: root/community/zabbix/zabbix-getloadavg.patch
diff options
context:
space:
mode:
Diffstat (limited to 'community/zabbix/zabbix-getloadavg.patch')
-rw-r--r--community/zabbix/zabbix-getloadavg.patch31
1 files changed, 31 insertions, 0 deletions
diff --git a/community/zabbix/zabbix-getloadavg.patch b/community/zabbix/zabbix-getloadavg.patch
new file mode 100644
index 0000000000..c6a458e1b4
--- /dev/null
+++ b/community/zabbix/zabbix-getloadavg.patch
@@ -0,0 +1,31 @@
+--- a/src/libs/zbxsysinfo/linux/cpu.c
++++ b/src/libs/zbxsysinfo/linux/cpu.c
+@@ -21,6 +21,28 @@
+ #include "sysinfo.h"
+ #include "stats.h"
+
++#ifndef HAVE_GETLOADAVG
++/*! \brief Alternative method of getting load avg on Linux only */
++int getloadavg(double *list, int nelem)
++{
++ FILE *LOADAVG;
++ double avg[3] = { 0.0, 0.0, 0.0 };
++ int i, res = -1;
++
++ if ((LOADAVG = fopen("/proc/loadavg", "r"))) {
++ fscanf(LOADAVG, "%lf %lf %lf", &avg[0], &avg[1], &avg[2]);
++ res = 0;
++ fclose(LOADAVG);
++ }
++
++ for (i = 0; (i < nelem) && (i < 3); i++) {
++ list[i] = avg[i];
++ }
++
++ return res;
++}
++#endif
++
+ int SYSTEM_CPU_NUM(AGENT_REQUEST *request, AGENT_RESULT *result)
+ {
+ char *type;