Skip to content

Commit

Permalink
Merge branch 'develop' for release 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ronytomen committed Jan 2, 2019
2 parents 0c7a866 + 2142382 commit c855622
Show file tree
Hide file tree
Showing 16 changed files with 1,067 additions and 779 deletions.
8 changes: 8 additions & 0 deletions ChangeLog → CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
The Cacti Group | spine

1.2.0
-feature: Allow threads to be set a Data Collector level
-issue#50: make fails on Debian 7 attempting to locate clock_gettime
-issue#53: Improved escaping when updating database records
-issue#54: Spine should always log if ICMP fails
-issue#58: When updating snmp_sysLocation, text can become truncated
-issue#63: Automatically reduce device threads when number of data sources does not require it

1.1.38
-feature: release to match Cacti release

Expand Down
432 changes: 99 additions & 333 deletions INSTALL

Large diffs are not rendered by default.

17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Spine: a poller for Cacti
---------------------------

Spine is a high speed poller replacement for `cmd.php`. It is almost 100%
compatible with the legacy cmd.php processor and provides much more
flexibility, speed and concurrency than `cmd.php`.
Expand All @@ -8,6 +8,19 @@ Make sure that you have the proper development environment to compile Spine.
This includes compilers, header files and things such as libtool. If you
have questions please consult the forums and/or online documentation.

-----------------------------------------------------------------------------

## 1.2.0 Development

**PLEASE READ**

Feature branch for `1.2.x` has been merged into the `develop` branch. This means
things may and will break, but they will eventually be fixed.

> DEVELOP branch is currently considered UNSTABLE, use with caution!
-----------------------------------------------------------------------------

## Unix Installation

