diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | configure.in | 228 | ||||
-rw-r--r-- | include/alias.h | 2 | ||||
-rw-r--r-- | src/libs/zbxcommon/alias.c | 8 | ||||
-rw-r--r-- | src/libs/zbxsysinfo/hpux/net.c | 153 | ||||
-rw-r--r-- | src/zabbix_agent/perfstat.c | 2 |
6 files changed, 274 insertions, 120 deletions
diff --git a/ChangeLog b/ChangeLog index 0a94fb76bea..d707b4a5798 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15,6 +15,7 @@ Bug fixes: Changes for 2.0.3rc1 New features: +...GI..... [ZBX-5171] got rid of agent ipv6 library dependency on older HP-UX machines (dimir) ........S. [ZBX-5450] added support of "KMGTsmhdw" suffixes in the second parameter of count() function (Sasha) A.F....... [ZBX-1357] added American English translation; thanks to Zabbix translators (Richlv) A......... [ZBX-2060] implemented the "expandExpression" parameter for the trigger.get and triggerprototype.get methods (Pavels) diff --git a/configure.in b/configure.in index 2fd83146652..698afdee0ef 100644 --- a/configure.in +++ b/configure.in @@ -146,7 +146,7 @@ dnl check for DNS lookup functions found_resolv="no" LIBRESOLV_CHECK_CONFIG([no]) if test "x$found_resolv" != "xyes"; then - AC_MSG_ERROR([Unable to DNS lookup functions "${found_resolv}"]) + AC_MSG_ERROR([Unable to do DNS lookups (libresolv check failed)]) fi LIBS="${LIBS} ${RESOLV_LIBS}" @@ -166,7 +166,7 @@ case "${host_os}" in ;; esac -if test "$largefile" = "yes"; then +if test "x$largefile" = "xyes"; then AC_SYS_LARGEFILE fi @@ -835,13 +835,124 @@ AC_MSG_RESULT(no)) dnl ***************************************************************** dnl * * +dnl * Checks for operating systems * +dnl * * +dnl ***************************************************************** + +AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset) +AC_TRY_COMPILE([#include <libperfstat.h>], +[perfstat_memory_total_t memstats; +memstats.virt_active = 0; +], +AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.]) +AC_MSG_RESULT(yes), +AC_MSG_RESULT(no)) + +AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset) +AC_TRY_COMPILE([#include <libperfstat.h>], +[perfstat_partition_total_t lparstats; +lparstats.type.b.donate_enabled = 0; +lparstats.idle_donated_purr = 0; +lparstats.busy_donated_purr = 0; +lparstats.idle_stolen_purr = 0; +lparstats.busy_stolen_purr = 0; +], +AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.]) +AC_MSG_RESULT(yes), +AC_MSG_RESULT(no)) + +AC_MSG_CHECKING(for architecture) + +case "$host_os" in +linux*) + ARCH="linux" + ;; +aix*) + ARCH="aix" + ;; +darwin*|rhapsody*) + ARCH="osx" + AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X]) + ;; +*solaris*) + ARCH="solaris" + ;; +hpux*) + ARCH="hpux" + ;; +freebsd*) + ARCH="freebsd" + ;; +netbsd*) + ARCH="netbsd" + ;; +osf*) + ARCH="osf" + ;; +openbsd*) + ARCH="openbsd" + ;; +*) + ARCH="unknown" + ;; +esac + +AC_MSG_RESULT([$ARCH ($host_os)]) + +if test "x$ARCH" = "xlinux"; then + AC_MSG_CHECKING([for the linux kernel version]) + + kernel=`uname -r` + + case "${kernel}" in + 2.6.*) + AC_MSG_RESULT([2.6 family (${kernel})]) + AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x]) + ;; + 2.4.*) + AC_MSG_RESULT([2.4 family (${kernel})]) + AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x]) + ;; + *) + AC_MSG_RESULT([unknown family (${kernel})]) + ;; + esac +fi + +dnl Low Level Discovery needs a way to get the list of network +dnl interfaces available on the monitored system. On HP-UX systems +dnl that way depends on the OS version. +if test "x$ARCH" = "xhpux"; then + hpux_version=${host_os#hpux} + hpux_major=${hpux_version%.*} + hpux_minor=${hpux_version#*.} + + AC_DEFINE_UNQUOTED([HPUX_VERSION], $hpux_major$hpux_minor, [Define to HP-UX version]) +fi + +AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing]) +AC_SUBST(ARCH) + +dnl ***************************************************************** +dnl * * dnl * Checks for options given on the command line * dnl * * dnl ***************************************************************** AC_ARG_ENABLE(static,[ --enable-static Build statically linked binaries], [case "${enableval}" in - yes) LDFLAGS="${LDFLAGS} -static" ;; + yes) + LDFLAGS="${LDFLAGS} -static" + AC_MSG_CHECKING(if static linking is possible) + AC_LINK_IFELSE([AC_LANG_PROGRAM(,)], + [AC_MSG_RESULT([yes]) + static_linking=yes], + [AC_MSG_RESULT([no]) + static_linking=no]) + if test "x$static_linking" = "xno"; then + AC_MSG_ERROR([static linking is not possible on this system]) + fi + ;; no) ;; *) AC_MSG_ERROR([bad value ${enableval} for --enable-static]) ;; esac]) @@ -899,12 +1010,12 @@ have_ipmi="no" have_ipv6="no" have_ssh2="no" -if test "$ipv6" = "yes"; then +if test "x$ipv6" = "xyes"; then AC_DEFINE(HAVE_IPV6,1,[Define to 1 if IPv6 should be enabled.]) have_ipv6="yes" fi -if test "$server" = "yes" || test "$proxy" = "yes"; then +if test "x$server" = "xyes" || test "x$proxy" = "xyes"; then have_multirow_insert="no" @@ -1071,6 +1182,7 @@ if test "$server" = "yes" || test "$proxy" = "yes"; then PROXY_LDFLAGS="$PROXY_LDFLAGS $LIBCURL_LDFLAGS" PROXY_LIBS="$PROXY_LIBS $LIBCURL_LIBS" + dnl Starting from 2.0 agent can do web monitoring AGENT_LDFLAGS="${AGENT_LDFLAGS} ${LIBCURL_LDFLAGS}" AGENT_LIBS="${AGENT_LIBS} ${LIBCURL_LIBS}" @@ -1191,7 +1303,7 @@ if test "$server" = "yes" || test "$proxy" = "yes"; then PROXY_LIBS="$PROXY_LIBS $OPENIPMI_LIBS" fi -if test "$java" = "yes"; then +if test "x$java" = "xyes"; then AC_CHECK_PROGS([JAVAC], [javac], [no]) if test "x$JAVAC" = "xno"; then AC_MSG_ERROR([Unable to find "javac" executable in path]) @@ -1228,7 +1340,7 @@ found_iconv="no" dnl Check for libiconv [by default - skip] LIBICONV_CHECK_CONFIG([no]) if test "x$found_iconv" != "xyes"; then - AC_MSG_ERROR([Unable to find iconv.h "${found_iconv}"]) + AC_MSG_ERROR([Unable to use iconv (libiconv check failed)]) fi CFLAGS="$CFLAGS $ICONV_CFLAGS" LDFLAGS="$LDFLAGS $ICONV_LDFLAGS" @@ -1248,108 +1360,6 @@ AC_SUBST(AGENT_LIBS) dnl ***************************************************************** dnl * * -dnl * Checks for operating systems * -dnl * * -dnl ***************************************************************** - -AC_MSG_CHECKING(for libperfstat 5.2.0.40 fileset) -AC_TRY_COMPILE([#include <libperfstat.h>], -[perfstat_memory_total_t memstats; -memstats.virt_active = 0; -], -AC_DEFINE(HAVE_AIXOSLEVEL_520004,1,[Define to 1 if libperfstat 5.2.0.40 fileset exists.]) -AC_MSG_RESULT(yes), -AC_MSG_RESULT(no)) - -AC_MSG_CHECKING(for libperfstat 5.3.0.60 fileset) -AC_TRY_COMPILE([#include <libperfstat.h>], -[perfstat_partition_total_t lparstats; -lparstats.type.b.donate_enabled = 0; -lparstats.idle_donated_purr = 0; -lparstats.busy_donated_purr = 0; -lparstats.idle_stolen_purr = 0; -lparstats.busy_stolen_purr = 0; -], -AC_DEFINE(HAVE_AIXOSLEVEL_530006,1,[Define to 1 if libperfstat 5.3.0.60 fileset exists.]) -AC_MSG_RESULT(yes), -AC_MSG_RESULT(no)) - -AC_MSG_CHECKING(for architecture) - -case "$host_os" in -linux*) - ARCH="linux" - - AC_MSG_RESULT([ok (${host_os})]) - - AC_MSG_CHECKING([for the kernel version]) - - kernel=`uname -r` - - case "${kernel}" in - 2.6.*) - AC_MSG_RESULT([2.6 family (${kernel})]) - AC_DEFINE([KERNEL_2_6], 1, [Define to 1 if you are using Linux 2.6.x]) - ;; - 2.4.*) - AC_MSG_RESULT([2.4 family (${kernel})]) - AC_DEFINE([KERNEL_2_4], 1, [Define to 1 if you are using Linux 2.4.x]) - ;; - esac -;; -aix*) - ARCH="aix" - - AC_MSG_RESULT([ok (${host_os})]) -;; -darwin*|rhapsody*) - ARCH="osx" - - AC_MSG_RESULT([ok (${host_os})]) - AC_DEFINE([MAC_OS_X], 1, [Define to 1 if you are using Mac OS X]) -;; -*solaris*) - ARCH="solaris" - - AC_MSG_RESULT([ok (${host_os})]) -;; -hpux*) - ARCH="hpux" - - AC_MSG_RESULT([ok (${host_os})]) -;; -freebsd*) - ARCH="freebsd" - - AC_MSG_RESULT([ok (${host_os})]) -;; -netbsd*) - ARCH="netbsd" - - AC_MSG_RESULT([ok (${host_os})]) -;; -osf*) - ARCH="osf" - - AC_MSG_RESULT([ok (${host_os})]) -;; -openbsd*) - ARCH="openbsd" - - AC_MSG_RESULT([ok (${host_os})]) -;; -*) - ARCH="unknown" - - AC_MSG_RESULT([ok (${host_os})]) -;; -esac - -AC_DEFINE_UNQUOTED([ARCH], "${ARCH}", [Define to OS name for code managing]) -AC_SUBST(ARCH) - -dnl ***************************************************************** -dnl * * dnl * Other checks * dnl * * dnl ***************************************************************** diff --git a/include/alias.h b/include/alias.h index df7695ae966..f705987bc00 100644 --- a/include/alias.h +++ b/include/alias.h @@ -30,7 +30,7 @@ typedef struct zbx_alias } ALIAS; -int add_alias(const char *name, const char *value); +void add_alias(const char *name, const char *value); void alias_list_free(); void alias_expand(const char *orig, char *expanded, size_t exp_buf_len); diff --git a/src/libs/zbxcommon/alias.c b/src/libs/zbxcommon/alias.c index f679dc698e7..8112ba85c72 100644 --- a/src/libs/zbxcommon/alias.c +++ b/src/libs/zbxcommon/alias.c @@ -23,7 +23,7 @@ static ALIAS *aliasList = NULL; -int add_alias(const char *name, const char *value) +void add_alias(const char *name, const char *value) { ALIAS *alias = NULL; @@ -45,7 +45,7 @@ int add_alias(const char *name, const char *value) aliasList = alias; zabbix_log(LOG_LEVEL_DEBUG, "Alias added: \"%s\" -> \"%s\"", name, value); - return SUCCEED; + break; } /* treat duplicate Alias as error */ @@ -55,10 +55,6 @@ int add_alias(const char *name, const char *value) exit(FAIL); } } - - zabbix_log(LOG_LEVEL_WARNING, "Alias handling FAILED: \"%s\" -> \"%s\"", name, value); - - return FAIL; } void alias_list_free() diff --git a/src/libs/zbxsysinfo/hpux/net.c b/src/libs/zbxsysinfo/hpux/net.c index 259f3e67e93..86faddf0411 100644 --- a/src/libs/zbxsysinfo/hpux/net.c +++ b/src/libs/zbxsysinfo/hpux/net.c @@ -21,25 +21,172 @@ #include "sysinfo.h" #include "zbxjson.h" +/* Low Level Discovery needs a way to get the list of network interfaces available */ +/* on the monitored system. HP-UX versions starting from 11.31 have if_nameindex() */ +/* available in libc, older versions have it in libipv6 which we do not want to */ +/* depend on. So for older versions we use different code to get that list. */ +/* More information: */ +/* h20000.www2.hp.com/bc/docs/support/SupportManual/c02258083/c02258083.pdf */ + +#if HPUX_VERSION < 1131 + +#define ZBX_IF_SEP ',' + +void add_if_name(char **if_list, size_t *if_list_alloc, size_t *if_list_offset, const char *name) +{ + if (FAIL == str_in_list(*if_list, name, ZBX_IF_SEP)) + { + if ('\0' != **if_list) + zbx_chrcpy_alloc(if_list, if_list_alloc, if_list_offset, ZBX_IF_SEP); + + zbx_strcpy_alloc(if_list, if_list_alloc, if_list_offset, name); + } +} + +int get_if_names(char **if_list, size_t *if_list_alloc, size_t *if_list_offset) +{ + int s, ifreq_size, numifs, i, family = AF_INET; + struct sockaddr *from; + size_t fromlen; + u_char *buffer = NULL; + struct ifconf ifc; + struct ifreq *ifr; + struct if_laddrconf lifc; + struct if_laddrreq *lifr; + + if (-1 == (s = socket(family, SOCK_DGRAM, 0))) + return FAIL; + + ifc.ifc_buf = 0; + ifc.ifc_len = 0; + + if (0 == ioctl(s, SIOCGIFCONF, (caddr_t)&ifc) && 0 != ifc.ifc_len) + ifreq_size = 2 * ifc.ifc_len; + else + ifreq_size = 2 * 512; + + buffer = zbx_malloc(buffer, ifreq_size); + memset(buffer, 0, ifreq_size); + + ifc.ifc_buf = (caddr_t)buffer; + ifc.ifc_len = ifreq_size; + + if (-1 == ioctl(s, SIOCGIFCONF, &ifc)) + goto next; + + /* check all IPv4 interfaces */ + ifr = (struct ifreq *)ifc.ifc_req; + while ((u_char *)ifr < (u_char *)(buffer + ifc.ifc_len)) + { + from = &ifr->ifr_addr; + + if (AF_INET6 != from->sa_family && AF_INET != from->sa_family) + continue; + + add_if_name(if_list, if_list_alloc, if_list_offset, ifr->ifr_name); + +#ifdef _SOCKADDR_LEN + ifr = (struct ifreq *)((char *)ifr + sizeof(*ifr) + (from->sa_len > sizeof(*from) ? from->sa_len - sizeof(*from) : 0)); +#else + ifr++; +#endif + } +next: + zbx_free(buffer); + close(s); + +#if defined (SIOCGLIFCONF) + family = AF_INET6; + + if (-1 == (s = socket(family, SOCK_DGRAM, 0))) + return FAIL; + + i = ioctl(s, SIOCGLIFNUM, (char *)&numifs); + if (0 == numifs) + { + close(s); + return SUCCEED; + } + + lifc.iflc_len = numifs * sizeof(struct if_laddrreq); + lifc.iflc_buf = zbx_malloc(NULL, lifc.iflc_len); + buffer = (u_char *)lifc.iflc_buf; + + if (-1 == ioctl(s, SIOCGLIFCONF, &lifc)) + goto end; + + /* check all IPv6 interfaces */ + for (lifr = lifc.iflc_req; '\0' != *lifr->iflr_name; lifr++) + { + from = (struct sockaddr *)&lifr->iflr_addr; + + if (AF_INET6 != from->sa_family && AF_INET != from->sa_family) + continue; + + add_if_name(if_list, if_list_alloc, if_list_offset, lifr->iflr_name); + } +end: + zbx_free(buffer); + close(s); +#endif + return SUCCEED; +} +#endif /* HPUX_VERSION < 1131 */ + int NET_IF_DISCOVERY(const char *cmd, const char *param, unsigned flags, AGENT_RESULT *result) { +#if HPUX_VERSION < 1131 + char *if_list = NULL, *if_name_end; + size_t if_list_alloc = 64, if_list_offset = 0; +#else struct if_nameindex *ni; - struct zbx_json j; int i; +#endif + struct zbx_json j; + char *if_name; zbx_json_init(&j, ZBX_JSON_STAT_BUF_LEN); zbx_json_addarray(&j, ZBX_PROTO_TAG_DATA); +#if HPUX_VERSION < 1131 + if_list = zbx_malloc(if_list, if_list_alloc); + *if_list = '\0'; + + if (FAIL == get_if_names(&if_list, &if_list_alloc, &if_list_offset)) + return SYSINFO_RET_FAIL; + + if_name = if_list; + + while (NULL != if_name) + { + if (NULL != (if_name_end = strchr(if_name, ZBX_IF_SEP))) + *if_name_end = '\0'; +#else for (ni = if_nameindex(), i = 0; 0 != ni[i].if_index; i++) { + if_name = ni[i].if_name; +#endif zbx_json_addobject(&j, NULL); - zbx_json_addstring(&j, "{#IFNAME}", ni[i].if_name, ZBX_JSON_TYPE_STRING); + zbx_json_addstring(&j, "{#IFNAME}", if_name, ZBX_JSON_TYPE_STRING); zbx_json_close(&j); +#if HPUX_VERSION < 1131 + + if (NULL != if_name_end) + { + *if_name_end = ZBX_IF_SEP; + if_name = if_name_end + 1; + } + else + if_name = NULL; +#endif } +#if HPUX_VERSION < 1131 + zbx_free(if_list); +#else if_freenameindex(ni); - +#endif zbx_json_close(&j); SET_STR_RESULT(result, strdup(j.buffer)); diff --git a/src/zabbix_agent/perfstat.c b/src/zabbix_agent/perfstat.c index 914eb80e4e2..eab59df1361 100644 --- a/src/zabbix_agent/perfstat.c +++ b/src/zabbix_agent/perfstat.c @@ -119,7 +119,7 @@ PERF_COUNTER_DATA *add_perf_counter(const char *name, const char *counterpath, i else if (NULL != name) { alias_name = zbx_dsprintf(NULL, "__UserPerfCounter[%s]", name); - result = add_alias(name, alias_name); + add_alias(name, alias_name); zbx_free(alias_name); } |