Skip to content

Commit c855622

Browse files
committed
Merge branch 'develop' for release 1.2.0
2 parents 0c7a866 + 2142382 commit c855622

File tree

16 files changed

+1067
-779
lines changed

16 files changed

+1067
-779
lines changed

ChangeLog renamed to CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
The Cacti Group | spine
22

3+
1.2.0
4+
-feature: Allow threads to be set a Data Collector level
5+
-issue#50: make fails on Debian 7 attempting to locate clock_gettime
6+
-issue#53: Improved escaping when updating database records
7+
-issue#54: Spine should always log if ICMP fails
8+
-issue#58: When updating snmp_sysLocation, text can become truncated
9+
-issue#63: Automatically reduce device threads when number of data sources does not require it
10+
311
1.1.38
412
-feature: release to match Cacti release
513

INSTALL

Lines changed: 99 additions & 333 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Spine: a poller for Cacti
2-
---------------------------
2+
33
Spine is a high speed poller replacement for `cmd.php`. It is almost 100%
44
compatible with the legacy cmd.php processor and provides much more
55
flexibility, speed and concurrency than `cmd.php`.
@@ -8,6 +8,19 @@ Make sure that you have the proper development environment to compile Spine.
88
This includes compilers, header files and things such as libtool. If you
99
have questions please consult the forums and/or online documentation.
1010

11+
-----------------------------------------------------------------------------
12+
13+
## 1.2.0 Development
14+
15+
**PLEASE READ**
16+
17+
Feature branch for `1.2.x` has been merged into the `develop` branch. This means
18+
things may and will break, but they will eventually be fixed.
19+
20+
> DEVELOP branch is currently considered UNSTABLE, use with caution!
21+
22+
-----------------------------------------------------------------------------
23+
1124
## Unix Installation
1225

