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:
authorRudolfs Kreicbergs <git-no-reply@zabbix.com>2011-05-03 13:43:57 +0400
committerRudolfs Kreicbergs <git-no-reply@zabbix.com>2011-05-03 13:43:57 +0400
commitc1c2f7d514dd98f53ee46383100e19b27463b453 (patch)
tree375974b3326111dcd167352192c0c7609f73c10c /include/perfmon.h
parent9375e944d51aede5a9d4d4806dbdf858c50f0915 (diff)
- [ZBX-3547] Rewrote performance counters and cpu stats collection for Windows [merged from branches/1.8 r19318
Diffstat (limited to 'include/perfmon.h')
-rw-r--r--include/perfmon.h73
1 files changed, 46 insertions, 27 deletions
diff --git a/include/perfmon.h b/include/perfmon.h
index ab80469f4bf..b8798fe158c 100644
--- a/include/perfmon.h
+++ b/include/perfmon.h
@@ -22,39 +22,58 @@
#if !defined(_WINDOWS)
# error "This module allowed only for Windows OS"
-#endif /* _WINDOWS */
+#endif
-/*
- * Performance Counter Indexes
- */
-
-#define PCI_SYSTEM (2)
-#define PCI_PROCESSOR (238)
-#define PCI_PROCESSOR_TIME (6)
-#define PCI_PROCESSOR_QUEUE_LENGTH (44)
-#define PCI_SYSTEM_UP_TIME (674)
-#define PCI_TERMINAL_SERVICES (2176)
-#define PCI_TOTAL_SESSIONS (2178)
-
-/*
- * Performance Countername structure
- */
+#define PCI_SYSTEM 2
+#define PCI_PROCESSOR 238
+#define PCI_PROCESSOR_TIME 6
+#define PCI_PROCESSOR_QUEUE_LENGTH 44
+#define PCI_SYSTEM_UP_TIME 674
+#define PCI_TERMINAL_SERVICES 2176
+#define PCI_TOTAL_SESSIONS 2178
-struct perfcounter
+typedef enum
{
- struct perfcounter *next;
- unsigned long pdhIndex;
- TCHAR name[PDH_MAX_COUNTER_NAME];
- /* must be character array! if you want to rewrite */
- /* to use dynamic memory allocation CHECK for usage */
- /* of sizeof function */
+ PERF_COUNTER_NOTSUPPORTED = 0,
+ PERF_COUNTER_INITIALIZED,
+ PERF_COUNTER_GET_SECOND_VALUE, /* waiting for the second raw value (needed for some, e.g. rate, counters) */
+ PERF_COUNTER_ACTIVE,
};
-typedef struct perfcounter PERFCOUNTER;
+typedef struct perf_counter_id
+{
+ struct perf_counter_id *next;
+ unsigned long pdhIndex;
+ TCHAR name[PDH_MAX_COUNTER_NAME];
+}
+PERF_COUNTER_ID;
+
+typedef struct perf_counter_data
+{
+ struct perf_counter_data *next;
+ char *name;
+ char *counterpath;
+ int interval;
+ int status;
+ HCOUNTER handle;
+ PDH_RAW_COUNTER rawValues[2]; /* rate counters need two raw values */
+ int olderRawValue; /* index of the older of both values */
+ double *value_array; /* a circular buffer of values */
+ int value_current; /* index of the last stored value */
+ int value_count; /* number of values in the array */
+ double sum; /* sum of last value_count values */
+}
+PERF_COUNTER_DATA;
-extern PERFCOUNTER *PerfCounterList;
+PDH_STATUS zbx_PdhMakeCounterPath(const char *function, PDH_COUNTER_PATH_ELEMENTS *cpe, char *counterpath);
+PDH_STATUS zbx_PdhOpenQuery(const char *function, PDH_HQUERY query);
+PDH_STATUS zbx_PdhAddCounter(const char *function, PERF_COUNTER_DATA *counter, PDH_HQUERY query,
+ const char *counterpath, PDH_HCOUNTER *handle);
+PDH_STATUS zbx_PdhCollectQueryData(const char *function, const char *counterpath, PDH_HQUERY query);
+PDH_STATUS zbx_PdhGetRawCounterValue(const char *function, const char *counterpath, PDH_HCOUNTER handle, PPDH_RAW_COUNTER value);
-LPTSTR GetCounterName(DWORD pdhIndex);
-int check_counter_path(char *counterPath);
+PDH_STATUS calculate_counter_value(const char *function, const char *counterpath, double *value);
+LPTSTR get_counter_name(DWORD pdhIndex);
+int check_counter_path(char *counterPath);
#endif /* ZABBIX_PERFMON_H */