1 /*
2 ** Zabbix
3 ** Copyright (C) 2001-2021 Zabbix SIA
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
18 **/
19 
20 #ifndef ZABBIX_PERFSTAT_H
21 #define ZABBIX_PERFSTAT_H
22 
23 #ifndef _WINDOWS
24 #	error "This module is only available for Windows OS"
25 #endif
26 
27 #include "perfmon.h"
28 
29 #define UNSUPPORTED_REFRESH_PERIOD		600
30 
31 typedef struct
32 {
33 	PERF_COUNTER_DATA	*pPerfCounterList;
34 	PDH_HQUERY		pdh_query;
35 	time_t			nextcheck;	/* refresh time of not supported counters */
36 }
37 ZBX_PERF_STAT_DATA;
38 
39 extern ZBX_PERF_STAT_DATA	ppsd;
40 
41 PERF_COUNTER_DATA	*add_perf_counter(const char *name, const char *counterpath, int interval, char **error);
42 void			remove_perf_counter(PERF_COUNTER_DATA *counter);
43 
44 double	compute_average_value(PERF_COUNTER_DATA *counter, int interval);
45 
46 int	init_perf_collector(int multithreaded);
47 void	free_perf_collector();
48 int	perf_collector_started();
49 void	collect_perfstat();
50 
51 int	get_perf_counter_value_by_name(const char *name, double *value, char **error);
52 int	get_perf_counter_value_by_path(const char *counterpath, int interval, double *value, char **error);
53 int	get_perf_counter_value(PERF_COUNTER_DATA *counter, int interval, double *value, char **error);
54 
55 #endif
56