diff --git a/README.md b/README.md index ea58f49..7d409eb 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ RTU version also features: - pkg-config - Prereq: Download and install libmodbus - Run `autogen.sh` + - `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2` - `make` - `make install` @@ -34,7 +35,7 @@ RTU version also features: Download from https://share.zabbix.com/dir-libraries/zabbix-loadable-modules/modbus-loadable-module - `tar zxvpf libzbxmodbus-0.1.tar.gz` - `cd libzbxmodbus-0.1` - - `./configure` + - `./configure --enable-zabbix-3` or `./configure --enable-zabbix-2` - `make` - `make install` @@ -86,7 +87,8 @@ and some optional params can be provided as well: * **datatype(optional):** provide datatype as single char: b - for MODBUS_BIT - i - for MODBUS_INTEGER + i - for MODBUS_INTEGER (unsigned) + s - for MODBUS_SIGNED_INT (NOTE: in Zabbix use 'Type of information' Numeric(float) ) l - for MODBUS_LONG f - for MODBUS_FLOAT otherwise, defaults will be used: diff --git a/configure.ac b/configure.ac index 58a1f81..2f36352 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([libzbxmodbus], [0.2]) +AC_INIT([libzbxmodbus], [0.3]) AM_INIT_AUTOMAKE([foreign -Wall -Werror]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/modbus.c]) @@ -22,6 +22,44 @@ PKG_CHECK_MODULES([LIBMODBUS], [libmodbus >= 3.1.1], [], libmodbus from http://libmodbus.org/ ------------------------------------------]) ]) + +#Zabbix 2.4 / Zabbix 3.0 chooser +AC_ARG_ENABLE([zabbix-2], +[ --enable-zabbix-2 Build with Zabbix 2.4 headers], +[case "${enableval}" in + yes) zabbix_2=true ;; + no) zabbix_2=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-zabbix-2]) ;; +esac],[zabbix_2=false]) +AM_CONDITIONAL([ZABBIX_2], [test x$zabbix_2 = xtrue]) + +AC_ARG_ENABLE([zabbix-3], +[ --enable-zabbix-3 Build with Zabbix 3.0 headers], +[case "${enableval}" in + yes) zabbix_3=true ;; + no) zabbix_3=false ;; + *) AC_MSG_ERROR([bad value ${enableval} for --enable-zabbix-3]) ;; +esac],[zabbix_3=false]) +AM_CONDITIONAL([ZABBIX_3], [test x$zabbix_3 = xtrue]) + + +if [test "x${zabbix_2}" = xfalse && test "x${zabbix_3}" = xfalse] ; then +AC_MSG_ERROR([ +------------------------------------------ +Please specify the version of Zabbix module will be used with: by providing either +--enable-zabbix-2 or --enable-zabbix-3 key but not both. +------------------------------------------]) +fi + +if [test "x${zabbix_2}" = xtrue && test "x${zabbix_3}" = xtrue] ; then +AC_MSG_ERROR([ +------------------------------------------ +Please specify the version of Zabbix module will be used with: by providing either +--enable-zabbix-2 or --enable-zabbix-3 key but not both. +------------------------------------------]) +fi + + LT_INIT AC_DISABLE_STATIC([yes]) AC_PROG_CC diff --git a/include/module.h b/include/zabbix-2.4/module.h similarity index 100% rename from include/module.h rename to include/zabbix-2.4/module.h diff --git a/include/sysinc.h b/include/zabbix-2.4/sysinc.h similarity index 100% rename from include/sysinc.h rename to include/zabbix-2.4/sysinc.h diff --git a/include/zbxtypes.h b/include/zabbix-2.4/zbxtypes.h similarity index 100% rename from include/zbxtypes.h rename to include/zabbix-2.4/zbxtypes.h diff --git a/include/zabbix-3.0/module.h b/include/zabbix-3.0/module.h new file mode 100644 index 0000000..f0c5ecd --- /dev/null +++ b/include/zabbix-3.0/module.h @@ -0,0 +1,138 @@ +/* +** Zabbix +** Copyright (C) 2001-2016 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_MODULE_H +#define ZABBIX_MODULE_H + +#include "zbxtypes.h" + +#define ZBX_MODULE_OK 0 +#define ZBX_MODULE_FAIL -1 + +#define ZBX_MODULE_API_VERSION_ONE 1 + +#define get_rkey(request) (request)->key +#define get_rparams_num(request) (request)->nparam +#define get_rparam(request, num) ((request)->nparam > num ? (request)->params[num] : NULL) + +/* flags for command */ +#define CF_HAVEPARAMS 0x01 /* item accepts either optional or mandatory parameters */ +#define CF_MODULE 0x02 /* item is defined in a loadable module */ +#define CF_USERPARAMETER 0x04 /* item is defined as user parameter */ + +typedef struct +{ + char *key; + unsigned flags; + int (*function)(); + char *test_param; /* item test parameters; user parameter items keep command here */ +} +ZBX_METRIC; + +/* agent request structure */ +typedef struct +{ + char *key; + int nparam; + char **params; + zbx_uint64_t lastlogsize; + int mtime; +} +AGENT_REQUEST; + +typedef struct +{ + char *value; + char *source; + int timestamp; + int severity; + int logeventid; +} +zbx_log_t; + +/* agent result types */ +#define AR_UINT64 0x01 +#define AR_DOUBLE 0x02 +#define AR_STRING 0x04 +#define AR_TEXT 0x08 +#define AR_LOG 0x10 +#define AR_MESSAGE 0x20 +#define AR_META 0x40 + +/* agent return structure */ +typedef struct +{ + zbx_uint64_t lastlogsize; /* meta information */ + zbx_uint64_t ui64; + double dbl; + char *str; + char *text; + char *msg; /* possible error message */ + zbx_log_t *log; + int type; /* flags: see AR_* above */ + int mtime; /* meta information */ +} +AGENT_RESULT; + +/* SET RESULT */ + +#define SET_UI64_RESULT(res, val) \ +( \ + (res)->type |= AR_UINT64, \ + (res)->ui64 = (zbx_uint64_t)(val) \ +) + +#define SET_DBL_RESULT(res, val) \ +( \ + (res)->type |= AR_DOUBLE, \ + (res)->dbl = (double)(val) \ +) + +/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */ +#define SET_STR_RESULT(res, val) \ +( \ + (res)->type |= AR_STRING, \ + (res)->str = (char *)(val) \ +) + +/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */ +#define SET_TEXT_RESULT(res, val) \ +( \ + (res)->type |= AR_TEXT, \ + (res)->text = (char *)(val) \ +) + +/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */ +#define SET_LOG_RESULT(res, val) \ +( \ + (res)->type |= AR_LOG, \ + (res)->log = (zbx_log_t *)(val) \ +) + +/* NOTE: always allocate new memory for val! DON'T USE STATIC OR STACK MEMORY!!! */ +#define SET_MSG_RESULT(res, val) \ +( \ + (res)->type |= AR_MESSAGE, \ + (res)->msg = (char *)(val) \ +) + +#define SYSINFO_RET_OK 0 +#define SYSINFO_RET_FAIL 1 + +#endif diff --git a/include/zabbix-3.0/sysinc.h b/include/zabbix-3.0/sysinc.h new file mode 100644 index 0000000..4891be3 --- /dev/null +++ b/include/zabbix-3.0/sysinc.h @@ -0,0 +1,438 @@ +/* +** Zabbix +** Copyright (C) 2001-2016 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_SYSINC_H +#define ZABBIX_SYSINC_H + +#include "config.h" + +#ifdef HAVE_STDIO_H +# include +#endif + +#ifdef HAVE_STDLIB_H +# include +#endif + +#ifdef HAVE_ASSERT_H +# include +#endif + +#ifdef HAVE_ERRNO_H +# include +#endif + +#ifdef HAVE_WINSOCK2_H +# include +#endif + +#ifdef HAVE_WS2TCPIP_H +# include +#endif + +#ifdef HAVE_WSPIAPI_H +# include "Wspiapi.h" +#endif + +#ifdef HAVE_IPHLPAPI_H +# include +#endif + +#ifdef HAVE_NETIOAPI_H +# include +#endif + +#ifdef HAVE_WINDOWS_H +/* to speed build process and reduce size of the Win32 header files */ +# define WIN32_LEAN_AND_MEAN 1 +# include +#endif + +#ifdef HAVE_PROCESS_H +# include +#endif + +#ifdef HAVE_CONIO_H +# include +#endif + +#ifdef HAVE_PDH_H +# include +# ifndef PDH_MAX_COUNTER_NAME +# define PDH_MAX_COUNTER_NAME 1024 /* maximum counter name length */ +# endif +# ifndef PDH_MAX_COUNTER_PATH +# define PDH_MAX_COUNTER_PATH 2048 /* maximum full counter path length */ +# endif +#endif + +#ifdef HAVE_PDHMSG_H +# include +#endif + +#ifdef HAVE_PSAPI_H +# include +#endif + +#ifdef HAVE_STDARG_H +# include +#endif + +#ifdef HAVE_CTYPE_H +# include +#endif + +#ifdef HAVE_GRP_H +# include +#endif + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + +#ifdef HAVE_SYS_SYSTEMCFG_H +# include +#endif + +#ifdef HAVE_INTTYPES_H +# include +#endif + +#ifdef HAVE_STRING_H +# include +#endif + +#ifdef HAVE_STRINGS_H +# include +#endif + +#ifdef HAVE_SYS_TIME_H +# include +#endif + +#ifdef HAVE_SYS_TIMES_H +# include +#endif + +#ifdef HAVE_LINUX_KERNEL_H +# include +#endif + +#ifdef HAVE_ARPA_NAMESER_H +# ifdef MAC_OS_X +# define BIND_8_COMPAT 1 +# endif +# include +#endif + +#ifdef HAVE_DIRENT_H +# include +#endif + +#ifdef HAVE_SYS_DKSTAT_H +# include +#endif + +#ifdef HAVE_DEVSTAT_H +# include +#endif + +#ifdef HAVE_FCNTL_H +# include +#endif + +#ifdef HAVE_KNLIST_H +# include +#endif + +#ifdef HAVE_KSTAT_H +# include +#endif + +#ifdef HAVE_WINLDAP_H +# undef SEC_I_INCOMPLETE_CREDENTIALS +# undef SEC_E_INCOMPLETE_CREDENTIALS +# undef SEC_I_RENEGOTIATE +# include +#endif + +#ifdef HAVE_WINBER_H +# include +#endif + +#ifdef HAVE_MACH_HOST_INFO_H +# include +#endif + +#ifdef HAVE_MACH_MACH_HOST_H +# include +#endif + +#ifdef HAVE_MTENT_H +# include +#endif + +#ifdef HAVE_NETDB_H +# include +#endif + +#ifdef HAVE_SYS_WAIT_H +# include +#endif + +#ifdef HAVE_NETINET_IN_H +# include +#endif + +#ifdef HAVE_PWD_H +# include +#endif + +#ifdef HAVE_SIGNAL_H +# include +#endif + +#ifdef HAVE_STDINT_H +# include +#endif + +#ifdef HAVE_SYS_LOADAVG_H +# include +#endif + +#ifdef HAVE_SYS_PARAM_H +# include +#endif + +#ifdef HAVE_SYS_PROC_H +# include +#endif + +#ifdef HAVE_SYS_PSTAT_H +# include +#endif + +#ifdef HAVE_PTHREAD_H +# include +#endif + +#ifdef HAVE_SYS_DK_H +# include +#endif + +#ifdef HAVE_RESOLV_H +# include +#endif + +#ifdef HAVE_SYS_DISK_H +# include +#endif + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif + +#ifdef HAVE_SYS_STAT_H +# include +#endif + +#ifdef HAVE_SYS_STATVFS_H +# include +#endif + +#ifdef HAVE_SYS_SWAP_H +# include +#endif + +#ifdef HAVE_SYS_SYSCALL_H +# include +#endif + +#ifdef HAVE_SYS_SYSCTL_H +# include +#endif + +#ifdef HAVE_SYS_SYSINFO_H +# include +#endif + +#ifdef HAVE_SYS_SYSMACROS_H +# include +#endif + +#ifdef HAVE_SYS_VAR_H +# include +#endif + +#ifdef HAVE_SYS_VFS_H +# include +#endif + +#ifdef HAVE_SYS_VMMETER_H +# include +#endif + +#ifdef HAVE_LIBPERFSTAT +# include +#endif + +#ifdef HAVE_SYS_RESOURCE_H +# include +#endif + +#ifdef HAVE_NLIST_H +# include +#endif + +#ifdef HAVE_NET_IF_H +# include +#endif + +#ifdef HAVE_NET_IF_MIB_H +# include +#endif + +#ifdef HAVE_SYS_USER_H +# include +#endif + +#ifdef HAVE_KVM_H +# include +#endif + +#ifdef HAVE_SYSLOG_H +# include +#endif + +#ifdef HAVE_TIME_H +# include +#endif + +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_SYS_IPC_H +# include +#endif + +#ifdef HAVE_SYS_SEM_H +# include +#endif + +#ifdef HAVE_SYS_SHM_H +# include +#endif + +#ifdef HAVE_SYS_FILE_H +# include +#endif + +#ifdef HAVE_MATH_H +# include +#endif + +#ifdef HAVE_REGEX_H +# include +#endif + +#ifdef HAVE_VM_VM_PARAM_H +# include +#endif + +#ifdef HAVE_ARPA_INET_H +# include +#endif + +#ifdef HAVE_SYS_MOUNT_H +# include +#endif + +#ifdef HAVE_SYS_TIMEB_H +# include +#endif + +#ifdef HAVE_PROCINFO_H +# undef T_NULL /* to solve definition conflict */ +# include +#endif + +#ifdef HAVE_LIBCURL +# include +# if !defined(HAVE_FUNCTION_CURL_EASY_ESCAPE) +# define curl_easy_escape(handle, string, length) curl_escape(string, length) +# endif +# if 0x071004 >= LIBCURL_VERSION_NUM /* version 7.16.4 */ +# define CURLOPT_KEYPASSWD CURLOPT_SSLKEYPASSWD +# endif +# if 0x071400 <= LIBCURL_VERSION_NUM /* version 7.20.0 */ +# define HAVE_SMTP_AUTHENTICATION 1 +# endif +# define ZBX_CURLOPT_MAXREDIRS 10L +#endif + +/* Net-SNMP is used */ +#ifdef HAVE_NETSNMP +# define SNMP_NO_DEBUGGING /* disabling debugging messages from Net-SNMP library */ +# include +# include +#endif + +/* LIBXML2 is used */ +#ifdef HAVE_LIBXML2 +# include +# include +# include +#endif + +/* Required for advanced sigaction */ +#ifdef HAVE_SYS_UCONTEXT_H +# include +#endif + +#ifdef HAVE_ICONV +# include +#endif + +#ifdef HAVE_SSH2 +# include +#endif + +#ifdef HAVE_IO_H +# include +#endif + +#ifdef HAVE_SYS_MNTTAB_H +# include +#endif + +#ifdef HAVE_MNTENT_H +# include +#endif + +#ifdef HAVE_DLFCN_H +# include +#endif + +#ifdef HAVE_ZONE_H +# include +# include +#endif + +#endif diff --git a/include/zabbix-3.0/zbxtypes.h b/include/zabbix-3.0/zbxtypes.h new file mode 100644 index 0000000..7d95b8d --- /dev/null +++ b/include/zabbix-3.0/zbxtypes.h @@ -0,0 +1,173 @@ +/* +** Zabbix +** Copyright (C) 2001-2016 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_TYPES_H +#define ZABBIX_TYPES_H + +#if defined(_WINDOWS) +# define ZBX_THREAD_LOCAL __declspec(thread) +#else +# define ZBX_THREAD_LOCAL +#endif + +#define ZBX_FS_DBL "%lf" +#define ZBX_FS_DBL_EXT(p) "%." #p "lf" + +#define ZBX_PTR_SIZE sizeof(void *) + +#if defined(_WINDOWS) +# include + +# define zbx_stat(path, buf) __zbx_stat(path, buf) +# define zbx_open(pathname, flags) __zbx_open(pathname, flags | O_BINARY) + +# ifndef __UINT64_C +# define __UINT64_C(x) x +# endif + +# ifndef __INT64_C +# define __INT64_C(x) x +# endif + +# define zbx_uint64_t unsigned __int64 +# define ZBX_FS_UI64 "%I64u" +# define ZBX_FS_UO64 "%I64o" +# define ZBX_FS_UX64 "%I64x" + +# define zbx_int64_t __int64 +# define ZBX_FS_I64 "%I64d" +# define ZBX_FS_O64 "%I64o" +# define ZBX_FS_X64 "%I64x" + +# define snprintf _snprintf + +# define alloca _alloca + +# ifndef uint32_t +# define uint32_t __int32 +# endif + +# ifndef PATH_SEPARATOR +# define PATH_SEPARATOR '\\' +# endif + +# define strcasecmp lstrcmpiA + +typedef __int64 zbx_offset_t; +# define zbx_lseek(fd, offset, whence) _lseeki64(fd, (zbx_offset_t)(offset), whence) + +#else /* _WINDOWS */ + +# define zbx_stat(path, buf) stat(path, buf) +# define zbx_open(pathname, flags) open(pathname, flags) + +# ifndef __UINT64_C +# ifdef UINT64_C +# define __UINT64_C(c) (UINT64_C(c)) +# else +# define __UINT64_C(c) (c ## ULL) +# endif +# endif + +# ifndef __INT64_C +# ifdef INT64_C +# define __INT64_C(c) (INT64_C(c)) +# else +# define __INT64_C(c) (c ## LL) +# endif +# endif + +# define zbx_uint64_t uint64_t +# if __WORDSIZE == 64 +# define ZBX_FS_UI64 "%lu" +# define ZBX_FS_UO64 "%lo" +# define ZBX_FS_UX64 "%lx" +# else +# ifdef HAVE_LONG_LONG_QU +# define ZBX_FS_UI64 "%qu" +# define ZBX_FS_UO64 "%qo" +# define ZBX_FS_UX64 "%qx" +# else +# define ZBX_FS_UI64 "%llu" +# define ZBX_FS_UO64 "%llo" +# define ZBX_FS_UX64 "%llx" +# endif +# endif + +# define zbx_int64_t int64_t +# if __WORDSIZE == 64 +# define ZBX_FS_I64 "%ld" +# define ZBX_FS_O64 "%lo" +# define ZBX_FS_X64 "%lx" +# else +# ifdef HAVE_LONG_LONG_QU +# define ZBX_FS_I64 "%qd" +# define ZBX_FS_O64 "%qo" +# define ZBX_FS_X64 "%qx" +# else +# define ZBX_FS_I64 "%lld" +# define ZBX_FS_O64 "%llo" +# define ZBX_FS_X64 "%llx" +# endif +# endif + +# ifndef PATH_SEPARATOR +# define PATH_SEPARATOR '/' +# endif + +typedef off_t zbx_offset_t; +# define zbx_lseek(fd, offset, whence) lseek(fd, (zbx_offset_t)(offset), whence) + +#endif /* _WINDOWS */ + +#define ZBX_FS_SIZE_T ZBX_FS_UI64 +#define ZBX_FS_SSIZE_T ZBX_FS_I64 +#define zbx_fs_size_t zbx_uint64_t /* use this type only in calls to printf() for formatting size_t */ +#define zbx_fs_ssize_t zbx_int64_t /* use this type only in calls to printf() for formatting ssize_t */ + +#ifndef S_ISREG +# define S_ISREG(x) (((x) & S_IFMT) == S_IFREG) +#endif + +#ifndef S_ISDIR +# define S_ISDIR(x) (((x) & S_IFMT) == S_IFDIR) +#endif + +#define ZBX_STR2UINT64(uint, string) is_uint64(string, &uint) +#define ZBX_OCT2UINT64(uint, string) sscanf(string, ZBX_FS_UO64, &uint) +#define ZBX_HEX2UINT64(uint, string) sscanf(string, ZBX_FS_UX64, &uint) + +#define ZBX_STR2UCHAR(var, string) var = (unsigned char)atoi(string) + +#define ZBX_CONST_STRING(str) ""str +#define ZBX_CONST_STRLEN(str) (sizeof(ZBX_CONST_STRING(str)) - 1) + +typedef struct +{ + zbx_uint64_t lo; + zbx_uint64_t hi; +} +zbx_uint128_t; + +#define ZBX_SIZE_T_ALIGN8(size) (((size) + 7) & ~(size_t)7) + +/* macro to test if a signed value has been assigned to unsigned type (char, short, int, long long) */ +#define ZBX_IS_TOP_BIT_SET(x) (0 != ((__UINT64_C(1) << ((sizeof(x) << 3) - 1)) & (x))) + +#endif diff --git a/src/Makefile.am b/src/Makefile.am index b39c5aa..57a3d4f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,9 +1,16 @@ lib_LTLIBRARIES = libzbxmodbus.la - libzbxmodbus_la_SOURCES = \ modbus.c libzbxmodbus_la_CFLAGS = $(LIBMODBUS_CFLAGS) + +if ZABBIX_2 +libzbxmodbus_la_CFLAGS += -I../include/zabbix-2.4 +endif +if ZABBIX_3 +libzbxmodbus_la_CFLAGS += -I../include/zabbix-3.0 +endif + libzbxmodbus_la_LDFLAGS = $(LIBMODBUS_LIBS) \ -module \ -shared \ - -avoid-version \ No newline at end of file + -avoid-version diff --git a/src/modbus.c b/src/modbus.c index d50ca25..48ae041 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -20,8 +20,8 @@ #include #include -#include "include/sysinc.h" -#include "include/module.h" +#include "sysinc.h" +#include "module.h" #include #include @@ -35,6 +35,7 @@ #define MODBUS_BIT 'b' #define MODBUS_INTEGER 'i' +#define MODBUS_SIGNED_INT 's' #define MODBUS_LONG 'l' #define MODBUS_FLOAT 'f' @@ -348,6 +349,11 @@ int zbx_modbus_read_registers(AGENT_REQUEST *request, AGENT_RESULT *result) case MODBUS_INTEGER: SET_UI64_RESULT(result, tab_reg[0]); break; + + case MODBUS_SIGNED_INT: + //use float type in zabbix item + SET_DBL_RESULT(result, (int16_t) tab_reg[0]); + break; case MODBUS_FLOAT: if (end == MODBUS_16BIT_LE) {