Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sysinfo.h4
-rw-r--r--src/libs/zbxsysinfo/win32/pdhmon.c6
-rw-r--r--src/zabbix_agent/cpustat.c4
-rw-r--r--src/zabbix_agent/cpustat.h2
-rw-r--r--src/zabbix_agent/perfstat.c13
-rw-r--r--src/zabbix_agent/zbxconf.c11
6 files changed, 27 insertions, 13 deletions
diff --git a/include/sysinfo.h b/include/sysinfo.h
index dbd19db123a..5f900558c8e 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -129,6 +129,10 @@ extern int CONFIG_UNSAFE_USER_PARAMETERS;
#define ZBX_AVG15 2
#define ZBX_AVG_COUNT 3
+#ifdef _WINDOWS
+# define MAX_COLLECTOR_PERIOD (15 * SEC_PER_MIN)
+#endif
+
#define ZBX_CPU_STATE_USER 0
#define ZBX_CPU_STATE_SYSTEM 1
#define ZBX_CPU_STATE_NICE 2
diff --git a/src/libs/zbxsysinfo/win32/pdhmon.c b/src/libs/zbxsysinfo/win32/pdhmon.c
index f4db697c6d5..cbabe5e4e2b 100644
--- a/src/libs/zbxsysinfo/win32/pdhmon.c
+++ b/src/libs/zbxsysinfo/win32/pdhmon.c
@@ -94,6 +94,12 @@ int PERF_COUNTER(AGENT_REQUEST *request, AGENT_RESULT *result)
goto out;
}
+ if (1 > interval || MAX_COLLECTOR_PERIOD < interval)
+ {
+ SET_MSG_RESULT(result, zbx_strdup(NULL, "Interval out of range."));
+ goto out;
+ }
+
if (FAIL == check_counter_path(counterpath))
{
SET_MSG_RESULT(result, zbx_strdup(NULL, "Invalid performance counter path."));
diff --git a/src/zabbix_agent/cpustat.c b/src/zabbix_agent/cpustat.c
index 676469eb7a1..f594d367383 100644
--- a/src/zabbix_agent/cpustat.c
+++ b/src/zabbix_agent/cpustat.c
@@ -138,7 +138,7 @@ int init_cpu_collector(ZBX_CPUS_STAT_DATA *pcpus)
if (ERROR_SUCCESS != zbx_PdhMakeCounterPath(__function_name, &cpe, counterPath))
goto clean;
- if (NULL == (pcpus->cpu_counter[cpu_num] = add_perf_counter(NULL, counterPath, MAX_CPU_HISTORY,
+ if (NULL == (pcpus->cpu_counter[cpu_num] = add_perf_counter(NULL, counterPath, MAX_COLLECTOR_PERIOD,
&error)))
{
goto clean;
@@ -152,7 +152,7 @@ int init_cpu_collector(ZBX_CPUS_STAT_DATA *pcpus)
if (ERROR_SUCCESS != zbx_PdhMakeCounterPath(__function_name, &cpe, counterPath))
goto clean;
- if (NULL == (pcpus->queue_counter = add_perf_counter(NULL, counterPath, MAX_CPU_HISTORY, &error)))
+ if (NULL == (pcpus->queue_counter = add_perf_counter(NULL, counterPath, MAX_COLLECTOR_PERIOD, &error)))
goto clean;
ret = SUCCEED;
diff --git a/src/zabbix_agent/cpustat.h b/src/zabbix_agent/cpustat.h
index 67ea4aba852..2d9431ff13a 100644
--- a/src/zabbix_agent/cpustat.h
+++ b/src/zabbix_agent/cpustat.h
@@ -25,8 +25,6 @@
#ifdef _WINDOWS
# include "perfmon.h"
-#define MAX_CPU_HISTORY (15 * SEC_PER_MIN)
-
typedef struct
{
PERF_COUNTER_DATA **cpu_counter;
diff --git a/src/zabbix_agent/perfstat.c b/src/zabbix_agent/perfstat.c
index 804fe0c581b..c49aadd1b6c 100644
--- a/src/zabbix_agent/perfstat.c
+++ b/src/zabbix_agent/perfstat.c
@@ -23,6 +23,7 @@
#include "alias.h"
#include "log.h"
#include "mutexs.h"
+#include "sysinfo.h"
static ZBX_PERF_STAT_DATA ppsd;
static ZBX_MUTEX perfstat_access = ZBX_MUTEX_NULL;
@@ -69,12 +70,6 @@ PERF_COUNTER_DATA *add_perf_counter(const char *name, const char *counterpath, i
goto out;
}
- if (1 > interval || 15 * SEC_PER_MIN < interval)
- {
- *error = zbx_dsprintf(*error, "Interval out of range.", interval);
- goto out;
- }
-
for (cptr = ppsd.pPerfCounterList; ; cptr = cptr->next)
{
/* add new parameters */
@@ -130,6 +125,8 @@ PERF_COUNTER_DATA *add_perf_counter(const char *name, const char *counterpath, i
out:
UNLOCK_PERFCOUNTERS;
+ zabbix_log(LOG_LEVEL_DEBUG, "End of %s(): %s", __function_name, NULL == cptr ? "FAIL" : "SUCCEED");
+
return cptr;
}
@@ -140,8 +137,8 @@ out:
* Purpose: extends the performance counter buffer to store the new data *
* interval *
* *
- * Parameters: result - [IN] the performance counter *
- * interval - [IN] the new data collection interval in seconds *
+ * Parameters: result - [IN] the performance counter *
+ * interval - [IN] the new data collection interval in seconds *
* *
******************************************************************************/
static void extend_perf_counter_interval(PERF_COUNTER_DATA *counter, int interval)
diff --git a/src/zabbix_agent/zbxconf.c b/src/zabbix_agent/zbxconf.c
index 35f2010fa5b..bb8791fb951 100644
--- a/src/zabbix_agent/zbxconf.c
+++ b/src/zabbix_agent/zbxconf.c
@@ -165,6 +165,7 @@ void load_perf_counters(const char **lines)
const char **pline;
char *error = NULL;
LPTSTR wcounterPath;
+ int period;
for (pline = lines; NULL != *pline; pline++)
{
@@ -202,7 +203,15 @@ void load_perf_counters(const char **lines)
goto pc_fail;
}
- if (NULL == add_perf_counter(name, counterpath, atoi(interval), &error))
+ period = atoi(interval);
+
+ if (1 > period || MAX_COLLECTOR_PERIOD < period)
+ {
+ error = zbx_strdup(NULL, "Interval out of range.");
+ goto pc_fail;
+ }
+
+ if (NULL == add_perf_counter(name, counterpath, period, &error))
{
if (NULL == error)
error = zbx_strdup(error, "Failed to add new performance counter.");