Skip to content

Commit 8a092c4

Browse files
committed
Merge branch 'testing'
Zabbix 3.2
2 parents fed0387 + 46f36db commit 8a092c4

File tree

6 files changed

+819
-15
lines changed

6 files changed

+819
-15
lines changed

README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ RTU version also features:
2828
- pkg-config
2929
- Prereq: Download and install libmodbus
3030
- Run `autogen.sh`
31-
- `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2`
31+
- `./configure --enable-zabbix-3.2` or `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2`
3232
- `make`
3333
- `make install`
3434

3535
## 2.B Install from tar.gz sources
3636
Download from https://share.zabbix.com/dir-libraries/zabbix-loadable-modules/modbus-loadable-module
37-
- `tar zxvpf libzbxmodbus-0.1.tar.gz`
38-
- `cd libzbxmodbus-0.1`
39-
- `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2`
37+
- `tar zxvpf libzbxmodbus-0.4.tar.gz`
38+
- `cd libzbxmodbus-0.4`
39+
- `./configure --enable-zabbix-3.2` or `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2`
4040
- `make`
4141
- `make install`
4242

configure.ac

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
AC_INIT([libzbxmodbus], [0.3])
1+
AC_INIT([libzbxmodbus], [0.4])
22
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
33
AC_CONFIG_MACRO_DIR([m4])
44
AC_CONFIG_SRCDIR([src/modbus.c])
5+
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
56
# Checks for libraries.
67
have_modbus=no
78
AC_SEARCH_LIBS([modbus_get_float], [modbus], [have_modbus=yes])
@@ -23,7 +24,7 @@ PKG_CHECK_MODULES([LIBMODBUS], [libmodbus >= 3.1.1], [],
2324
------------------------------------------])
2425
])
2526

26-
#Zabbix 2.4 / Zabbix 3.0 chooser
27+
#Zabbix 2.4 / Zabbix 3.0 / 3.2 chooser
2728
AC_ARG_ENABLE([zabbix-2],
2829
[ --enable-zabbix-2 Build with Zabbix 2.4 headers],
2930
[case "${enableval}" in
@@ -42,22 +43,23 @@ AC_ARG_ENABLE([zabbix-3],
4243
esac],[zabbix_3=false])
4344
AM_CONDITIONAL([ZABBIX_3], [test x$zabbix_3 = xtrue])
4445

46+
AC_ARG_ENABLE([zabbix-3.2],
47+
[ --enable-zabbix-3.2 Build with Zabbix 3.2 headers],
48+
[case "${enableval}" in
49+
yes) zabbix_3_2=true ;;
50+
no) zabbix_3_2=false ;;
51+
*) AC_MSG_ERROR([bad value ${enableval} for --enable-zabbix-3.2]) ;;
52+
esac],[zabbix_3_2=false])
53+
AM_CONDITIONAL([ZABBIX_3_2], [test x$zabbix_3_2 = xtrue])
4554

46-
if [test "x${zabbix_2}" = xfalse && test "x${zabbix_3}" = xfalse] ; then
55+
if [test "x${zabbix_2}" = xfalse && test "x${zabbix_3}" = xfalse && test "x${zabbix_3_2}" = xfalse] ; then
4756
AC_MSG_ERROR([
4857
------------------------------------------
4958
Please specify the version of Zabbix module will be used with: by providing either
50-
--enable-zabbix-2 or --enable-zabbix-3 key but not both.
59+
--enable-zabbix-2 or --enable-zabbix-3 or --enable-zabbix-3.2 key but no more than one.
5160
------------------------------------------])
5261
fi
5362

54-
if [test "x${zabbix_2}" = xtrue && test "x${zabbix_3}" = xtrue] ; then
55-
AC_MSG_ERROR([
56-
------------------------------------------
57-
Please specify the version of Zabbix module will be used with: by providing either
58-
--enable-zabbix-2 or --enable-zabbix-3 key but not both.
59-
------------------------------------------])
60-
fi
6163

6264

6365
LT_INIT

include/zabbix-3.2/module.h

