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 
21 #ifndef ZABBIX_ZBXTRENDS_H
22 #define ZABBIX_ZBXTRENDS_H
23 
24 #include "common.h"
25 #include "dbcache.h"
26 
27 int	zbx_trends_parse_base(const char *params, zbx_time_unit_t *base, char **error);
28 int	zbx_parse_timeshift(time_t from, const char *timeshift, struct tm *tm, char **error);
29 
30 int	zbx_trends_parse_range(time_t from, const char *param, int *start, int *end, char **error);
31 int	zbx_trends_parse_nextcheck(time_t from, const char *period_shift, time_t *nextcheck, char **error);
32 
33 int	zbx_trends_eval_avg(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
34 int	zbx_trends_eval_count(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
35 int	zbx_trends_eval_delta(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
36 int	zbx_trends_eval_max(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
37 int	zbx_trends_eval_min(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
38 int	zbx_trends_eval_sum(const char *table, zbx_uint64_t itemid, int start, int end, double *value, char **error);
39 
40 /* trends function cache */
41 typedef struct
42 {
43 	zbx_uint64_t	hits;
44 	zbx_uint64_t	misses;
45 	zbx_uint64_t	items_num;
46 	zbx_uint64_t	requests_num;
47 }
48 zbx_tfc_stats_t;
49 
50 int	zbx_tfc_init(char **error);
51 int	zbx_tfc_get_stats(zbx_tfc_stats_t *stats, char **error);
52 void	zbx_tfc_invalidate_trends(ZBX_DC_TREND *trends, int trends_num);
53 
54 #endif
55