1326
These instructions assume the default install location for spine
@@ -22,7 +35,7 @@ please do the following:
2235
make
2336
make install
2437
chown root:root /usr/local/spine/bin/spine
25-
chmod +s /usr/local/spine/bin/spine
38+
chmod u+s /usr/local/spine/bin/spine
2639
```
2740

2841
To compile and install Spine using MySQL versions previous to 5.5

configure.ac

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
AC_PREREQ(2.53)
2-
AC_INIT(Spine Poller, 1.1.38, http://www.cacti.net/issues.php)
2+
AC_INIT(Spine Poller, 1.2.0, http://www.cacti.net/issues.php)
33

44
AC_CONFIG_AUX_DIR(config)
55
AC_SUBST(ac_aux_dir)
@@ -10,7 +10,7 @@ AC_PREFIX_DEFAULT(/usr/local/spine)
1010
AC_LANG(C)
1111

1212
AM_INIT_AUTOMAKE([foreign])
13-
AM_CONFIG_HEADER(config/config.h)
13+
AC_CONFIG_HEADERS(config/config.h)
1414

1515
# static libraries
1616
AC_ARG_WITH(static,
@@ -67,6 +67,7 @@ case $host_alias in
6767
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS";;
6868
*freebsd*)
6969
LIBS="$LIBS -pthread"
70+
LDFLAGS="-lexecinfo"
7071
AC_DEFINE(HAVE_LIBPTHREAD, 1);;
7172
*darwin*)
7273
ShLib="dylib";;
@@ -80,7 +81,7 @@ AC_PROG_CC
8081
AC_PROG_CPP
8182
AC_PROG_INSTALL
8283
AC_PROG_LN_S
83-
AC_PROG_LIBTOOL
84+
LT_INIT
8485

8586
AC_MSG_CHECKING([whether to enable -Wall])
8687
AC_ARG_ENABLE(warnings,
@@ -127,11 +128,15 @@ AC_CHECK_LIB(z, deflate)
127128
AC_CHECK_LIB(kstat, kstat_close)
128129
AC_CHECK_LIB(crypto, CRYPTO_realloc)
129130

131+
# minor adjustments for debian
132+
AC_SEARCH_LIBS([clock_gettime], [rt pthread])
133+
130134
# Checks for header files.
131135
AC_HEADER_STDC
132136
AC_CHECK_HEADERS(sys/socket.h sys/select.h sys/wait.h sys/time.h)
133137
AC_CHECK_HEADERS(assert.h ctype.h errno.h signal.h math.h malloc.h netdb.h)
134138
AC_CHECK_HEADERS(signal.h stdarg.h stdio.h syslog.h)
139+
AC_CHECK_HEADERS(execinfo.h)
135140
AC_CHECK_HEADERS(
136141
netinet/in_systm.h netinet/in.h netinet/ip.h netinet/ip_icmp.h,
137142
[],
@@ -177,7 +182,7 @@ if test x$ENABLED_SOL_PRIV != xno; then
177182
if test x$FOUND_PRIV_H != xno; then
178183
AC_MSG_RESULT([yes])
179184
AC_DEFINE([SOLAR_PRIV], [1],
180-
[If upport for Solaris privileges should be enabled]
185+
[If Support for Solaris privileges should be enabled]
181186
)
182187
else
183188
AC_MSG_RESULT([no])
@@ -470,4 +475,28 @@ if test -z "$HAVE_GETHOSTBYNAME_R"; then
470475
HAVE_GETHOSTBYNAME_R=yes
471476
fi
472477

478+
# See if we can support backtracing
479+
AC_MSG_CHECKING([if we can support backtracing])
480+
AC_TRY_LINK(
481+
[
482+
#include <stdlib.h>
483+
#include <execinfo.h>
484+
],[
485+
void *array[10];
486+
size_t size;
487+
488+
# get void*'s for all entries on the stack
489+
size = backtrace(array, 10);
490+
if (size) {
491+
exit(0);
492+
} else {
493+
exit(1);
494+
}
495+
],
496+
[ AC_MSG_RESULT(yes)
497+
AC_DEFINE(HAS_EXECINFO_H,1,[Do we have backtracing capabilities?])
498+
],
499+
AC_MSG_RESULT(no)
500+
)
501+
473502
AC_OUTPUT(Makefile)

error.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@
4646
static void spine_signal_handler(int spine_signal) {
4747
signal(spine_signal, SIG_DFL);
4848

49+
#if HAS_EXECINFO_H
50+
// get void*'s for all entries on the stack
51+
set.exit_size = backtrace(set.exit_stack, 10);
52+
#endif
53+
4954
set.exit_code = spine_signal;
5055

5156
switch (spine_signal) {
@@ -80,6 +85,8 @@ static int spine_fatal_signals[] = {
8085
SIGBUS,
8186
SIGFPE,
8287
SIGQUIT,
88+
SIGSYS,
89+
SIGABRT,
8390
0
8491
};
8592

php.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,9 +435,10 @@ int php_init(int php_process) {
435435
php_processes[php_process].php_state = PHP_BUSY;
436436
}
437437
}
438+
439+
free(result_string);
438440
}
439441

440-
free(result_string);
441442

442443
return TRUE;
443444
}

ping.c

Lines changed: 31 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ int ping_host(host_t *host, ping_t *ping) {
5959

6060
if (host->ping_method == PING_ICMP) {
6161
if (set.icmp_avail == FALSE) {
62-
if (is_debug_device(host->id)) {
63-
SPINE_LOG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
64-
} else {
65-
SPINE_LOG_DEBUG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
66-
}
62+
SPINE_LOG(("Device[%i] DEBUG Falling back to UDP Ping Due to SetUID Issues", host->id));
6763
host->ping_method = PING_UDP;
6864
}
6965
}
@@ -387,26 +383,13 @@ int ping_icmp(host_t *host, ping_t *ping) {
387383
return HOST_DOWN;
388384
}
389385

390-
/* record start time */
391-
if (total_time == 0) {
392-
/* establish timeout value */
393-
timeout.tv_sec = rint(host_timeout / 1000);
394-
timeout.tv_usec = rint((int) host_timeout % 1000) * 1000;
395-
396-
/* set the socket send and receive timeout */
397-
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
398-
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
399-
400-
begin_time = get_time_as_double();
401-
} else {
402-
/* decrement the timeout value by the total time */
403-
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
404-
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;
386+
/* decrement the timeout value by the total time */
387+
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
388+
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;
405389

406-
/* set the socket send and receive timeout */
407-
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
408-
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
409-
}
390+
/* set the socket send and receive timeout */
391+
setsockopt(icmp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
392+
setsockopt(icmp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
410393

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

433416
if (return_code < 0) {
434417
if (errno == EINTR) {
418+
/* call was interrupted by some system event */
419+
435420
if (is_debug_device(host->id)) {
436421
SPINE_LOG(("Device[%i] DEBUG: Received EINTR", host->id));
437422
} else {
438423
SPINE_LOG_DEBUG(("Device[%i] DEBUG: Received EINTR", host->id));
439424
}
440-
/* call was interrupted by some system event */
441-
// usleep(10000);
425+
442426
goto keep_listening;
443427
}
444428
} else {
445429
ip = (struct ip *) socket_reply;
446430
pkt = (struct icmp *) (socket_reply + (ip->ip_hl << 2));
447431

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

578+
begin_time = get_time_as_double();
579+
594580
/* remove "udp:" from hostname */
595581
new_hostname = remove_tcp_udp_from_hostname(host->hostname);
596582

@@ -644,8 +630,6 @@ int ping_udp(host_t *host, ping_t *ping) {
644630
/* set the socket send and receive timeout */
645631
setsockopt(udp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
646632
setsockopt(udp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
647-
648-
begin_time = get_time_as_double();
649633
} else {
650634
/* decrement the timeout value by the total time */
651635
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
@@ -769,6 +753,12 @@ int ping_tcp(host_t *host, ping_t *ping) {
769753
/* initilize the socket */
770754
tcp_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
771755

756+
/* initialize total time */
757+
total_time = 0;
758+
759+
/* initialize begin time */
760+
begin_time = get_time_as_double();
761+
772762
/* hostname must be nonblank */
773763
if ((strlen(host->hostname) != 0) && (tcp_socket != -1)) {
774764
/* initialize variables */
@@ -781,26 +771,13 @@ int ping_tcp(host_t *host, ping_t *ping) {
781771
retry_count = 0;
782772

783773
while (1) {
784-
/* record start time */
785-
if (total_time == 0) {
786-
/* establish timeout value */
787-
timeout.tv_sec = rint(host_timeout / 1000);
788-
timeout.tv_usec = ((int) host_timeout % 1000) * 1000;
774+
/* establish timeout value */
775+
timeout.tv_sec = rint(host_timeout / 1000);
776+
timeout.tv_usec = ((int) host_timeout % 1000) * 1000;
789777

790-
/* set the socket send and receive timeout */
791-
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
792-
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
793-
794-
begin_time = get_time_as_double();
795-
} else {
796-
/* decrement the timeout value by the total time */
797-
timeout.tv_sec = rint((host_timeout - total_time) / 1000);
798-
timeout.tv_usec = ((int) (host_timeout - total_time) % 1000) * 1000;
799-
800-
/* set the socket send and receive timeout */
801-
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
802-
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
803-
}
778+
/* set the socket send and receive timeout */
779+
setsockopt(tcp_socket, SOL_SOCKET, SO_RCVTIMEO, (char*)&timeout, sizeof(timeout));
780+
setsockopt(tcp_socket, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof(timeout));
804781

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

903880
buf = malloc(len*sizeof(char));
904-
memset(buf, 0, sizeof(buf));
881+
memset(buf, 0, len*sizeof(char));
905882

906883
while (1) {
907884
rv = gethostbyname_r(hostname, &result_buf, buf, len,
@@ -1107,20 +1084,20 @@ void update_host_status(int status, host_t *host, ping_t *ping, int availability
11071084
case AVAIL_SNMP_OR_PING:
11081085
case AVAIL_SNMP_AND_PING:
11091086
if ((strlen(host->snmp_community) == 0) && (host->snmp_version < 3)) {
1110-
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->ping_response);
1087+
snprintf(host->status_last_error, BUFSIZE, "%s", ping->ping_response);
11111088
} else {
1112-
snprintf(host->status_last_error, SMALL_BUFSIZE,"%s, %s",ping->snmp_response,ping->ping_response);
1089+
snprintf(host->status_last_error, BUFSIZE,"%s, %s",ping->snmp_response,ping->ping_response);
11131090
}
11141091
break;
11151092
case AVAIL_SNMP:
11161093
if ((strlen(host->snmp_community) == 0) && (host->snmp_version < 3)) {
1117-
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", "Device does not require SNMP");
1094+
snprintf(host->status_last_error, BUFSIZE, "%s", "Device does not require SNMP");
11181095
} else {
1119-
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->snmp_response);
1096+
snprintf(host->status_last_error, BUFSIZE, "%s", ping->snmp_response);
11201097
}
11211098
break;
11221099
default:
1123-
snprintf(host->status_last_error, SMALL_BUFSIZE, "%s", ping->ping_response);
1100+
snprintf(host->status_last_error, BUFSIZE, "%s", ping->ping_response);
11241101
}
11251102

11261103
/* determine if to send an alert and update remainder of statistics */

0 commit comments

Comments
 (0)