diff options
author | Rudolfs Kreicbergs <git-no-reply@zabbix.com> | 2011-05-03 13:43:57 +0400 |
---|---|---|
committer | Rudolfs Kreicbergs <git-no-reply@zabbix.com> | 2011-05-03 13:43:57 +0400 |
commit | c1c2f7d514dd98f53ee46383100e19b27463b453 (patch) | |
tree | 375974b3326111dcd167352192c0c7609f73c10c /include | |
parent | 9375e944d51aede5a9d4d4806dbdf858c50f0915 (diff) |
- [ZBX-3547] Rewrote performance counters and cpu stats collection for Windows [merged from branches/1.8 r19318
Diffstat (limited to 'include')
-rw-r--r-- | include/alias.h | 17 | ||||
-rw-r--r-- | include/perfmon.h | 73 | ||||
-rw-r--r-- | include/zbxdb.h | 2 |
3 files changed, 55 insertions, 37 deletions
diff --git a/include/alias.h b/include/alias.h index 78a4c51ed83..6ba5f59b2ad 100644 --- a/include/alias.h +++ b/include/alias.h @@ -22,18 +22,17 @@ #define MAX_ALIAS_NAME 120 -struct zbx_alias +typedef struct zbx_alias { - struct zbx_alias *next; - char name[MAX_ALIAS_NAME]; - char *value; -}; - -typedef struct zbx_alias ALIAS; + struct zbx_alias *next; + char name[MAX_ALIAS_NAME]; + char *value; +} +ALIAS; int add_alias(const char *name, const char *value); int add_alias_from_config(char *value); -void alias_list_free(void); +void alias_list_free(); void alias_expand(const char *orig, char *expanded, int exp_buf_len); -#endif /* ZABBIX_ALIAS_H */ +#endif /* ZABBIX_ALIAS_H */ 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 */ diff --git a/include/zbxdb.h b/include/zbxdb.h index b53cc26c834..e8d3bada0ea 100644 --- a/include/zbxdb.h +++ b/include/zbxdb.h @@ -156,7 +156,7 @@ #endif /* HAVE_SQLITE3 */ #ifdef HAVE_SQLITE3 - /* We have to put double % here for sprintf */ + /* we have to put double % here for sprintf */ # define ZBX_SQL_MOD(x, y) #x "%%" #y #else # define ZBX_SQL_MOD(x, y) "mod(" #x "," #y ")" |