+206
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
/*
2+
** Zabbix
3+
** Copyright (C) 2001-2016 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_MODULE_H
21+
#define ZABBIX_MODULE_H
22+
23+
#include "zbxtypes.h"
24+
25+
#define ZBX_MODULE_OK 0
26+
#define ZBX_MODULE_FAIL -1
27+
28+
/* zbx_module_api_version() MUST return this constant */
29+
#define ZBX_MODULE_API_VERSION 2
30+
31+
/* old name alias is kept for source compatibility only, SHOULD NOT be used */
32+
#define ZBX_MODULE_API_VERSION_ONE ZBX_MODULE_API_VERSION
33+
34+
/* HINT: For conditional compilation with different module.h versions modules can use: */
35+
/* #if ZBX_MODULE_API_VERSION == X */
36+
/* ... */
37+
/* #endif */
38+
39+
#define get_rkey(request) (request)->key
40+
#define get_rparams_num(request) (request)->nparam
41+
#define get_rparam(request, num) ((request)->nparam > num ? (request)->params[num] : NULL)
42+
43+
/* flags for command */
44+
#define CF_HAVEPARAMS 0x01 /* item accepts either optional or mandatory parameters */
45+
#define CF_MODULE 0x02 /* item is defined in a loadable module */
46+
#define CF_USERPARAMETER 0x04 /* item is defined as user parameter */
47+
48+
typedef struct
49+
{
50+
char *key;
51+
unsigned flags;
52+
int (*function)();
53+
char *test_param; /* item test parameters; user parameter items keep command here */
54+
}
55+
ZBX_METRIC;
56+
57+
/* agent request structure */
58+
typedef struct
59+
{
60+
char *key;
61+
int nparam;
62+
char **params;
63+
zbx_uint64_t lastlogsize;
64+
int mtime;
65+
}
66+
AGENT_REQUEST;
67+
68+
typedef struct
69+
{
70+
char *value;
71+
char *source;
72+
int timestamp;
73+
int severity;
74+
int logeventid;
75+
}
76+
zbx_log_t;
77+
78+
/* agent result types */
79+
#define AR_UINT64 0x01
80+
#define AR_DOUBLE 0x02
81+
#define AR_STRING 0x04
82+
#define AR_TEXT 0x08
83+
#define AR_LOG 0x10
84+
#define AR_MESSAGE 0x20
85+
#define AR_META 0x40
86+
87+
/* agent return structure */
88+
typedef struct
89+
{
90+
zbx_uint64_t lastlogsize; /* meta information */
91+
zbx_uint64_t ui64;
92+
double dbl;
93+
char *str;
94+
char *text;
95+
char *msg; /* possible error message */
96+
zbx_log_t *log;
97+
int type; /* flags: see AR_* above */
98+
int mtime; /* meta information */
99+
}
100+
AGENT_RESULT;
101+
102+
/* SET RESULT */
103+
104+
#define SET_UI64_RESULT(res, val) \
105+
( \
106+
(res)->type |= AR_UINT64, \
107+
(res)->ui64 = (zbx_uint64_t)(val) \
108+
)
109+
110+
#define SET_DBL_RESULT(res, val) \
111+
( \
112+
(res)->type |= AR_DOUBLE, \
113+
(res)->dbl = (double)(val) \
114+
)
115+
116+
/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */
117+
#define SET_STR_RESULT(res, val) \
118+
( \
119+
(res)->type |= AR_STRING, \
120+
(res)->str = (char *)(val) \
121+
)
122+
123+
/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */
124+
#define SET_TEXT_RESULT(res, val) \
125+
( \
126+
(res)->type |= AR_TEXT, \
127+
(res)->text = (char *)(val) \
128+
)
129+
130+
/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */
131+
#define SET_LOG_RESULT(res, val) \
132+
( \
133+
(res)->type |= AR_LOG, \
134+
(res)->log = (zbx_log_t *)(val) \
135+
)
136+
137+
/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */
138+
#define SET_MSG_RESULT(res, val) \
139+
( \
140+
(res)->type |= AR_MESSAGE, \
141+
(res)->msg = (char *)(val) \
142+
)
143+
144+
#define SYSINFO_RET_OK 0
145+
#define SYSINFO_RET_FAIL 1
146+
147+
typedef struct
148+
{
149+
zbx_uint64_t itemid;
150+
int clock;
151+
int ns;
152+
double value;
153+
}
154+
ZBX_HISTORY_FLOAT;
155+
156+
typedef struct
157+
{
158+
zbx_uint64_t itemid;
159+
int clock;
160+
int ns;
161+
zbx_uint64_t value;
162+
}
163+
ZBX_HISTORY_INTEGER;
164+
165+
typedef struct
166+
{
167+
zbx_uint64_t itemid;
168+
int clock;
169+
int ns;
170+
const char *value;
171+
}
172+
ZBX_HISTORY_STRING;
173+
174+
typedef struct
175+
{
176+
zbx_uint64_t itemid;
177+
int clock;
178+
int ns;
179+
const char *value;
180+
}
181+
ZBX_HISTORY_TEXT;
182+
183+
typedef struct
184+
{
185+
zbx_uint64_t itemid;
186+
int clock;
187+
int ns;
188+
const char *value;
189+
const char *source;
190+
int timestamp;
191+
int logeventid;
192+
int severity;
193+
}
194+
ZBX_HISTORY_LOG;
195+
196+
typedef struct
197+
{
198+
void (*history_float_cb)(const ZBX_HISTORY_FLOAT *history, int history_num);
199+
void (*history_integer_cb)(const ZBX_HISTORY_INTEGER *history, int history_num);
200+
void (*history_string_cb)(const ZBX_HISTORY_STRING *history, int history_num);
201+
void (*history_text_cb)(const ZBX_HISTORY_TEXT *history, int history_num);
202+
void (*history_log_cb)(const ZBX_HISTORY_LOG *history, int history_num);
203+
}
204+
ZBX_HISTORY_WRITE_CBS;
205+
206+
#endif

0 commit comments

Comments
 (0)