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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
/*
** Zabbix
** Copyright (C) 2001-2018 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 ZABBIX_SENDER_H
#define ZABBIX_SENDER_H
#ifdef ZBX_EXPORT
# define ZBX_API __declspec(dllexport)
#else
# define ZBX_API __declspec(dllimport)
#endif
typedef struct
{
/* host name, must match the name of target host in Zabbix */
char *host;
/* the item key */
char *key;
/* the item value */
char *value;
}
zabbix_sender_value_t;
typedef struct
{
/* number of total values processed */
int total;
/* number of failed values */
int failed;
/* time in seconds the server spent processing the sent values */
double time_spent;
}
zabbix_sender_info_t;
/******************************************************************************
* *
* Function: zabbix_sender_send_values *
* *
* Purpose: send values to Zabbix server/proxy *
* *
* Parameters: address - [IN] zabbix server/proxy address *
* port - [IN] zabbix server/proxy trapper port *
* source - [IN] source IP, optional - can be NULL *
* values - [IN] array of values to send *
* count - [IN] number of items in values array *
* result - [OUT] the server response/error message, optional *
* If result is specified it must always be freed *
* afterwards with zabbix_sender_free_result() *
* function. *
* *
* Return value: 0 - the values were sent successfully, result contains *
* server response *
* -1 - an error occurred, result contains error message *
* *
******************************************************************************/
ZBX_API int zabbix_sender_send_values(const char *address, unsigned short port, const char *source,
const zabbix_sender_value_t *values, int count, char **result);
/******************************************************************************
* *
* Function: zabbix_sender_parse_result *
* *
* Purpose: parses the result returned from zabbix_sender_send_values() *
* function *
* *
* Parameters: result - [IN] result to parse *
* response - [OUT] the operation response *
* 0 - operation was successful *
* -1 - operation failed *
* info - [OUT] the detailed information about processed *
* values, optional *
* *
* Return value: 0 - the result was parsed successfully *
* -1 - the result parsing failed *
* *
* Comments: If info parameter was specified but the function failed to parse *
* the result info field, then info->total is set to -1. *
* *
******************************************************************************/
ZBX_API int zabbix_sender_parse_result(const char *result, int *response, zabbix_sender_info_t *info);
/******************************************************************************
* *
* Function: zabbix_sender_free_result *
* *
* Purpose: free data allocated by zabbix_sender_send_values() function *
* *
* Parameters: ptr - [IN] pointer to the data to free *
* *
******************************************************************************/
ZBX_API void zabbix_sender_free_result(void *ptr);
#endif /* ZABBIX_SENDER_H */
|