1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*
** Zabbix
** Copyright (C) 2000-2011 Zabbix SIA
**
** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation; either version 2 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
#ifndef ZABBIX_PERFMON_H
#define ZABBIX_PERFMON_H
#if !defined(_WINDOWS)
# error "This module allowed only for Windows OS"
#endif
#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
typedef enum
{
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 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;
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);
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 */
|