+2017-06-06, Version 5.7.2
+ * Build system: The Notify Email plugin is no longer linked with
+ indirect dependencies. Thanks to Marc Fournier.
+ * collectd: A race condition when calculating a metric's rate has been
+ fixed. Thanks to Florian Forster. #1193
+ * AMQP, Exec, UnixSock, Write Kafka plugins: Parsing of the PUTVAL
+ command with multiple values has been fixed. Thanks to Florian
+ Forster. #2274
+ * AMQP plugin: The "ExchangeType" option is now also valid for
+ publishers. Thanks to Florian Forster. #2286
+ * BIND plugin: Fix parsing of the sample time provided by BIND.
+ Previously, the time was assumed to be in the local timezone when in
+ fact it was in UTC. Thanks to Ed Ravin. #1268
+ * BIND plugin: Memory leaks have been fixed. Thanks to Ruben Kerkhof.
+ #2303
+ * cURL-JSON plugin: Handling of arrays has been fixed. Thanks to Florian
+ Forster. #2266
+ * DPDKStat plugin: Error handling during initialization has been
+ improved. Thanks to Ruben Kerkhof.
+ * DPDKStat plugin: Handling of a number of metrics has been improved,
+ for example "rx_q0bytes". Thanks to Przemyslaw Szczerbik. #2167
+ * Intel RDT plugin: Configuration handling has been changed to be more
+ graceful. Thanks to Maryam Tahhan. #2165
+ * Log Logstash plugin: If writing the log entry fails, print it to
+ "STDERR" instead. Thanks to Marc Fournier.
+ * LogFile plugin: If writing to the file fails, print log messages on
+ "STDERR" instead. Thanks to Marc Fournier.
+ * memcachec, Tail plugins: A resource leak in the matching
+ infrastructure has been fixed. Thanks to Krzysztof Matczak. #2192
+ * MQTT plugin: Invalid symbols in topic names are now replaced and a
+ resource leak has been fixed. Thanks to Denys Fedoryshchenko. #2123
+ * Network plugin: A potential endless-loop has been fixed. This can be
+ triggered remotely by sending a signed network packet to a server
+ which is not set up to check signatures. Thanks to Marcin Kozlowski
+ and Pavel Rochnyack. #2174, #2233, CVE-2017-7401
+ * Perl plugin: A potential double-free has been fixed. Thanks to Florian
+ Forster. #2278
+ * Processes plugin: A compilation error on AIX has been fixed. Thanks to
+ Pavel Rochnyack. #2210
+ * SMART plugin: A check for the "CAP_SYS_RAWIO" capability has been
+ added. Thanks to Marc Fournier.
+ * Write Graphite plugin: Error handling in the case that calculating a
+ metric's rate fails has been improved. Previously, the raw counter
+ values were sent to Graphite. Thanks to Iain Buclaw. #2209
+ * Write Prometheus plugin: An incorrect use of "realloc(3)" has been
+ fixed. Thanks to Florian Forster. #2275
+
2017-01-23, Version 5.7.1
* collectd: Handling of boolean configuration options has been unified.
Thanks to Sebastian Harl. #2083, #2098
liblookup.la \
libmetadata.la \
libmount.la \
- liboconfig.la \
+ liboconfig.la
+
+
+check_LTLIBRARIES = \
libplugin_mock.la
if BUILD_PLUGIN_IPVS
pkglib_LTLIBRARIES += ipvs.la
ipvs_la_SOURCES = src/ipvs.c
-ipvs_la_CFLAGS = $(AM_CFLAGS)
-if IP_VS_H_NEEDS_KERNEL_CFLAGS
-ipvs_la_CFLAGS += $(KERNEL_CFLAGS)
-endif
ipvs_la_LDFLAGS = $(PLUGIN_LDFLAGS)
endif
AM_CONDITIONAL([BUILD_OPENBSD], [test "x$ac_system" = "xOpenBSD"])
AM_CONDITIONAL([BUILD_SOLARIS], [test "x$ac_system" = "xSolaris"])
-if test "x$ac_system" = "xLinux"; then
- AC_ARG_VAR([KERNEL_DIR], [path to Linux kernel sources])
- if test "x$KERNEL_DIR" = "x"; then
- KERNEL_DIR="/lib/modules/`uname -r`/source"
- fi
- KERNEL_CFLAGS="-I$KERNEL_DIR/include"
- AC_SUBST([KERNEL_CFLAGS])
-fi
-
if test "x$ac_system" = "xSolaris"; then
AC_DEFINE([_POSIX_PTHREAD_SEMANTICS], [1], [Define to enforce POSIX thread semantics under Solaris.])
AC_DEFINE([_REENTRANT], [1], [Define to enable reentrancy interfaces.])
#endif
]]
)
-
+
AC_CHECK_HEADERS([linux/inet_diag.h], [], [],
[[
#if HAVE_SYS_TYPES_H
#endif
]]
)
-
+
AC_CHECK_HEADERS([linux/netdevice.h], [], [],
[[
#if HAVE_SYS_TYPES_H
#endif
]]
)
-
+
# For ethstat module
AC_CHECK_HEADERS([linux/sockios.h],
[have_linux_sockios_h="yes"],
#endif
]]
)
-
+
AC_CHECK_HEADERS([linux/ethtool.h],
[have_linux_ethtool_h="yes"],
[have_linux_ethtool_h="no"],
)
# For ipvs module
- AC_CHECK_HEADERS([linux/ip_vs.h], [have_linux_ip_vs_h="yes"], [have_linux_ip_vs="no"])
- AC_CHECK_HEADERS([net/ip_vs.h], [have_net_ip_vs_h="yes"], [have_net_ip_vs_h="no"])
- AC_CHECK_HEADERS([ip_vs.h], [have_ip_vs_h="yes"], [have_ip_vs_h="no"])
-
- ip_vs_h_needs_kernel_cflags="no"
-
- if test "x$have_linux_ip_vs_h$have_net_ip_vs_h$have_ip_vs_h" = "xnonono" && test -d "$KERNEL_DIR"; then
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $KERNEL_CFLAGS"
-
- AC_MSG_NOTICE([Did not find ip_vs.h. Trying again using headers from $KERNEL_DIR.])
-
- AC_CHECK_HEADERS([linux/ip_vs.h], [have_linux_ip_vs_h="yes"])
- AC_CHECK_HEADERS([net/ip_vs.h], [have_net_ip_vs_h="yes"])
- AC_CHECK_HEADERS([ip_vs.h], [have_ip_vs_h="yes"])
-
- if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"; then
- ip_vs_h_needs_kernel_cflags="yes"
- fi
-
- CFLAGS="$SAVE_CFLAGS"
- fi
+ AC_CHECK_HEADERS_ONCE([linux/ip_vs.h])
# For the email plugin
AC_CHECK_HEADERS([linux/un.h], [], [],
[have_asm_msrindex_h="yes"],
[have_asm_msrindex_h="no"]
)
-
+
if test "x$have_asm_msrindex_h" = "xyes"; then
AC_CACHE_CHECK([whether asm/msr-index.h has MSR_PKG_C10_RESIDENCY],
[c_cv_have_usable_asm_msrindex_h],
]
)
fi
-
+
AC_CHECK_HEADERS([cpuid.h],
[have_cpuid_h="yes"],
[have_cpuid_h="no (cpuid.h not found)"]
)
-
+
AC_CHECK_HEADERS([sys/capability.h],
[have_capability="yes"],
[have_capability="no (<sys/capability.h> not found)"]
have_linux_wireless_h="no"
fi
-AM_CONDITIONAL([IP_VS_H_NEEDS_KERNEL_CFLAGS], [test "x$ip_vs_h_needs_kernel_cflags" = "xyes"])
AM_CONDITIONAL([BUILD_WITH_CAPABILITY], [test "x$have_capability" = "xyes"])
# For the swap module
uint64_t i1;
uint8_t c[8];
double d;
-
+
d = 8.642135e130;
memcpy ((void *) &i0, (void *) &d, 8);
-
+
i1 = endianflip (i0);
memcpy ((void *) c, (void *) &i1, 8);
-
+
if ((c[0] == 0x2f) && (c[1] == 0x25)
&& (c[2] == 0xc0) && (c[3] == 0xc7)
&& (c[4] == 0x43) && (c[5] == 0x2b)
uint64_t i1;
uint8_t c[8];
double d;
-
+
d = 8.642135e130;
memcpy ((void *) &i0, (void *) &d, 8);
-
+
i1 = intswap (i0);
memcpy ((void *) c, (void *) &i1, 8);
-
+
if ((c[0] == 0x2f) && (c[1] == 0x25)
&& (c[2] == 0xc0) && (c[3] == 0xc7)
&& (c[4] == 0x43) && (c[5] == 0x2b)
plugin_wireless="yes"
plugin_zfs_arc="yes"
- if test "x$have_linux_ip_vs_h" = "xyes" || test "x$have_net_ip_vs_h" = "xyes" || test "x$have_ip_vs_h" = "xyes"; then
+ if test "x$ac_cv_header_linux_ip_vs_h" = "xyes"; then
plugin_ipvs="yes"
fi
if test "x$c_cv_have_usable_asm_msrindex_h" = "xyes" && test "x$have_cpuid_h" = "xyes"; then
plugin_turbostat="yes"
fi
-
+
if test "x$c_cv_have_clock_boottime_monotonic" = "xyes"; then
plugin_cpusleep="yes"
fi
AC_SUBST([LOAD_PLUGIN_LOGFILE])
AC_SUBST([LOAD_PLUGIN_LOG_LOGSTASH])
-if test "x$enable_debug" = "xyes"
-then
+if test "x$enable_debug" = "xyes"; then
DEFAULT_LOG_LEVEL="debug"
else
DEFAULT_LOG_LEVEL="info"
AC_SUBST([LOAD_PLUGIN_NETWORK])
AC_SUBST([LOAD_PLUGIN_CSV])
-dnl ip_vs.h
-if test "x$ac_system" = "xLinux" && test "x$have_linux_ip_vs_h" = "xno" && "x$have_net_ip_vs_h" = "xno" && "x$have_ip_vs_h" = "xno"; then
- enable_ipvs="$enable_ipvs (ip_vs.h not found)"
-fi
-
-if test "x$ip_vs_h_needs_kernel_cflags" = "xyes"; then
- enable_ipvs="$enable_ipvs (needs $KERNEL_CFLAGS)"
-fi
-
dnl Perl bindings
PERL_BINDINGS_OPTIONS="PREFIX=${prefix}"
AC_ARG_WITH(perl-bindings, [AS_HELP_STRING([--with-perl-bindings@<:@=OPTIONS@:>@], [Options passed to "perl Makefile.PL".])],
[
- if test "x$withval" != "xno" && test "x$withval" != "xyes"
- then
+ if test "x$withval" != "xno" && test "x$withval" != "xyes"; then
PERL_BINDINGS_OPTIONS="$withval"
with_perl_bindings="yes"
else
fi
],
[
- if test "x$PERL" != "x"
- then
+ if test "x$PERL" != "x"; then
with_perl_bindings="yes"
else
with_perl_bindings="no (no perl interpreter found)"
fi
fi
-if test "x$with_perl_bindings" = "xyes"
-then
+if test "x$with_perl_bindings" = "xyes"; then
PERL_BINDINGS="perl"
else
PERL_BINDINGS=""
char recvline[1024];
char *tokptr;
char *toksaveptr;
- _Bool retry = 1;
+ int try = 0;
int status;
#if APCMAIN
#define PRINT_VALUE(name, val) /**/
#endif
- while (retry) {
+ while (1) {
if (global_sockfd < 0) {
global_sockfd = net_open(node, service);
if (global_sockfd < 0) {
status = net_send(&global_sockfd, "status", strlen("status"));
if (status != 0) {
- /* net_send is closing the socket on error. */
+ /* net_send closes the socket on error. */
assert(global_sockfd < 0);
- if (retry) {
- retry = 0;
+ if (try == 0) {
+ try++;
count_retries++;
continue;
}
}
break;
- } /* while (retry) */
+ } /* while (1) */
/* When collectd's collection interval is larger than apcupsd's
* timeout, we would have to retry / re-connect each iteration. Try to
Collect "std_traffic" "hr_users"
</Host>
<Host "secure.router.mydomain.org">
- Address "192.168.0.7"
+ Address "192.168.0.7:165"
Version 3
SecurityLevel "authPriv"
Username "cosmo"
Collect "std_traffic"
</Host>
<Host "some.ups.mydomain.org">
- Address "192.168.0.3"
+ Address "tcp:192.168.0.3"
Version 1
Community "more_communities"
Collect "powerplus_voltge_input"
=item B<Address> I<IP-Address>|I<Hostname>
-Set the address to connect to.
+Set the address to connect to. Address may include transport specifier and/or
+port number.
=item B<Version> B<1>|B<2>|B<3>
* Private functions
*/
static int email_config(const char *key, const char *value) {
- if (0 == strcasecmp(key, "SocketFile")) {
- if (NULL != sock_file)
+ if (strcasecmp(key, "SocketFile") == 0) {
+ if (sock_file != NULL)
free(sock_file);
sock_file = sstrdup(value);
- } else if (0 == strcasecmp(key, "SocketGroup")) {
- if (NULL != sock_group)
+ } else if (strcasecmp(key, "SocketGroup") == 0) {
+ if (sock_group != NULL)
free(sock_group);
sock_group = sstrdup(value);
- } else if (0 == strcasecmp(key, "SocketPerms")) {
+ } else if (strcasecmp(key, "SocketPerms") == 0) {
/* the user is responsible for providing reasonable values */
sock_perms = (int)strtol(value, NULL, 8);
- } else if (0 == strcasecmp(key, "MaxConns")) {
+ } else if (strcasecmp(key, "MaxConns") == 0) {
long int tmp = strtol(value, NULL, 0);
if (tmp < 1) {
/* Increment the value of the given name in the given list by incr. */
static void type_list_incr(type_list_t *list, char *name, int incr) {
- if (NULL == list->head) {
+ if (list->head == NULL) {
list->head = smalloc(sizeof(*list->head));
list->head->name = sstrdup(name);
type_t *ptr;
for (ptr = list->head; NULL != ptr; ptr = ptr->next) {
- if (0 == strcmp(name, ptr->name))
+ if (strcmp(name, ptr->name) == 0)
break;
}
- if (NULL == ptr) {
+ if (ptr == NULL) {
list->tail->next = smalloc(sizeof(*list->tail->next));
list->tail = list->tail->next;
pthread_mutex_lock(&conns_mutex);
- while (NULL == conns.head) {
+ while (conns.head == NULL) {
pthread_cond_wait(&conn_available, &conns_mutex);
}
connection = conns.head;
conns.head = conns.head->next;
- if (NULL == conns.head) {
+ if (conns.head == NULL) {
conns.tail = NULL;
}
int len = 0;
errno = 0;
- if (NULL == fgets(line, sizeof(line), this->socket)) {
- if (0 != errno) {
+ if (fgets(line, sizeof(line), this->socket) == NULL) {
+ if (errno != 0) {
char errbuf[1024];
log_err("collect: reading from socket (fd #%i) "
"failed: %s",
}
len = strlen(line);
- if (('\n' != line[len - 1]) && ('\r' != line[len - 1])) {
+ if ((line[len - 1] != '\n') && (line[len - 1] != '\r')) {
log_warn("collect: line too long (> %zu characters): "
"'%s' (truncated)",
sizeof(line) - 1, line);
- while (NULL != fgets(line, sizeof(line), this->socket))
- if (('\n' == line[len - 1]) || ('\r' == line[len - 1]))
+ while (fgets(line, sizeof(line), this->socket) != NULL)
+ if ((line[len - 1] == '\n') || (line[len - 1] == '\r'))
break;
continue;
}
log_debug("collect: line = '%s'", line);
- if (':' != line[1]) {
+ if (line[1] != ':') {
log_err("collect: syntax error in line '%s'", line);
continue;
}
- if ('e' == line[0]) { /* e:<type>:<bytes> */
+ if (line[0] == 'e') { /* e:<type>:<bytes> */
char *ptr = NULL;
char *type = strtok_r(line + 2, ":", &ptr);
char *tmp = strtok_r(NULL, ":", &ptr);
int bytes = 0;
- if (NULL == tmp) {
+ if (tmp == NULL) {
log_err("collect: syntax error in line '%s'", line);
continue;
}
type_list_incr(&list_size, type, /* increment = */ bytes);
pthread_mutex_unlock(&size_mutex);
}
- } else if ('s' == line[0]) { /* s:<value> */
+ } else if (line[0] == 's') { /* s:<value> */
pthread_mutex_lock(&score_mutex);
score = (score * (double)score_count + atof(line + 2)) /
(double)(score_count + 1);
++score_count;
pthread_mutex_unlock(&score_mutex);
- } else if ('c' == line[0]) { /* c:<type1>[,<type2>,...] */
+ } else if (line[0] == 'c') { /* c:<type1>[,<type2>,...] */
char *dummy = line + 2;
char *endptr = NULL;
char *type;
/* create UNIX socket */
errno = 0;
- if (-1 == (connector_socket = socket(PF_UNIX, SOCK_STREAM, 0))) {
+ if ((connector_socket = socket(PF_UNIX, SOCK_STREAM, 0)) == -1) {
char errbuf[1024];
disabled = 1;
log_err("socket() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
sstrncpy(addr.sun_path, path, (size_t)(UNIX_PATH_MAX - 1));
errno = 0;
- if (-1 ==
- bind(connector_socket, (struct sockaddr *)&addr,
- offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path))) {
+ if (bind(connector_socket, (struct sockaddr *)&addr,
+ offsetof(struct sockaddr_un, sun_path) + strlen(addr.sun_path)) == -1) {
char errbuf[1024];
disabled = 1;
close(connector_socket);
}
errno = 0;
- if (-1 == listen(connector_socket, 5)) {
+ if (listen(connector_socket, 5) == -1) {
char errbuf[1024];
disabled = 1;
close(connector_socket);
{
struct group sg;
struct group *grp;
- char grbuf[2048];
+ char grbuf[4096];
int status;
grp = NULL;
if (status != 0) {
char errbuf[1024];
log_warn("getgrnam_r (%s) failed: %s", group,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ sstrerror(status, errbuf, sizeof(errbuf)));
} else if (grp == NULL) {
log_warn("No such group: `%s'", group);
} else {
}
errno = 0;
- if (0 != chmod(path, sock_perms)) {
+ if (chmod(path, sock_perms) != 0) {
char errbuf[1024];
log_warn("chmod() failed: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
}
pthread_mutex_lock(&available_mutex);
- while (0 == available_collectors) {
+ while (available_collectors == 0) {
pthread_cond_wait(&collector_available, &available_mutex);
}
connection->socket = fdopen(remote, "r");
connection->next = NULL;
- if (NULL == connection->socket) {
+ if (connection->socket == NULL) {
close(remote);
sfree(connection);
continue;
pthread_mutex_lock(&conns_mutex);
- if (NULL == conns.head) {
+ if (conns.head == NULL) {
conns.head = connection;
conns.tail = connection;
} else {
type_list_free(&list_check);
type_list_free(&list_check_copy);
- unlink((NULL == sock_file) ? SOCK_PATH : sock_file);
+ unlink((sock_file == NULL) ? SOCK_PATH : sock_file);
sfree(sock_file);
sfree(sock_group);
static void copy_type_list(type_list_t *l1, type_list_t *l2) {
type_t *last = NULL;
- for (type_t *ptr1 = l1->head, *ptr2 = l2->head; NULL != ptr1;
+ for (type_t *ptr1 = l1->head, *ptr2 = l2->head; ptr1 != NULL;
ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
- if (NULL == ptr2) {
+ if (ptr2 == NULL) {
ptr2 = smalloc(sizeof(*ptr2));
ptr2->name = NULL;
ptr2->next = NULL;
- if (NULL == last) {
+ if (last == NULL) {
l2->head = ptr2;
} else {
last->next = ptr2;
l2->tail = ptr2;
}
- if (NULL == ptr2->name) {
+ if (ptr2->name == NULL) {
ptr2->name = sstrdup(ptr1->name);
}
pthread_mutex_unlock(&count_mutex);
- for (type_t *ptr = list_count_copy.head; NULL != ptr; ptr = ptr->next) {
+ for (type_t *ptr = list_count_copy.head; ptr != NULL; ptr = ptr->next) {
email_submit("email_count", ptr->name, ptr->value);
}
pthread_mutex_unlock(&size_mutex);
- for (type_t *ptr = list_size_copy.head; NULL != ptr; ptr = ptr->next) {
+ for (type_t *ptr = list_size_copy.head; ptr != NULL; ptr = ptr->next) {
email_submit("email_size", ptr->name, ptr->value);
}
pthread_mutex_unlock(&check_mutex);
- for (type_t *ptr = list_check_copy.head; NULL != ptr; ptr = ptr->next)
+ for (type_t *ptr = list_check_copy.head; ptr != NULL; ptr = ptr->next)
email_submit("spam_check", ptr->name, ptr->value);
return 0;
struct passwd *sp_ptr;
struct passwd sp;
- char nambuf[2048];
+ char nambuf[4096];
if (pl->pid != 0)
return -1;
status = getpwnam_r(pl->user, &sp, nambuf, sizeof(nambuf), &sp_ptr);
if (status != 0) {
ERROR("exec plugin: Failed to get user information for user ``%s'': %s",
- pl->user, sstrerror(errno, errbuf, sizeof(errbuf)));
+ pl->user, sstrerror(status, errbuf, sizeof(errbuf)));
goto failed;
}
/* The group configured in the configfile is set as effective group, because
* this way the forked process can (re-)gain the user's primary group. */
egid = -1;
- if (NULL != pl->group) {
- if ('\0' != *pl->group) {
+ if (pl->group != NULL) {
+ if (*pl->group != '\0') {
struct group *gr_ptr = NULL;
struct group gr;
status = getgrnam_r(pl->group, &gr, nambuf, sizeof(nambuf), &gr_ptr);
- if (0 != status) {
+ if (status != 0) {
ERROR("exec plugin: Failed to get group information "
"for group ``%s'': %s",
- pl->group, sstrerror(errno, errbuf, sizeof(errbuf)));
+ pl->group, sstrerror(status, errbuf, sizeof(errbuf)));
goto failed;
}
- if (NULL == gr_ptr) {
+ if (gr_ptr == NULL) {
ERROR("exec plugin: No such group: `%s'", pl->group);
goto failed;
}
#include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
-/* this can probably only be found in the kernel sources */
-#if HAVE_LINUX_IP_VS_H
#include <linux/ip_vs.h>
-#elif HAVE_NET_IP_VS_H
-#include <net/ip_vs.h>
-#elif HAVE_IP_VS_H
-#include <ip_vs.h>
-#endif /* HAVE_IP_VS_H */
#define log_err(...) ERROR("ipvs: " __VA_ARGS__)
#define log_info(...) INFO("ipvs: " __VA_ARGS__)
*/
static struct ip_vs_get_services *ipvs_get_services(void) {
struct ip_vs_getinfo ipvs_info;
- struct ip_vs_get_services *ret;
+ struct ip_vs_get_services *services;
- socklen_t len;
+ socklen_t len = sizeof(ipvs_info);
- len = sizeof(ipvs_info);
-
- if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, (void *)&ipvs_info,
- &len)) {
+ if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
+ -1) {
char errbuf[1024];
log_err("ip_vs_get_services: getsockopt() failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
return NULL;
}
- len = sizeof(*ret) +
+ len = sizeof(*services) +
sizeof(struct ip_vs_service_entry) * ipvs_info.num_services;
- if (NULL == (ret = malloc(len))) {
+ services = malloc(len);
+ if (services == NULL) {
log_err("ipvs_get_services: Out of memory.");
- exit(3);
+ return NULL;
}
- ret->num_services = ipvs_info.num_services;
+ services->num_services = ipvs_info.num_services;
- if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES, (void *)ret,
- &len)) {
+ if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_SERVICES, services, &len) ==
+ -1) {
char errbuf[1024];
log_err("ipvs_get_services: getsockopt failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- free(ret);
+ free(services);
return NULL;
}
- return ret;
+ return services;
} /* ipvs_get_services */
static struct ip_vs_get_dests *ipvs_get_dests(struct ip_vs_service_entry *se) {
- struct ip_vs_get_dests *ret;
- socklen_t len;
+ struct ip_vs_get_dests *dests;
- len = sizeof(*ret) + sizeof(struct ip_vs_dest_entry) * se->num_dests;
+ socklen_t len =
+ sizeof(*dests) + sizeof(struct ip_vs_dest_entry) * se->num_dests;
- if (NULL == (ret = malloc(len))) {
+ dests = malloc(len);
+ if (dests == NULL) {
log_err("ipvs_get_dests: Out of memory.");
- exit(3);
+ return NULL;
}
- ret->fwmark = se->fwmark;
- ret->protocol = se->protocol;
- ret->addr = se->addr;
- ret->port = se->port;
- ret->num_dests = se->num_dests;
+ dests->fwmark = se->fwmark;
+ dests->protocol = se->protocol;
+ dests->addr = se->addr;
+ dests->port = se->port;
+ dests->num_dests = se->num_dests;
- if (0 !=
- getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS, (void *)ret, &len)) {
+ if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_DESTS, dests, &len) == -1) {
char errbuf[1024];
log_err("ipvs_get_dests: getsockopt() failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
- free(ret);
+ free(dests);
return NULL;
}
- return ret;
+ return dests;
} /* ip_vs_get_dests */
/*
static int cipvs_init(void) {
struct ip_vs_getinfo ipvs_info;
- socklen_t len;
-
- if (-1 == (sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW))) {
+ if ((sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) == -1) {
char errbuf[1024];
log_err("cipvs_init: socket() failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
return -1;
}
- len = sizeof(ipvs_info);
+ socklen_t len = sizeof(ipvs_info);
- if (0 != getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, (void *)&ipvs_info,
- &len)) {
+ if (getsockopt(sockfd, IPPROTO_IP, IP_VS_SO_GET_INFO, &ipvs_info, &len) ==
+ -1) {
char errbuf[1024];
log_err("cipvs_init: getsockopt() failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
/* plugin instance */
static int get_pi(struct ip_vs_service_entry *se, char *pi, size_t size) {
- struct in_addr addr;
- int len = 0;
-
- if ((NULL == se) || (NULL == pi))
+ if ((se == NULL) || (pi == NULL))
return 0;
- addr.s_addr = se->addr;
+ struct in_addr addr = {.s_addr = se->addr};
- /* inet_ntoa() returns a pointer to a statically allocated buffer
- * I hope non-glibc systems behave the same */
- len =
+ int len =
ssnprintf(pi, size, "%s_%s%u", inet_ntoa(addr),
(se->protocol == IPPROTO_TCP) ? "TCP" : "UDP", ntohs(se->port));
- if ((0 > len) || (size <= ((size_t)len))) {
+ if ((len < 0) || (size <= ((size_t)len))) {
log_err("plugin instance truncated: %s", pi);
return -1;
}
/* type instance */
static int get_ti(struct ip_vs_dest_entry *de, char *ti, size_t size) {
- struct in_addr addr;
- int len = 0;
-
- if ((NULL == de) || (NULL == ti))
+ if ((de == NULL) || (ti == NULL))
return 0;
- addr.s_addr = de->addr;
+ struct in_addr addr = {.s_addr = de->addr};
- /* inet_ntoa() returns a pointer to a statically allocated buffer
- * I hope non-glibc systems behave the same */
- len = ssnprintf(ti, size, "%s_%u", inet_ntoa(addr), ntohs(de->port));
+ int len = ssnprintf(ti, size, "%s_%u", inet_ntoa(addr), ntohs(de->port));
- if ((0 > len) || (size <= ((size_t)len))) {
+ if ((len < 0) || (size <= ((size_t)len))) {
log_err("type instance truncated: %s", ti);
return -1;
}
sstrncpy(vl.plugin, "ipvs", sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, pi, sizeof(vl.plugin_instance));
sstrncpy(vl.type, "connections", sizeof(vl.type));
- sstrncpy(vl.type_instance, (NULL != ti) ? ti : "total",
+ sstrncpy(vl.type_instance, (ti != NULL) ? ti : "total",
sizeof(vl.type_instance));
plugin_dispatch_values(&vl);
- return;
} /* cipvs_submit_connections */
static void cipvs_submit_if(const char *pi, const char *t, const char *ti,
sstrncpy(vl.plugin, "ipvs", sizeof(vl.plugin));
sstrncpy(vl.plugin_instance, pi, sizeof(vl.plugin_instance));
sstrncpy(vl.type, t, sizeof(vl.type));
- sstrncpy(vl.type_instance, (NULL != ti) ? ti : "total",
+ sstrncpy(vl.type_instance, (ti != NULL) ? ti : "total",
sizeof(vl.type_instance));
plugin_dispatch_values(&vl);
- return;
} /* cipvs_submit_if */
static void cipvs_submit_dest(const char *pi, struct ip_vs_dest_entry *de) {
char ti[DATA_MAX_NAME_LEN];
- if (0 != get_ti(de, ti, sizeof(ti)))
+ if (get_ti(de, ti, sizeof(ti)) != 0)
return;
cipvs_submit_connections(pi, ti, stats.conns);
cipvs_submit_if(pi, "if_packets", ti, stats.inpkts, stats.outpkts);
cipvs_submit_if(pi, "if_octets", ti, stats.inbytes, stats.outbytes);
- return;
} /* cipvs_submit_dest */
static void cipvs_submit_service(struct ip_vs_service_entry *se) {
char pi[DATA_MAX_NAME_LEN];
- if (0 != get_pi(se, pi, sizeof(pi))) {
+ if (get_pi(se, pi, sizeof(pi)) != 0) {
free(dests);
return;
}
} /* cipvs_submit_service */
static int cipvs_read(void) {
- struct ip_vs_get_services *services = NULL;
-
if (sockfd < 0)
return -1;
- if (NULL == (services = ipvs_get_services()))
+ struct ip_vs_get_services *services = ipvs_get_services();
+ if (services == NULL)
return -1;
for (size_t i = 0; i < services->num_services; ++i)
if (rc != LDAP_SUCCESS) {
ERROR("openldap plugin: ldap_initialize failed: %s", ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(ld, NULL, NULL);
- return -1;
+ if (ld != NULL)
+ ldap_unbind_ext_s(ld, NULL, NULL);
+ return (-1);
}
st->ld = ld;
ERROR("openldap plugin: Failed to start tls on %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
- return -1;
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return (-1);
}
}
ERROR("openldap plugin: Failed to bind to %s: %s", st->url,
ldap_err2string(rc));
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
- return -1;
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return (-1);
} else {
DEBUG("openldap plugin: Successfully connected to %s", st->url);
st->state = 1;
ERROR("openldap plugin: Failed to execute search: %s", ldap_err2string(rc));
ldap_msgfree(result);
st->state = 0;
- ldap_unbind_ext_s(st->ld, NULL, NULL);
- return -1;
+ if (st->ld != NULL)
+ ldap_unbind_ext_s(st->ld, NULL, NULL);
+ return (-1);
}
for (LDAPMessage *e = ldap_first_entry(st->ld, result); e != NULL;
DEBUG(PLUGIN_NAME ": Type: %s", dd->type);
if (dd->type_instance)
DEBUG(PLUGIN_NAME ": TypeInstance: %s", dd->type_instance);
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]);
DEBUG(PLUGIN_NAME ": OID[%d]: %s", i, oid_str);
}
DEBUG(PLUGIN_NAME ": Type: %s", dd->type);
if (dd->type_instance)
DEBUG(PLUGIN_NAME ": TypeInstance: %s", dd->type_instance);
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
snmp_agent_oid_to_string(oid_str, sizeof(oid_str), &dd->oids[i]);
DEBUG(PLUGIN_NAME ": OID[%d]: %s", i, oid_str);
}
return 0;
}
-static void snmp_agent_generate_oid2string(oid_t *oid, int offset, char *key) {
+static void snmp_agent_generate_oid2string(oid_t *oid, size_t offset, char *key) {
int key_len = oid->oid[offset];
int i;
for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
data_definition_t *dd = de->value;
- for (int i = 0; i < dd->oids_len; i++)
+ for (size_t i = 0; i < dd->oids_len; i++)
if (td->index_oid.oid_len)
snmp_agent_unregister_oid_index(&dd->oids[i], *index);
else
/* unregister scalar type OID */
if ((*dd)->table == NULL) {
- for (int i = 0; i < (*dd)->oids_len; i++)
+ for (size_t i = 0; i < (*dd)->oids_len; i++)
unregister_mib((*dd)->oids[i].oid, (*dd)->oids[i].oid_len);
}
if (!(*dd)->table->index_oid.oid_len) {
c_avl_iterator_t *iter = c_avl_get_iterator((*dd)->table->instance_index);
while (c_avl_iterator_next(iter, (void *)&instance, (void *)&instance) ==
0) {
- for (int i = 0; i < (*dd)->oids_len; i++)
+ for (size_t i = 0; i < (*dd)->oids_len; i++)
snmp_agent_unregister_oid_string(&(*dd)->oids[i], instance);
}
c_avl_iterator_destroy(iter);
c_avl_iterator_t *iter = c_avl_get_iterator((*dd)->table->index_instance);
while (c_avl_iterator_next(iter, (void *)&index, (void *)&value) == 0) {
- for (int i = 0; i < (*dd)->oids_len; i++)
+ for (size_t i = 0; i < (*dd)->oids_len; i++)
snmp_agent_unregister_oid_index(&(*dd)->oids[i], *index);
}
c_avl_iterator_destroy(iter);
}
assert(ds->ds_num == values_num);
- assert(oid_index < values_num);
+ assert(oid_index < (int)values_num);
char data[DATA_MAX_NAME_LEN];
size_t data_len = sizeof(data);
}
requests->requestvb->type = dd->oids[oid_index].type;
- snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type, data,
- data_len);
+ snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
+ (const u_char *)data, data_len);
return SNMP_ERR_NOERROR;
}
for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
data_definition_t *dd = de->value;
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
int ret = snmp_oid_ncompare(oid.oid, oid.oid_len, dd->oids[i].oid,
dd->oids[i].oid_len,
MIN(oid.oid_len, dd->oids[i].oid_len));
if (dd->is_instance) {
requests->requestvb->type = ASN_OCTET_STR;
snmp_set_var_typed_value(requests->requestvb,
- requests->requestvb->type, instance,
+ requests->requestvb->type, (const u_char *)instance,
strlen((instance)));
pthread_mutex_unlock(&g_agent->lock);
requests->requestvb->type = ASN_INTEGER;
snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
- &index, sizeof(index));
+ (const u_char *)&index, sizeof(index));
pthread_mutex_unlock(&g_agent->lock);
requests->requestvb->type = td->size_oid.type;
snmp_set_var_typed_value(requests->requestvb, requests->requestvb->type,
- &size, sizeof(size));
+ (const u_char *)&size, sizeof(size));
pthread_mutex_unlock(&g_agent->lock);
de = de->next) {
data_definition_t *dd = de->value;
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
int ret = snmp_oid_compare(oid.oid, oid.oid_len, dd->oids[i].oid,
dd->oids[i].oid_len);
for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
data_definition_t *dd = de->value;
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
dd->oids[i].type =
snmp_agent_get_asn_type(dd->oids[i].oid, dd->oids[i].oid_len);
}
for (llentry_t *e = llist_head(g_agent->scalars); e != NULL; e = e->next) {
data_definition_t *dd = e->value;
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
dd->oids[i].type =
snmp_agent_get_asn_type(dd->oids[i].oid, dd->oids[i].oid_len);
for (llentry_t *de = llist_head(td->columns); de != NULL; de = de->next) {
data_definition_t *dd = de->value;
- for (int i = 0; i < dd->oids_len; i++) {
+ for (size_t i = 0; i < dd->oids_len; i++) {
if (td->index_oid.oid_len) {
ret = snmp_agent_register_oid_index(&dd->oids[i], *index,
snmp_agent_table_oid_handler);
for (in_ptr = (struct xinpgen *)(((char *)in_orig) + in_orig->xig_len);
in_ptr->xig_len > sizeof(struct xinpgen);
in_ptr = (struct xinpgen *)(((char *)in_ptr) + in_ptr->xig_len)) {
+#if __FreeBSD_version >= 1200026
+ struct xtcpcb *tp = (struct xtcpcb *)in_ptr;
+ struct xinpcb *inp = &tp->xt_inp;
+ struct xsocket *so = &inp->xi_socket;
+#else
struct tcpcb *tp = &((struct xtcpcb *)in_ptr)->xt_tp;
struct inpcb *inp = &((struct xtcpcb *)in_ptr)->xt_inp;
struct xsocket *so = &((struct xtcpcb *)in_ptr)->xt_socket;
+#endif
/* Ignore non-TCP sockets */
if (so->xso_protocol != IPPROTO_TCP)
const char *grpname;
struct group *g;
struct group sg;
- char grbuf[2048];
+ char grbuf[4096];
grpname = (sock_group != NULL) ? sock_group : COLLECTD_GRP_NAME;
g = NULL;
if (status != 0) {
char errbuf[1024];
WARNING("unixsock plugin: getgrnam_r (%s) failed: %s", grpname,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ sstrerror(status, errbuf, sizeof(errbuf)));
break;
}
if (g == NULL) {
size_t error_location;
if (!bson_validate(ret, BSON_VALIDATE_UTF8, &error_location)) {
ERROR("write_mongodb plugin: Error in generated BSON document "
- "at byte %zu", error_location);
+ "at byte %zu",
+ error_location);
bson_destroy(ret);
return NULL;
}
static int wm_initialize(wm_node_t *node) /* {{{ */
{
char *uri;
- size_t uri_length;
- char const *format_string;
- if (node->connected) {
+ if (node->connected)
return 0;
- }
- INFO("write_mongodb plugin: Connecting to [%s]:%i",
- (node->host != NULL) ? node->host : "localhost",
- (node->port != 0) ? node->port : MONGOC_DEFAULT_PORT);
+ INFO("write_mongodb plugin: Connecting to [%s]:%d", node->host, node->port);
if ((node->db != NULL) && (node->user != NULL) && (node->passwd != NULL)) {
- format_string = "mongodb://%s:%s@%s:%d/?authSource=%s";
- uri_length = strlen(format_string) + strlen(node->user) +
- strlen(node->passwd) + strlen(node->host) + 5 +
- strlen(node->db) + 1;
- if ((uri = calloc(1, uri_length)) == NULL) {
+ uri = ssnprintf_alloc("mongodb://%s:%s@%s:%d/?authSource=%s", node->user,
+ node->passwd, node->host, node->port, node->db);
+ if (uri == NULL) {
ERROR("write_mongodb plugin: Not enough memory to assemble "
"authentication string.");
mongoc_client_destroy(node->client);
node->connected = 0;
return -1;
}
- ssnprintf(uri, uri_length, format_string, node->user, node->passwd,
- node->host, node->port, node->db);
node->client = mongoc_client_new(uri);
if (!node->client) {
- ERROR("write_mongodb plugin: Authenticating to [%s]%i for database "
+ ERROR("write_mongodb plugin: Authenticating to [%s]:%d for database "
"\"%s\" as user \"%s\" failed.",
- (node->host != NULL) ? node->host : "localhost",
- (node->port != 0) ? node->port : MONGOC_DEFAULT_PORT, node->db,
- node->user);
+ node->host, node->port, node->db, node->user);
node->connected = 0;
sfree(uri);
return -1;
}
} else {
- format_string = "mongodb://%s:%d";
- uri_length = strlen(format_string) + strlen(node->host) + 5 + 1;
- if ((uri = calloc(1, uri_length)) == NULL) {
+ uri = ssnprintf_alloc("mongodb://%s:%d", node->host, node->port);
+ if (uri == NULL) {
ERROR("write_mongodb plugin: Not enough memory to assemble "
"authentication string.");
mongoc_client_destroy(node->client);
node->connected = 0;
return -1;
}
- snprintf(uri, uri_length, format_string, node->host, node->port);
node->client = mongoc_client_new(uri);
if (!node->client) {
- ERROR("write_mongodb plugin: Connecting to [%s]:%i failed.",
- (node->host != NULL) ? node->host : "localhost",
- (node->port != 0) ? node->port : MONGOC_DEFAULT_PORT);
+ ERROR("write_mongodb plugin: Connecting to [%s]:%d failed.", node->host,
+ node->port);
node->connected = 0;
sfree(uri);
return -1;
}
+ sfree(uri);
}
- sfree(uri);
node->database = mongoc_client_get_database(node->client, "collectd");
if (!node->database) {
if (node == NULL)
return ENOMEM;
mongoc_init();
- node->host = NULL;
+ node->host = strdup("localhost");
+ if (node->host == NULL) {
+ sfree(node);
+ return ENOMEM;
+ }
+ node->port = MONGOC_DEFAULT_PORT;
node->store_rates = 1;
pthread_mutex_init(&node->lock, /* attr = */ NULL);
status = cf_util_get_string_buffer(ci, node->name, sizeof(node->name));
if (status != 0) {
+ sfree(node->host);
sfree(node);
return status;
}
ssnprintf(cb_name, sizeof(cb_name), "write_mongodb/%s", node->name);
- status = plugin_register_write(
- cb_name, wm_write, &(user_data_t){
- .data = node, .free_func = wm_config_free,
- });
+ status =
+ plugin_register_write(cb_name, wm_write,
+ &(user_data_t){
+ .data = node, .free_func = wm_config_free,
+ });
INFO("write_mongodb plugin: registered write plugin %s %d", cb_name,
status);
}
RIEMANN_EVENT_FIELD_SERVICE, &service_buffer[1],
RIEMANN_EVENT_FIELD_NONE);
+#if RCC_VERSION_NUMBER >= 0x010A00
+ riemann_event_set(event, RIEMANN_EVENT_FIELD_TIME_MICROS,
+ (int64_t)CDTIME_T_TO_US(n->time));
+#endif
+
if (n->host[0] != 0)
riemann_event_string_attribute_add(event, "host", n->host);
if (n->plugin[0] != 0)
vl->type, "ds_name", ds->ds[index].name, NULL,
RIEMANN_EVENT_FIELD_SERVICE, service_buffer, RIEMANN_EVENT_FIELD_NONE);
+#if RCC_VERSION_NUMBER >= 0x010A00
+ riemann_event_set(event, RIEMANN_EVENT_FIELD_TIME_MICROS,
+ (int64_t)CDTIME_T_TO_US(vl->time));
+#endif
+
if (host->check_thresholds) {
const char *state = NULL;
#!/bin/sh
-DEFAULT_VERSION="5.7.1.git"
+DEFAULT_VERSION="5.7.2.git"
if [ -d .git ]; then
VERSION="`git describe --dirty=+ --abbrev=7 2> /dev/null | grep collectd | sed -e 's/^collectd-//' -e 's/-/./g'`"