These instructions assume the default install location for spine
Expand All @@ -22,7 +35,7 @@ please do the following:
make
make install
chown root:root /usr/local/spine/bin/spine
chmod +s /usr/local/spine/bin/spine
chmod u+s /usr/local/spine/bin/spine
```

To compile and install Spine using MySQL versions previous to 5.5
Expand Down
37 changes: 33 additions & 4 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
AC_PREREQ(2.53)
AC_INIT(Spine Poller, 1.1.38, http://www.cacti.net/issues.php)
AC_INIT(Spine Poller, 1.2.0, http://www.cacti.net/issues.php)

AC_CONFIG_AUX_DIR(config)
AC_SUBST(ac_aux_dir)
Expand All @@ -10,7 +10,7 @@ AC_PREFIX_DEFAULT(/usr/local/spine)
AC_LANG(C)

AM_INIT_AUTOMAKE([foreign])
AM_CONFIG_HEADER(config/config.h)
AC_CONFIG_HEADERS(config/config.h)

# static libraries
AC_ARG_WITH(static,
Expand Down Expand Up @@ -67,6 +67,7 @@ case $host_alias in
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS";;
*freebsd*)
LIBS="$LIBS -pthread"
LDFLAGS="-lexecinfo"
AC_DEFINE(HAVE_LIBPTHREAD, 1);;
*darwin*)
ShLib="dylib";;
Expand All @@ -80,7 +81,7 @@ AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_LIBTOOL
LT_INIT

AC_MSG_CHECKING([whether to enable -Wall])
AC_ARG_ENABLE(warnings,
Expand Down Expand Up @@ -127,11 +128,15 @@ AC_CHECK_LIB(z, deflate)
AC_CHECK_LIB(kstat, kstat_close)
AC_CHECK_LIB(crypto, CRYPTO_realloc)

# minor adjustments for debian
AC_SEARCH_LIBS([clock_gettime], [rt pthread])

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(sys/socket.h sys/select.h sys/wait.h sys/time.h)
AC_CHECK_HEADERS(assert.h ctype.h errno.h signal.h math.h malloc.h netdb.h)
AC_CHECK_HEADERS(signal.h stdarg.h stdio.h syslog.h)
AC_CHECK_HEADERS(execinfo.h)
AC_CHECK_HEADERS(
netinet/in_systm.h netinet/in.h netinet/ip.h netinet/ip_icmp.h,
[],
Expand Down Expand Up @@ -177,7 +182,7 @@ if test x$ENABLED_SOL_PRIV != xno; then
if test x$FOUND_PRIV_H != xno; then
AC_MSG_RESULT([yes])
AC_DEFINE([SOLAR_PRIV], [1],
[If upport for Solaris privileges should be enabled]
[If Support for Solaris privileges should be enabled]
)
else
AC_MSG_RESULT([no])
Expand Down Expand Up @@ -470,4 +475,28 @@ if test -z "$HAVE_GETHOSTBYNAME_R"; then
HAVE_GETHOSTBYNAME_R=yes
fi

# See if we can support backtracing
AC_MSG_CHECKING([if we can support backtracing])
AC_TRY_LINK(
[
#include <stdlib.h>
#include <execinfo.h>
],[
void *array[10];
size_t size;
# get void*'s for all entries on the stack
size = backtrace(array, 10);
if (size) {
exit(0);
} else {
exit(1);
}
],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAS_EXECINFO_H,1,[Do we have backtracing capabilities?])
],
AC_MSG_RESULT(no)
)

AC_OUTPUT(Makefile)
7 changes: 7 additions & 0 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
static void spine_signal_handler(int spine_signal) {
signal(spine_signal, SIG_DFL);

#if HAS_EXECINFO_H
// get void*'s for all entries on the stack
set.exit_size = backtrace(set.exit_stack, 10);
#endif

set.exit_code = spine_signal;

switch (spine_signal) {
Expand Down Expand Up @@ -80,6 +85,8 @@ static int spine_fatal_signals[] = {
SIGBUS,
SIGFPE,
SIGQUIT,
SIGSYS,
SIGABRT,
0
};

Expand Down
3 changes: 2 additions & 1 deletion php.c
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,10 @@ int php_init(int php_process) {
php_processes[php_process].php_state = PHP_BUSY;
}
}

free(result_string);
}

free(result_string);

return TRUE;
}
Expand Down
85 changes: 31 additions & 54 deletions ping.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,7 @@ int ping_host(host_t *host, ping_t *ping) {

if (host->ping_method == PING_ICMP) {
if (set.icmp_avail == FALSE) {
if (is_debug_device(host->id)) {
SPINE_LOG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
} else {
SPINE_LOG_DEBUG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
}
SPINE_LOG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
host->ping_method = PING_UDP;
}
}
Expand Down Expand Up @@ -387,26 +383,13 @@ int ping_icmp(host_t *host, ping_t *ping) {
return HOST_DOWN;
}

/* record start time */
if (total_time == 0) {
/* establish timeout value */
timeout.tv_sec = rint(host_timeout / 1000);
timeout.tv_usec = rint((int) host_timeout % 1000) * 1000;

/* set the socket send and receive timeout */
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));

begin_time = get_time_as_double();
} else {
/* decrement the timeout value by the total time */
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;
/* decrement the timeout value by the total time */
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;

/* set the socket send and receive timeout */
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
}
/* set the socket send and receive timeout */
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));

/* send packet to destination */
return_code = sendto(icmp_socket, packet, packet_len, 0, (struct sockaddr *) &fromname, sizeof(fromname));
Expand All @@ -432,21 +415,22 @@ int ping_icmp(host_t *host, ping_t *ping) {

if (return_code < 0) {
if (errno == EINTR) {
/* call was interrupted by some system event */

if (is_debug_device(host->id)) {
SPINE_LOG(("Device[%i] DEBUG: Received EINTR", host->id));
} else {
SPINE_LOG_DEBUG(("Device[%i] DEBUG: Received EINTR", host->id));
}
/* call was interrupted by some system event */
// usleep(10000);

goto keep_listening;
}
} else {
ip = (struct ip *) socket_reply;
pkt = (struct icmp *) (socket_reply + (ip->ip_hl << 2));

if (fromname.sin_addr.s_addr == recvname.sin_addr.s_addr) {
if ((pkt->icmp_type == ICMP_ECHOREPLY)) {
if (pkt->icmp_type == ICMP_ECHOREPLY) {
if (is_debug_device(host->id)) {
SPINE_LOG(("Device[%i] DEBUG: ICMP Device Alive, Try Count:%i, Time:%.4f ms", host->id, retry_count+1, (total_time)));
} else {
Expand Down Expand Up @@ -591,6 +575,8 @@ int ping_udp(host_t *host, ping_t *ping) {
/* set total time */
total_time = 0;

begin_time = get_time_as_double();

/* remove "udp:" from hostname */
new_hostname = remove_tcp_udp_from_hostname(host->hostname);

Expand Down Expand Up @@ -644,8 +630,6 @@ int ping_udp(host_t *host, ping_t *ping) {
/* set the socket send and receive timeout */
setsockopt(udp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(udp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));

begin_time = get_time_as_double();
} else {
/* decrement the timeout value by the total time */
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
Expand Down Expand Up @@ -769,6 +753,12 @@ int ping_tcp(host_t *host, ping_t *ping) {
/* initilize the socket */
tcp_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

/* initialize total time */
total_time = 0;

/* initialize begin time */
begin_time = get_time_as_double();

/* hostname must be nonblank */
if ((strlen(host->hostname) != 0) && (tcp_socket != -1)) {
/* initialize variables */
Expand All @@ -781,26 +771,13 @@ int ping_tcp(host_t *host, ping_t *ping) {
retry_count = 0;

while (1) {
/* record start time */
if (total_time == 0) {
/* establish timeout value */
timeout.tv_sec = rint(host_timeout / 1000);
timeout.tv_usec = ((int) host_timeout % 1000) * 1000;
/* establish timeout value */
timeout.tv_sec = rint(host_timeout / 1000);
timeout.tv_usec = ((int) host_timeout % 1000) * 1000;

/* set the socket send and receive timeout */
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));

begin_time = get_time_as_double();
} else {
/* decrement the timeout value by the total time */
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;

/* set the socket send and receive timeout */
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
}
/* set the socket send and receive timeout */
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));

/* make the connection */
return_code = connect(tcp_socket, (struct sockaddr *) &servername, sizeof(servername));
Expand Down Expand Up @@ -901,7 +878,7 @@ int init_sockaddr(struct sockaddr_in *name, const char *hostname, unsigned short
int rv;

buf = malloc(len*sizeof(char));
memset(buf, 0, sizeof(buf));
memset(buf, 0, len*sizeof(char));

while (1) {
rv = gethostbyname_r(hostname, &result_buf, buf, len,
Expand Down Expand Up @@ -1107,20 +1084,20 @@ void update_host_status(int status, host_t *host, ping_t *ping, int availability
case AVAIL_SNMP_OR_PING:
case AVAIL_SNMP_AND_PING:
if ((strlen(host->snmp_community) == 0) && (host->snmp_version < 3)) {
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->ping_response);
snprintf(host->status_last_error, BUFSIZE, "%s", ping->ping_response);
} else {
snprintf(host->status_last_error, SMALL_BUFSIZE,"%s, %s",ping->snmp_response,ping->ping_response);
snprintf(host->status_last_error, BUFSIZE,"%s, %s",ping->snmp_response,ping->ping_response);
}
break;
case AVAIL_SNMP:
if ((strlen(host->snmp_community) == 0) && (host->snmp_version < 3)) {
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", "Device does not require SNMP");
snprintf(host->status_last_error, BUFSIZE, "%s", "Device does not require SNMP");
} else {
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->snmp_response);
snprintf(host->status_last_error, BUFSIZE, "%s", ping->snmp_response);
}
break;
default:
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->ping_response);
snprintf(host->status_last_error, BUFSIZE, "%s", ping->ping_response);
}

/* determine if to send an alert and update remainder of statistics */
Expand Down
Loading

0 comments on commit c855622

Please sign in to comment.