Welcome to mirror list, hosted at ThFree Co, Russian Federation.

user_macro.h « zbxcacheconfig « libs « src - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b710a259222ee7db4a34ea6f443277d2eb15c4fc (plain)
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
80
81
82
83
84
85
86
87
88
89
/*
** Zabbix
** Copyright (C) 2001-2022 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/

#ifndef ZBX_USER_MACRO_H
#define ZBX_USER_MACRO_H

#include "zbxalgo.h"

#define ZBX_UM_CACHE_GLOBAL_MACRO_HOSTID	0

typedef struct
{
	zbx_uint64_t	macroid;
	zbx_uint64_t	hostid;
	const char	*name;
	const char	*context;
	const char	*value;
	zbx_uint32_t	refcount;
	unsigned char	type;
	unsigned char	context_op;
}
zbx_um_macro_t;

ZBX_PTR_VECTOR_DECL(um_macro, zbx_um_macro_t *)

typedef struct
{
	zbx_uint64_t		hostid;
	zbx_vector_uint64_t	templateids;
	zbx_vector_um_macro_t	macros;
	zbx_uint32_t		refcount;
	zbx_uint64_t		macro_revision;
	zbx_uint64_t		link_revision;
}
zbx_um_host_t;

ZBX_PTR_VECTOR_DECL(um_host, zbx_um_host_t *)

typedef struct
{
	zbx_hashset_t	hosts;
	zbx_uint32_t	refcount;
	zbx_uint64_t	revision;
}
zbx_um_cache_t;

zbx_hash_t	um_macro_hash(const void *d);
int	um_macro_compare(const void *d1, const void *d2);

zbx_um_cache_t	*um_cache_create(void);
void	um_cache_release(zbx_um_cache_t *cache);
void	um_macro_release(zbx_um_macro_t *macro);

zbx_um_cache_t	*um_cache_set_value_to_macros(zbx_um_cache_t *cache, zbx_uint64_t revision,
		const zbx_vector_uint64_pair_t *host_macro_ids, const char *value);

int	um_macro_check_vault_location(const zbx_um_macro_t *macro, const char *location);

void	um_cache_resolve_const(const zbx_um_cache_t *cache, const zbx_uint64_t *hostids, int hostids_num,
		const char *macro, int env, const char **value);
void	um_cache_resolve(const zbx_um_cache_t *cache, const zbx_uint64_t *hostids, int hostids_num, const char *macro,
		int env, char **value);
int	um_cache_get_host_revision(const zbx_um_cache_t *cache, zbx_uint64_t hostid, zbx_uint64_t *revision);
void	um_cache_get_macro_updates(const zbx_um_cache_t *cache, const zbx_uint64_t *hostids, int hostids_num,
		zbx_uint64_t revision, zbx_vector_uint64_t *macro_hostids, zbx_vector_uint64_t *del_macro_hostids);

void	um_cache_get_unused_templates(zbx_um_cache_t *cache, zbx_hashset_t *templates,
		const zbx_vector_uint64_t *hostids, zbx_vector_uint64_t *templateids);
void	um_cache_remove_hosts(zbx_um_cache_t *cache, const zbx_vector_uint64_t *hostids);

void	um_cache_dump(zbx_um_cache_t *cache);

#endif