FreeBSD Bugzilla – Attachment 110580 Details for
Bug 151770
net-mgmt/cacti-spine: spine 0.8.7g hangs up after one host poll
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
cacti-spine.shar.txt
cacti-spine.shar.txt (text/plain), 14.62 KB, created by
Panagiotis Christias
on 2010-11-01 15:38:52 UTC
(
hide
)
Description:
cacti-spine.shar.txt
Filename:
MIME Type:
Creator:
Panagiotis Christias
Created:
2010-11-01 15:38:52 UTC
Size:
14.62 KB
patch
obsolete
># This is a shell archive. Save it in a file, remove anything before ># this line, and then unpack it by entering "sh file". Note, it may ># create directories; files and directories will be owned by you and ># have default permissions. ># ># This archive contains: ># ># cacti-spine ># cacti-spine/files ># cacti-spine/files/patch-util.h ># cacti-spine/files/patch-util.c ># cacti-spine/files/patch-spine.h ># cacti-spine/files/patch-spine.c ># cacti-spine/files/patch-snmp.c ># cacti-spine/files/patch-poller.c ># cacti-spine/Makefile ># cacti-spine/distinfo ># cacti-spine/pkg-descr ># cacti-spine/pkg-plist ># >echo c - cacti-spine >mkdir -p cacti-spine > /dev/null 2>&1 >echo c - cacti-spine/files >mkdir -p cacti-spine/files > /dev/null 2>&1 >echo x - cacti-spine/files/patch-util.h >sed 's/^X//' >cacti-spine/files/patch-util.h << 'a49a9d4a89a199fb11b6a5dfee28814f' >X--- util.h.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ util.h 2010-11-01 14:33:54.000000000 +0200 >X@@ -54,7 +54,7 @@ >X extern int is_hexadecimal(const char * str, const short ignore_space); >X >X /* string and file functions */ >X-extern char *add_slashes(char *string, int arguments_2_strip); >X+extern char *add_slashes(char *string); >X extern int file_exists(const char *filename); >X extern char *strip_alpha(char *string); >X extern char *strncopy(char *dst, const char *src, size_t n); >a49a9d4a89a199fb11b6a5dfee28814f >echo x - cacti-spine/files/patch-util.c >sed 's/^X//' >cacti-spine/files/patch-util.c << '300fbb056982f6e970b311a99a964a8d' >X--- util.c.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ util.c 2010-11-01 14:33:54.000000000 +0200 >X@@ -755,7 +755,7 @@ >X /* empty string is not all digits */ >X if ( *string == '\0' ) return FALSE; >X >X- while ( isdigit(*string) ) >X+ while ( isdigit((int)*string) ) >X string++; >X >X return *string == '\0'; >X@@ -773,7 +773,7 @@ >X */ >X int is_ipaddress(const char *string) { >X while (*string) { >X- if ((isdigit(*string)) || >X+ if ((isdigit((int)*string)) || >X (*string == '.') || >X (*string == ':')) { >X string++; >X@@ -887,7 +887,7 @@ >X i = strlen(string); >X >X while (i >= 0) { >X- if (isdigit(string[i])) { >X+ if (isdigit((int)string[i])) { >X break; >X }else{ >X string[i] = '\0'; >X@@ -898,17 +898,15 @@ >X return string; >X } >X >X-/*! \fn char *add_slashes(char *string, int arguments_2_strip) >X- * \brief change all backslashes to forward slashes for the first n arguements. >X+/*! \fn char *add_slashes(char *string) >X+ * \brief add escaping to back slashes on for Windows type commands. >X * \param string the string to replace slashes >X- * \param arguments_2_strip the number of space delimited arguments to reverse >X * >X * \return a pointer to the modified string. Variable must be freed by parent. >X * >X */ >X-char *add_slashes(char *string, int arguments_2_strip) { >X+char *add_slashes(char *string) { >X int length; >X- int space_count; >X int position; >X int new_position; >X char *return_str; >X@@ -919,9 +917,8 @@ >X return_str[0] = '\0'; >X >X length = strlen(string); >X- space_count = 0; >X position = 0; >X- new_position = position; >X+ new_position = 0; >X >X /* simply return on blank string */ >X if (!length) { >X@@ -931,17 +928,9 @@ >X while (position < length) { >X /* backslash detected, change to forward slash */ >X if (string[position] == '\\') { >X- /* only add slashes for first x arguments */ >X- if (space_count < arguments_2_strip) { >X- return_str[new_position] = '/'; >X- }else{ >X- return_str[new_position] = string[position]; >X- } >X- /* end of argument detected */ >X- }else if (string[position] == ' ') { >X- return_str[new_position] = ' '; >X- space_count++; >X- /* normal character detected */ >X+ return_str[new_position] = '\\'; >X+ new_position++; >X+ return_str[new_position] = '\\'; >X }else{ >X return_str[new_position] = string[position]; >X } >X@@ -1248,7 +1237,7 @@ >X seteuid(0); >X >X if (geteuid() != 0) { >X- SPINE_LOG_DEBUG(("WARNING: Spine NOT running asroot. This is require if using ICMP. Please run \"chmod +s;chown root:root spine\" to resolve.")); >X+ SPINE_LOG_DEBUG(("WARNING: Spine NOT running asroot. This is required if using ICMP. Please run \"chmod +s;chown root:root spine\" to resolve.")); >X set.icmp_avail = FALSE; >X }else{ >X SPINE_LOG_DEBUG(("DEBUG: Spine is running asroot.")); >300fbb056982f6e970b311a99a964a8d >echo x - cacti-spine/files/patch-spine.h >sed 's/^X//' >cacti-spine/files/patch-spine.h << 'a84af9e4c385fe102cdc156a730d7f99' >X--- spine.h.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ spine.h 2010-11-01 14:33:54.000000000 +0200 >X@@ -504,5 +504,6 @@ >X extern char start_datetime[20]; >X extern char config_paths[CONFIG_PATHS][BUFSIZE]; >X extern int active_threads; >X+extern int thread_ready; >X >X #endif /* not _SPINE_H_ */ >a84af9e4c385fe102cdc156a730d7f99 >echo x - cacti-spine/files/patch-spine.c >sed 's/^X//' >cacti-spine/files/patch-spine.c << '8e92df7f682405510537bfa6a51a11c7' >X--- spine.c.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ spine.c 2010-11-01 14:33:54.000000000 +0200 >X@@ -94,6 +94,7 @@ >X int num_hosts = 0; >X int active_threads = 0; >X int active_scripts = 0; >X+int thread_ready = FALSE; >X >X config_t set; >X php_t *php_processes = 0; >X@@ -134,7 +135,7 @@ >X int poller_counter = 0; >X int last_active_threads = 0; >X int valid_conf_file = FALSE; >X- long int EXTERNAL_THREAD_SLEEP = 5000; >X+ long int EXTERNAL_THREAD_SLEEP = 50; >X long int internal_thread_sleep; >X char querybuf[BIG_BUFSIZE], *qp = querybuf; >X char *host_time = NULL; >X@@ -196,6 +197,7 @@ >X >X /* we attempt to support scripts better in cygwin */ >X #if defined(__CYGWIN__) >X+ setenv("CYGWIN", "nodosfilewarning", 1); >X if (file_exists("./sh.exe")) { >X set.cygwinshloc = 0; >X printf("NOTE: The Shell Command Exists in the current directory\n"); >X@@ -281,7 +283,7 @@ >X >X else if (STRMATCH(arg, "-H") || >X STRIMATCH(arg, "--hostlist")) { >X- snprintf(set.host_id_list, BIG_BUFSIZE, getarg(opt, &argv)); >X+ snprintf(set.host_id_list, BIG_BUFSIZE, "%s", getarg(opt, &argv)); >X } >X >X else if (STRMATCH(arg, "-h") || >X@@ -584,6 +586,11 @@ >X poller_details->host_data_ids = itemsPT; >X poller_details->host_time = host_time; >X >X+ /* this variable tells us that the child had loaded the poller >X+ * poller_details structure and we can move on to the next thread >X+ */ >X+ thread_ready = FALSE; >X+ >X /* create child process */ >X thread_status = pthread_create(&threads[device_counter], &attr, child, poller_details); >X >X@@ -596,6 +603,11 @@ >X } >X active_threads++; >X >X+ /* wait for the child to read and process the structure */ >X+ while (!thread_ready) { >X+ usleep(internal_thread_sleep); >X+ } >X+ >X SPINE_LOG_DEBUG(("DEBUG: The Value of Active Threads is %i", active_threads)); >X >X break; >X@@ -603,7 +615,7 @@ >X SPINE_LOG(("ERROR: The System Lacked the Resources to Create a Thread")); >X break; >X case EFAULT: >X- SPINE_LOG(("ERROR: The Thread or Attribute Was Invalid")); >X+ SPINE_LOG(("ERROR: The Thread or Attribute were Invalid")); >X break; >X case EINVAL: >X SPINE_LOG(("ERROR: The Thread Attribute is Not Initialized")); >X@@ -613,6 +625,8 @@ >X break; >X } >X >X+ thread_mutex_unlock(LOCK_THREAD); >X+ >X /* get current time and exit program if time limit exceeded */ >X if (poller_counter >= 20) { >X current_time = get_time_as_double(); >8e92df7f682405510537bfa6a51a11c7 >echo x - cacti-spine/files/patch-snmp.c >sed 's/^X//' >cacti-spine/files/patch-snmp.c << '74aee9908690225ea7f55abba69d7c23' >X--- snmp.c.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ snmp.c 2010-11-01 14:33:54.000000000 +0200 >X@@ -499,13 +499,9 @@ >X size_t out_len = 0; >X >X if ((buf = (u_char *) calloc(buf_len, 1)) != 0) { >X- if (sprint_realloc_value(&buf, &buf_len, &out_len, 1, >X- objid, objidlen, variable)) { >X+ sprint_realloc_by_type(&buf, &buf_len, &out_len, 1, variable, NULL, NULL, NULL); >X snprintf(obuf, buf_len, "%s", buf); >X }else{ >X- snprintf(obuf, buf_len, "%s [TRUNCATED]", buf); >X- } >X- }else{ >X SET_UNDEFINED(obuf); >X } >X >X@@ -528,6 +524,7 @@ >X int i; >X int array_count; >X int index_count; >X+ char temp_result[RESULTS_BUFFER]; >X >X struct nameStruct { >X oid name[MAX_OID_LEN]; >X@@ -570,11 +567,13 @@ >X for(i = 0; i < num_oids && vars; i++) { >X if (!IS_UNDEFINED(snmp_oids[i].result)) { >X #ifdef USE_NET_SNMP >X- snmp_snprint_value(snmp_oids[i].result, RESULTS_BUFFER, vars->name, vars->name_length, vars); >X+ snmp_snprint_value(temp_result, RESULTS_BUFFER, vars->name, vars->name_length, vars); >X #else >X- sprint_value(snmp_oids[i].result, vars->name, vars->name_length, vars); >X+ sprint_value(temp_result, vars->name, vars->name_length, vars); >X #endif >X >X+ snprintf(snmp_oids[i].result, RESULTS_BUFFER, "%s", trim(temp_result)); >X+ >X vars = vars->next_variable; >X } >X } >74aee9908690225ea7f55abba69d7c23 >echo x - cacti-spine/files/patch-poller.c >sed 's/^X//' >cacti-spine/files/patch-poller.c << '74c79e20a6b0f2992cedea40f6b3fd35' >X--- poller.c.orig 2010-07-10 00:39:53.000000000 +0300 >X+++ poller.c 2010-11-01 14:33:54.000000000 +0200 >X@@ -57,21 +57,26 @@ >X host_data_ids = poller_details.host_data_ids; >X snprintf(host_time, SMALL_BUFSIZE, "%s", poller_details.host_time); >X >X- thread_mutex_unlock(LOCK_THREAD); >X- >X free(arg); >X >X+ thread_ready = TRUE; >X+ >X SPINE_LOG_DEBUG(("DEBUG: In Poller, About to Start Polling of Host")); >X >X poll_host(host_id, host_thread, last_host_thread, host_data_ids, host_time); >X >X- thread_mutex_lock(LOCK_THREAD); >X- >X+ while (TRUE) { >X+ if (thread_mutex_trylock(LOCK_THREAD) == 0) { >X active_threads--; >X+ thread_mutex_unlock(LOCK_THREAD); >X >X- SPINE_LOG_DEBUG(("DEBUG: The Value of Active Threads is %i" ,active_threads)); >X+ break; >X+ } >X >X- thread_mutex_unlock(LOCK_THREAD); >X+ usleep(100); >X+ } >X+ >X+ SPINE_LOG_DEBUG(("DEBUG: The Value of Active Threads is %i" ,active_threads)); >X >X /* end the thread */ >X pthread_exit(0); >X@@ -965,7 +970,7 @@ >X poll_result = exec_poll(host, poller_items[i].arg1); >X >X /* process the result */ >X- if ((is_numeric(poll_result)) || (is_multipart_output(poll_result))) { >X+ if ((is_numeric(poll_result)) || (is_multipart_output(trim(poll_result)))) { >X snprintf(poller_items[i].result, RESULTS_BUFFER, "%s", poll_result); >X }else if (is_hexadecimal(snmp_oids[j].result, TRUE)) { >X snprintf(poller_items[i].result, RESULTS_BUFFER, "%lld", hex2dec(poll_result)); >X@@ -998,7 +1003,7 @@ >X poll_result = php_cmd(poller_items[i].arg1, php_process); >X >X /* process the output */ >X- if ((is_numeric(poll_result)) || (is_multipart_output(poll_result))) { >X+ if ((is_numeric(poll_result)) || (is_multipart_output(trim(poll_result)))) { >X snprintf(poller_items[i].result, RESULTS_BUFFER, "%s", poll_result); >X }else if (is_hexadecimal(snmp_oids[j].result, TRUE)) { >X snprintf(poller_items[i].result, RESULTS_BUFFER, "%lld", hex2dec(poll_result)); >X@@ -1247,7 +1252,7 @@ >X if (is_numeric(result)) { >X return TRUE; >X }else{ >X- if (is_multipart_output(result)) { >X+ if (is_multipart_output(trim(result))) { >X return TRUE; >X }else{ >X return FALSE; >X@@ -1290,7 +1295,7 @@ >X >X /* compensate for back slashes in arguments */ >X #if defined(__CYGWIN__) >X- proc_command = add_slashes(command, 2); >X+ proc_command = add_slashes(command); >X #else >X proc_command = command; >X #endif >X@@ -1340,7 +1345,7 @@ >X FD_SET(cmd_fd, &fds); >X >X /* wait x seonds for pipe response */ >X- switch (select(cmd_fd+1, &fds, NULL, NULL, &timeout)) { >X+ switch (select(FD_SETSIZE, &fds, NULL, NULL, &timeout)) { >X case -1: >X switch (errno) { >X case EBADF: >X@@ -1381,11 +1386,13 @@ >X break; >X } >X case 0: >X+ #ifdef USING_TPOPEN >X SPINE_LOG(("Host[%i] ERROR: The POPEN timed out", current_host->id)); >X >X- #ifdef USING_TPOPEN >X close_fd = FALSE; >X #else >X+ SPINE_LOG(("Host[%i] ERROR: The NIFTY POPEN timed out", current_host->id)); >X+ >X pid = nft_pchild(cmd_fd); >X kill(pid, SIGKILL); >X #endif >74c79e20a6b0f2992cedea40f6b3fd35 >echo x - cacti-spine/Makefile >sed 's/^X//' >cacti-spine/Makefile << 'b4aa05b86e19b5ad651aa5d8159c5315' >X# New ports collection makefile for: cactid >X# Date created: Feb 26 2005 >X# Whom: clement@FreeBSD.org >X# >X# $FreeBSD: ports/net-mgmt/cacti-spine/Makefile,v 1.24 2010/10/12 23:08:33 pav Exp $ >X# >X >XPORTNAME= spine >XPORTVERSION= 0.8.7.g >XPORTREVISION= 1 >XCATEGORIES= net-mgmt >XMASTER_SITES= http://www.cacti.net/downloads/${PORTNAME}/ >XDISTNAME= cacti-${PORTNAME}-0.8.7g >X >XMAINTAINER= skreuzer@FreeBSD.org >XCOMMENT= A multithreaded poller for Cacti written in C >X >XLIB_DEPENDS= netsnmp.20:${PORTSDIR}/net-mgmt/net-snmp >X >XGNU_CONFIGURE= YES >XCONFIGURE_ARGS+=--with-mysql=${LOCALBASE} --with-snmp=${LOCALBASE} >XCONFIGURE_ENV= LDFLAGS="`net-snmp-config --libs`" \ >X CPPFLAGS="`net-snmp-config --cflags`" >XUSE_MYSQL= YES >XUSE_OPENSSL= YES >XUSE_AUTOTOOLS= libtool:22 >X >Xpost-patch: >X @${REINPLACE_CMD} 's,#define\ *DEFAULT_CONF_FILE .*,#define DEFAULT_CONF_FILE "${PREFIX}/etc/spine.conf",' ${WRKSRC}/spine.h >X >Xpre-configure: >X @(cd ${WRKSRC} ; ${LIBTOOLIZE} --copy --force --install) >X >Xdo-install: >X @${INSTALL_PROGRAM} ${WRKSRC}/spine ${PREFIX}/bin >X @${MKDIR} ${EXAMPLESDIR} >X @${INSTALL_DATA} ${WRKSRC}/spine.conf.dist ${EXAMPLESDIR}/spine.conf >X @[ -e ${PREFIX}/etc/spine.conf ] || \ >X ${INSTALL_DATA} ${EXAMPLESDIR}/spine.conf ${PREFIX}/etc/spine.conf >X >X.include <bsd.port.mk> >b4aa05b86e19b5ad651aa5d8159c5315 >echo x - cacti-spine/distinfo >sed 's/^X//' >cacti-spine/distinfo << 'b1a552b7c3b03a006c0f5b8af2869ee5' >XMD5 (cacti-spine-0.8.7g.tar.gz) = 22c2b1986c880b9c587876c18d5c3f9f >XSHA256 (cacti-spine-0.8.7g.tar.gz) = 2735fbc1fc38d31651009d0a8d6ea121b29403d6020b13ba245ab4f3e0f6d561 >XSIZE (cacti-spine-0.8.7g.tar.gz) = 592801 >b1a552b7c3b03a006c0f5b8af2869ee5 >echo x - cacti-spine/pkg-descr >sed 's/^X//' >cacti-spine/pkg-descr << '9d1ac1bd413d14d2c1948a7acc4a7d9c' >XCactid is a poller for Cacti that primarily strives to be as fast as >Xpossible. For this reason it is written in native C, makes use of POSIX >Xthreads, and is linked directly against the net-snmp library for >Xminmumal SNMP polling overhead. Cactid is a replacement for the default >Xcmd.php poller so you must decide if using Cactid makes sense for your >Xinstallation. >X >XWWW: http://www.cacti.net/cactid_info.php >9d1ac1bd413d14d2c1948a7acc4a7d9c >echo x - cacti-spine/pkg-plist >sed 's/^X//' >cacti-spine/pkg-plist << 'd9d582e6521974617b5c5dff878709b7' >Xbin/spine >X@unexec if cmp -s %D/etc/spine.conf %D/%%EXAMPLESDIR%%/spine.conf; then rm -f %D/etc/spine.conf; fi >X%%EXAMPLESDIR%%/spine.conf >X@exec [ -f %D/etc/spine.conf ] || cp %D/%%EXAMPLESDIR%%/spine.conf %D/etc/spine.conf >X@dirrm %%EXAMPLESDIR%% >d9d582e6521974617b5c5dff878709b7 >exit
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 151770
: 110580