Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package cacti-spine for openSUSE:Factory 
checked in at 2023-01-03 15:05:18
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cacti-spine (Old)
 and      /work/SRC/openSUSE:Factory/.cacti-spine.new.1563 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cacti-spine"

Tue Jan  3 15:05:18 2023 rev:38 rq:1046258 version:1.2.23

Changes:
--------
--- /work/SRC/openSUSE:Factory/cacti-spine/cacti-spine.changes  2022-10-03 
13:47:22.509694340 +0200
+++ /work/SRC/openSUSE:Factory/.cacti-spine.new.1563/cacti-spine.changes        
2023-01-03 15:05:33.522577570 +0100
@@ -1,0 +2,11 @@
+Mon Jan  2 17:43:08 UTC 2023 - Andreas Stieger <[email protected]>
+
+- cacti-spine 1.2.23:
+  * Fix unexpected reindexing when using uptime as the reindex
+    method
+  * Spine should prevent the script server from connecting to remote
+    when offline
+  * Improve Script Server Timeout Logging
+  * Add SQL_NO_CACHE to Spine Queries
+
+-------------------------------------------------------------------

Old:
----
  cacti-spine-1.2.22.tar.gz

New:
----
  cacti-spine-1.2.23.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ cacti-spine.spec ++++++
--- /var/tmp/diff_new_pack.ugwe1i/_old  2023-01-03 15:05:33.930579951 +0100
+++ /var/tmp/diff_new_pack.ugwe1i/_new  2023-01-03 15:05:33.934579975 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package cacti-spine
 #
-# Copyright (c) 2022 SUSE LLC
+# Copyright (c) 2023 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -18,7 +18,7 @@
 
 %{!?make_build: %define make_build make %{?_smp_mflags}}
 Name:           cacti-spine
-Version:        1.2.22
+Version:        1.2.23
 Release:        0
 Summary:        Threaded poller for Cacti written in C
 License:        LGPL-2.1-or-later

++++++ cacti-spine-1.2.22.tar.gz -> cacti-spine-1.2.23.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/CHANGELOG 
new/cacti-spine-1.2.23/CHANGELOG
--- old/cacti-spine-1.2.22/CHANGELOG    2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/CHANGELOG    2023-01-02 15:48:31.000000000 +0100
@@ -1,6 +1,16 @@
 The Cacti Group | spine
 
+1.2.23
+-issue#287: Unexpected reindexing occurs when using uptime as the reindex 
method
+-issue#279: spine does not compile with SQL TLS deactivated
+-feature#277: Spine should prevent the script server from connecting to remote 
when offline
+-feature#292: Improve Script Server Timeout Logging
+-feature#293: Add SQL_NO_CACHE to Spine Queries
+
+
 1.2.22
+-issue#265: Periodically spine crashes with sigabort due to MariaDB API buffer 
overruns
+-issue#267: FATAL: Spine Encountered a Segmentation Fault
 -issue#269: When polling time is exceed, spine does not always exit as expected
 -issue#270: Spine logging at `-V 5` includes an extra line feed
 -issue#271: Incorrect SNMP responses can cause spine to crash
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/configure.ac 
new/cacti-spine-1.2.23/configure.ac
--- old/cacti-spine-1.2.22/configure.ac 2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/configure.ac 2023-01-02 15:48:31.000000000 +0100
@@ -1,5 +1,5 @@
 AC_PREREQ([2.63])
-AC_INIT([Spine Poller],[1.2.22],[http://www.cacti.net/issues.php])
+AC_INIT([Spine Poller],[1.2.23],[http://www.cacti.net/issues.php])
 
 AC_CONFIG_AUX_DIR(config)
 AC_SUBST(ac_aux_dir)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/locks.c 
new/cacti-spine-1.2.23/locks.c
--- old/cacti-spine-1.2.22/locks.c      2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/locks.c      2023-01-02 15:48:31.000000000 +0100
@@ -158,7 +158,7 @@
                case LOCK_HOST_TIME:   ret_val = &host_time_cond;   break;
        }
 
-       SPINE_LOG_DEVDBG(( "LOCKS: [ RET ] Returning cond for %s", 
get_name(lock) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [RET]   Returning cond for %s", 
get_name(lock)));
 
        return ret_val;
 }
@@ -192,7 +192,7 @@
                case LOCK_HOST_TIME:   ret_val = &host_time_lock;   break;
        }
 
-       SPINE_LOG_DEVDBG(( "LOCKS: [ RET ] Returning lock for %s", 
get_name(lock) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [RET]   Returning lock for %s", 
get_name(lock)));
 
        return ret_val;
 }
@@ -226,26 +226,27 @@
                case LOCK_HOST_TIME_O:   ret_val = &host_time_lock_o;   break;
        }
 
-       SPINE_LOG_DEVDBG(( "LOCKS: [ RET ] Returning attr for %s", 
get_name(locko) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [RET]   Returning attr for %s", 
get_name(locko)));
 
        return ret_val;
 }
 
 void thread_mutex_lock(int mutex) {
-       SPINE_LOG_DEVDBG(( "LOCKS: [START] Mutex lock for %s", get_name(mutex) 
));
+       SPINE_LOG_DEVDBG(("LOCKS: [START] Mutex lock for %s", get_name(mutex)));
        pthread_mutex_lock(get_lock(mutex));
-       SPINE_LOG_DEVDBG(( "LOCKS: [ END ] Mutex lock for %s", get_name(mutex) 
));
+       SPINE_LOG_DEVDBG(("LOCKS: [END]   Mutex lock for %s", get_name(mutex)));
 }
 
 void thread_mutex_unlock(int mutex) {
-       SPINE_LOG_DEVDBG(( "LOCKS: [START] Mutex unlock for %s", 
get_name(mutex) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [START] Mutex unlock for %s", 
get_name(mutex)));
        pthread_mutex_unlock(get_lock(mutex));
-       SPINE_LOG_DEVDBG(( "LOCKS: [ END ] Mutex unlock for %s", 
get_name(mutex) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [END]   Mutex unlock for %s", 
get_name(mutex)));
 }
 
 int thread_mutex_trylock(int mutex) {
-       SPINE_LOG_DEVDBG(( "LOCKS: [START] Mutex try lock for %s", 
get_name(mutex) ));
+       SPINE_LOG_DEVDBG(("LOCKS: [START] Mutex try lock for %s", 
get_name(mutex)));
        int ret_val = pthread_mutex_trylock(get_lock(mutex));
-       SPINE_LOG_DEVDBG(( "LOCKS: [ END ] Mutex try lock for %s, result = %d", 
get_name(mutex), ret_val ));
+       SPINE_LOG_DEVDBG(("LOCKS: [END]   Mutex try lock for %s, result = %d", 
get_name(mutex), ret_val));
        return ret_val;
 }
+
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/php.c new/cacti-spine-1.2.23/php.c
--- old/cacti-spine-1.2.22/php.c        2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/php.c        2023-01-02 15:48:31.000000000 +0100
@@ -84,7 +84,7 @@
        /* if write status is <= 0 then the script server may be hung */
        if (bytes <= 0) {
                result_string = strdup("U");
-               SPINE_LOG(("ERROR: SS[%i] PHP Script Server communications 
lost.  Restarting PHP Script Server", php_process));
+               SPINE_LOG(("ERROR: SS[%i] PHP Script Server communications lost 
sending Command[%s].  Restarting PHP Script Server", php_process, command));
 
                php_close(php_process);
                php_init(php_process);
@@ -93,9 +93,9 @@
                if (retries < 3) {
                        goto retry;
                }
-       }else{
+       } else {
                /* read the result from the php_command */
-               result_string = php_readpipe(php_process);
+               result_string = php_readpipe(php_process, command);
 
                /* check for a null */
                if (!strlen(result_string)) {
@@ -148,7 +148,7 @@
        return i;
 }
 
-/*! \fn char *php_readpipe(int php_process)
+/*! \fn char *php_readpipe(int php_process, char *command)
  *  \brief read a line from a PHP Script Server process
  *  \param php_process the PHP Script Server process to obtain output from
  *
@@ -159,11 +159,12 @@
  *
  *  \return a string pointer to the PHP Script Server response
  */
-char *php_readpipe(int php_process) {
+char *php_readpipe(int php_process, char *command) {
        fd_set fds;
        struct timeval timeout;
        double begin_time = 0;
        double end_time = 0;
+       double remaining_usec = 0;
        char *result_string;
 
        int  i;
@@ -206,14 +207,21 @@
                                end_time = get_time_as_double();
 
                                /* re-establish new timeout value */
-                               timeout.tv_sec = 
rint(floor(set.script_timeout-(end_time-begin_time)));
-                               timeout.tv_usec = 
rint((set.script_timeout-(end_time-begin_time)-timeout.tv_sec)*1000000);
+                               timeout.tv_sec  = 
rint(floor(set.script_timeout-(end_time-begin_time)));
+                               remaining_usec  = set.script_timeout - 
timeout.tv_sec - (end_time - begin_time);
 
-                               if ((end_time - begin_time) < 
set.script_timeout) {
+                               if (remaining_usec > 0) {
+                                       timeout.tv_usec = rint(remaining_usec * 
1000000);
+                               } else {
+                                       timeout.tv_usec = 0;
+                               }
+
+                               if (timeout.tv_sec + timeout.tv_usec > 0) {
                                        goto retry;
-                               }else{
+                               } else {
                                        SPINE_LOG(("WARNING: SS[%i] The Script 
Server script timed out while processing EINTR's.", php_process));
                                }
+
                                break;
                        case EINVAL:
                                SPINE_LOG(("ERROR: SS[%i] N is negative or the 
value contained within timeout is invalid.", php_process));
@@ -233,7 +241,7 @@
                php_init(php_process);
                break;
        case 0:
-               SPINE_LOG(("WARNING: SS[%i] The PHP Script Server did not 
respond in time and will therefore be restarted", php_process));
+               SPINE_LOG(("WARNING: SS[%i] The PHP Script Server did not 
respond in time for Timeout[%0.2f], Command[%s] and will therefore be 
restarted", php_process, end_time - start_time, command));
                SET_UNDEFINED(result_string);
 
                /* kill script server because it is misbehaving */
@@ -264,7 +272,7 @@
                                        SET_UNDEFINED(result_string);
                                }
                        }
-               }else{
+               } else {
                        SPINE_LOG(("ERROR: SS[%i] The FD was not set as 
expected", php_process));
                        SET_UNDEFINED(result_string);
                }
@@ -291,17 +299,19 @@
        int  php2cacti_pdes[2];
        pid_t  pid;
        char poller_id[TINY_BUFSIZE];
-       char *argv[6];
+       char mode[TINY_BUFSIZE];
+       char *argv[7];
        int  cancel_state;
        char *result_string = 0;
        int num_processes;
        int i;
        int retry_count = 0;
+       char *command = strdup("INIT");
 
        /* special code to start all PHP Servers */
        if (php_process == PHP_INIT) {
                num_processes = set.php_servers;
-       }else{
+       } else {
                num_processes = 1;
        }
 
@@ -324,13 +334,41 @@
                pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cancel_state);
 
                /* establish arguments for script server execution */
-               argv[0] = set.path_php;
-               argv[1] = "-q";
-               argv[2] = set.path_php_server;
-               argv[3] = "spine";
-               snprintf(poller_id, TINY_BUFSIZE, "%d", set.poller_id);
-               argv[4] = poller_id;
-               argv[5] = NULL;
+               if (set.cacti_version <= 1222) {
+                       argv[0] = set.path_php;
+                       argv[1] = "-q";
+                       argv[2] = set.path_php_server;
+                       argv[3] = "spine";
+                       snprintf(poller_id, TINY_BUFSIZE, "%d", set.poller_id);
+                       argv[4] = poller_id;
+                       argv[5] = NULL;
+               } else if (set.poller_id > 1) {
+                       argv[0] = set.path_php;
+                       argv[1] = "-q";
+                       argv[2] = set.path_php_server;
+                       argv[3] = "--environ=spine";
+
+                       snprintf(poller_id, TINY_BUFSIZE, "--poller=%d", 
set.poller_id);
+                       argv[4] = poller_id;
+
+                       if (set.mode == REMOTE_ONLINE) {
+                               snprintf(mode, TINY_BUFSIZE, "--mode=online");
+                       } else {
+                               snprintf(mode, TINY_BUFSIZE, "--mode=offline");
+                       }
+                       argv[5] = mode;
+
+                       argv[6] = NULL;
+               } else {
+                       argv[0] = set.path_php;
+                       argv[1] = "-q";
+                       argv[2] = set.path_php_server;
+                       argv[3] = "--environ=spine";
+                       snprintf(poller_id, TINY_BUFSIZE, "--poller=%d", 
set.poller_id);
+                       argv[4] = poller_id;
+
+                       argv[5] = NULL;
+               }
 
                /* fork a child process */
                SPINE_LOG_DEBUG(("DEBUG: SS[%i] PHP Script Server About to FORK 
Child Process", i));
@@ -351,7 +389,7 @@
                                                usleep(50000);
                                                #endif
                                                goto retry;
-                                       }else{
+                                       } else {
                                                SPINE_LOG(("ERROR: SS[%i] Could 
not fork PHP Script Server Out of Resources", i));
                                        }
                                case ENOMEM:
@@ -362,7 +400,7 @@
                                                usleep(50000);
                                                #endif
                                                goto retry;
-                                       }else{
+                                       } else {
                                                SPINE_LOG(("ERROR: SS[%i] Could 
not fork PHP Script Server Out of Memory", i));
                                        }
                                default:
@@ -407,7 +445,7 @@
                        php_processes[i].php_pid = pid;
                        php_processes[i].php_write_fd = cacti2php_pdes[1];
                        php_processes[i].php_read_fd = php2cacti_pdes[0];
-               }else{
+               } else {
                        php_processes[php_process].php_pid = pid;
                        php_processes[php_process].php_write_fd = 
cacti2php_pdes[1];
                        php_processes[php_process].php_read_fd = 
php2cacti_pdes[0];
@@ -418,9 +456,9 @@
 
                /* check pipe to insure startup took place */
                if (php_process == PHP_INIT) {
-                       result_string = php_readpipe(i);
-               }else{
-                       result_string = php_readpipe(php_process);
+                       result_string = php_readpipe(i, command);
+               } else {
+                       result_string = php_readpipe(php_process, command);
                }
 
                if (strstr(result_string, "Started")) {
@@ -428,18 +466,17 @@
                                SPINE_LOG_DEBUG(("DEBUG: SS[%i] Confirmed PHP 
Script Server running using readfd[%i], writefd[%i]", i, php2cacti_pdes[0], 
cacti2php_pdes[1]));
 
                                php_processes[i].php_state = PHP_READY;
-                       }else{
+                       } else {
                                SPINE_LOG_DEBUG(("DEBUG: SS[%i] Confirmed PHP 
Script Server running using readfd[%i], writefd[%i]", php_process, 
php2cacti_pdes[0], cacti2php_pdes[1]));
 
                                php_processes[php_process].php_state = 
PHP_READY;
                        }
-               }else{
-
+               } else {
                        if (php_process == PHP_INIT) {
                                SPINE_LOG(("ERROR: SS[%i] Script Server did not 
start properly return message was: '%s'", i, result_string));
 
                                php_processes[i].php_state = PHP_BUSY;
-                       }else{
+                       } else {
                                SPINE_LOG(("ERROR: SS[%i] Script Server did not 
start properly return message was: '%s'", php_process, result_string));
 
                                php_processes[php_process].php_state = PHP_BUSY;
@@ -473,7 +510,7 @@
 
        if (php_process == PHP_INIT) {
                num_processes = set.php_servers;
-       }else{
+       } else {
                num_processes = 1;
        }
 
@@ -485,7 +522,7 @@
                /* tell the script server to close */
                if (php_process == PHP_INIT) {
                        phpp = &php_processes[i];
-               }else{
+               } else {
                        phpp = &php_processes[php_process];
                }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/php.h new/cacti-spine-1.2.23/php.h
--- old/cacti-spine-1.2.22/php.h        2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/php.h        2023-01-02 15:48:31.000000000 +0100
@@ -32,7 +32,7 @@
 */
 
 extern char *php_cmd(const char *php_command, int php_process);
-extern char *php_readpipe(int php_process);
+extern char *php_readpipe(int php_process, char *command);
 extern int php_init(int php_process);
 extern void php_close(int php_process);
 extern int php_get_process(void);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/ping.c 
new/cacti-spine-1.2.23/ping.c
--- old/cacti-spine-1.2.22/ping.c       2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/ping.c       2023-01-02 15:48:31.000000000 +0100
@@ -1168,30 +1168,26 @@
                                if (set.ping_failure_count == 1) {
                                        snprintf(host->status_fail_date, 40, 
"%s", current_date);
                                }
-
-                       /* host is down, but not ready to issue log message */
                        } else {
                                /* host down for the first time, set event date 
*/
                                if (host->status_event_count == 1) {
                                        snprintf(host->status_fail_date, 40, 
"%s", current_date);
                                }
                        }
-
-               /* host is recovering, put back in failed state */
                } else if (host->status == HOST_RECOVERING) {
+                       /* host is recovering, put back in failed state */
                        host->status_event_count = 1;
                        host->status = HOST_DOWN;
-
-               /* host was unknown and now is down */
                } else if (host->status == HOST_UNKNOWN) {
+                       /* host was unknown and now is down */
                        host->status = HOST_DOWN;
                        host->status_event_count = 0;
                } else {
                        host->status_event_count++;
                }
-
-       /* host is up!! */
        } else {
+               /* host is up!! */
+
                /* update total polls and availability */
                host->total_polls = host->total_polls + 1;
                host->availability = hundred_percent * (host->total_polls - 
host->failed_polls) / host->total_polls;
@@ -1232,7 +1228,7 @@
                        * host->avg_time) + ping_time) / 
(host->total_polls-host->failed_polls);
 
                /* the host was down, now it's recovering */
-               if ((host->status == HOST_DOWN) || (host->status == 
HOST_RECOVERING )) {
+               if ((host->status == HOST_DOWN) || (host->status == 
HOST_RECOVERING)) {
                        /* just up, change to recovering */
                        if (host->status == HOST_DOWN) {
                                host->status = HOST_RECOVERING;
@@ -1255,19 +1251,23 @@
 
                                /* reset the event counter */
                                host->status_event_count = 0;
-                       /* host is recovering, but not ready to issue log 
message */
                        } else {
                                /* host recovering for the first time, set 
event date */
                                if (host->status_event_count == 1) {
                                        snprintf(host->status_rec_date, 40, 
"%s", current_date);
                                }
                        }
+               } else if (host->status_event_count > 0) {
+                       /* host was unknown and now is up */
+                       host->status = HOST_UP;
+                       host->status_event_count = 0;
                } else {
-               /* host was unknown and now is up */
+                       /* host was unknown and now is up */
                        host->status = HOST_UP;
                        host->status_event_count = 0;
                }
        }
+
        /* if the user wants a flood of information then flood them */
        if (set.log_level >= POLLER_VERBOSITY_HIGH) {
                if ((host->status == HOST_UP) || (host->status == 
HOST_RECOVERING)) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/poller.c 
new/cacti-spine-1.2.23/poller.c
--- old/cacti-spine-1.2.22/poller.c     2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/poller.c     2023-01-02 15:48:31.000000000 +0100
@@ -6,7 +6,7 @@
  | This program is free software; you can redistribute it and/or           |
  | modify it under the terms of the GNU Lesser General Public              |
  | License as published by the Free Software Foundation; either            |
- | version 2.1 of the License, or (at your option) any later version.  |
+ | version 2.1 of the License, or (at your option) any later version.      |
  |                                                                         |
  | This program is distributed in the hope that it will be useful,         |
  | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
@@ -150,6 +150,7 @@
        char query10[BUFSIZE];
        char query11[BUFSIZE];
        char *query12 = NULL;
+       char query13[BUFSIZE];
        char posuffix[BUFSIZE];
 
        int query1_len   = 0;
@@ -278,7 +279,7 @@
        /* single polling interval query for items */
        if (set.poller_id == 0) {
                snprintf(query1, BUFSIZE,
-                       "SELECT action, hostname, snmp_community, "
+                       "SELECT SQL_NO_CACHE action, hostname, snmp_community, "
                                "snmp_version, snmp_username, snmp_password, "
                                "rrd_name, rrd_path, arg1, arg2, arg3, 
local_data_id, "
                                "rrd_num, snmp_port, snmp_timeout, "
@@ -290,7 +291,7 @@
 
                /* host structure for uptime checks */
                snprintf(query2, BIG_BUFSIZE,
-                       "SELECT id, hostname, snmp_community, snmp_version, "
+                       "SELECT SQL_NO_CACHE id, hostname, snmp_community, 
snmp_version, "
                                "snmp_username, snmp_password, 
snmp_auth_protocol, "
                                "snmp_priv_passphrase, snmp_priv_protocol, 
snmp_context, snmp_engine_id, snmp_port, snmp_timeout, max_oids, "
                                "availability_method, ping_method, ping_port, 
ping_timeout, ping_retries, "
@@ -305,7 +306,7 @@
 
                /* data query structure for reindex detection */
                snprintf(query4, BUFSIZE,
-                       "SELECT data_query_id, action, op, assert_value, arg1"
+                       "SELECT SQL_NO_CACHE data_query_id, action, op, 
assert_value, arg1"
                                " FROM poller_reindex"
                                " WHERE host_id = %i", host_id);
 
@@ -313,7 +314,7 @@
                if (set.active_profiles != 1) {
                        if (set.total_snmp_ports == 1) {
                                snprintf(query5, BUFSIZE,
-                                       "SELECT action, hostname, 
snmp_community, "
+                                       "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                                "snmp_version, snmp_username, 
snmp_password, "
                                                "rrd_name, rrd_path, arg1, 
arg2, arg3, local_data_id, "
                                                "rrd_num, snmp_port, 
snmp_timeout, "
@@ -324,7 +325,7 @@
                                        " %s", host_id, limits);
                        } else {
                                snprintf(query5, BUFSIZE,
-                                       "SELECT action, hostname, 
snmp_community, "
+                                       "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                                "snmp_version, snmp_username, 
snmp_password, "
                                                "rrd_name, rrd_path, arg1, 
arg2, arg3, local_data_id, "
                                                "rrd_num, snmp_port, 
snmp_timeout, "
@@ -337,7 +338,7 @@
                } else {
                        if (set.total_snmp_ports == 1) {
                                snprintf(query5, BUFSIZE,
-                                       "SELECT action, hostname, 
snmp_community, "
+                                       "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                                "snmp_version, snmp_username, 
snmp_password, "
                                                "rrd_name, rrd_path, arg1, 
arg2, arg3, local_data_id, "
                                                "rrd_num, snmp_port, 
snmp_timeout, "
@@ -347,7 +348,7 @@
                                        " %s", host_id, limits);
                        } else {
                                snprintf(query5, BUFSIZE,
-                                       "SELECT action, hostname, 
snmp_community, "
+                                       "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                                "snmp_version, snmp_username, 
snmp_password, "
                                                "rrd_name, rrd_path, arg1, 
arg2, arg3, local_data_id, "
                                                "rrd_num, snmp_port, 
snmp_timeout, "
@@ -380,7 +381,7 @@
 
                /* number of agent's count for single polling interval */
                snprintf(query9, BUFSIZE,
-                       "SELECT snmp_port, count(snmp_port)"
+                       "SELECT SQL_NO_CACHE snmp_port, count(snmp_port)"
                        " FROM poller_item"
                        " WHERE host_id = %i"
                        " GROUP BY snmp_port %s", host_id, limits);
@@ -388,21 +389,21 @@
                /* number of agent's count for multiple polling intervals */
                if (set.active_profiles != 1) {
                        snprintf(query10, BUFSIZE,
-                               "SELECT snmp_port, count(snmp_port)"
+                               "SELECT SQL_NO_CACHE snmp_port, 
count(snmp_port)"
                                " FROM poller_item"
                                " WHERE host_id = %i"
                                " AND rrd_next_step <= 0"
                                " GROUP BY snmp_port %s", host_id, limits);
                } else {
                        snprintf(query10, BUFSIZE,
-                               "SELECT snmp_port, count(snmp_port)"
+                               "SELECT SQL_NO_CACHE snmp_port, 
count(snmp_port)"
                                " FROM poller_item"
                                " WHERE host_id = %i"
                                " GROUP BY snmp_port %s", host_id, limits);
                }
        } else {
                snprintf(query1, BUFSIZE,
-                       "SELECT action, hostname, snmp_community, "
+                       "SELECT SQL_NO_CACHE action, hostname, snmp_community, "
                                "snmp_version, snmp_username, snmp_password, "
                                "rrd_name, rrd_path, arg1, arg2, arg3, 
local_data_id, "
                                "rrd_num, snmp_port, snmp_timeout, "
@@ -414,7 +415,7 @@
 
                /* host structure for uptime checks */
                snprintf(query2, BIG_BUFSIZE,
-                       "SELECT id, hostname, snmp_community, snmp_version, "
+                       "SELECT SQL_NO_CACHE id, hostname, snmp_community, 
snmp_version, "
                                "snmp_username, snmp_password, 
snmp_auth_protocol, "
                                "snmp_priv_passphrase, snmp_priv_protocol, 
snmp_context, snmp_engine_id, snmp_port, snmp_timeout, max_oids, "
                                "availability_method, ping_method, ping_port, 
ping_timeout, ping_retries, "
@@ -429,14 +430,14 @@
 
                /* data query structure for reindex detection */
                snprintf(query4, BUFSIZE,
-                       "SELECT data_query_id, action, op, assert_value, arg1"
+                       "SELECT SQL_NO_CACHE data_query_id, action, op, 
assert_value, arg1"
                                " FROM poller_reindex"
                                " WHERE host_id = %i", host_id);
 
                /* multiple polling interval query for items */
                if (set.active_profiles != 1) {
                        snprintf(query5, BUFSIZE,
-                               "SELECT action, hostname, snmp_community, "
+                               "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                        "snmp_version, snmp_username, 
snmp_password, "
                                        "rrd_name, rrd_path, arg1, arg2, arg3, 
local_data_id, "
                                        "rrd_num, snmp_port, snmp_timeout, "
@@ -448,7 +449,7 @@
                                " ORDER by snmp_port %s", host_id, 
set.poller_id, limits);
                } else {
                        snprintf(query5, BUFSIZE,
-                               "SELECT action, hostname, snmp_community, "
+                               "SELECT SQL_NO_CACHE action, hostname, 
snmp_community, "
                                        "snmp_version, snmp_username, 
snmp_password, "
                                        "rrd_name, rrd_path, arg1, arg2, arg3, 
local_data_id, "
                                        "rrd_num, snmp_port, snmp_timeout, "
@@ -477,7 +478,7 @@
 
                /* number of agent's count for single polling interval */
                snprintf(query9, BUFSIZE,
-                       "SELECT snmp_port, count(snmp_port)"
+                       "SELECT SQL_NO_CACHE snmp_port, count(snmp_port)"
                        " FROM poller_item"
                        " WHERE host_id = %i"
                        " AND poller_id = %i"
@@ -486,7 +487,7 @@
                /* number of agent's count for multiple polling intervals */
                if (set.active_profiles != 1) {
                        snprintf(query10, BUFSIZE,
-                               "SELECT snmp_port, count(snmp_port)"
+                               "SELECT SQL_NO_CACHE snmp_port, 
count(snmp_port)"
                                " FROM poller_item"
                                " WHERE host_id = %i"
                                " AND rrd_next_step <= 0"
@@ -494,7 +495,7 @@
                                " GROUP BY snmp_port %s", host_id, 
set.poller_id, limits);
                } else {
                        snprintf(query10, BUFSIZE,
-                               "SELECT snmp_port, count(snmp_port)"
+                               "SELECT SQL_NO_CACHE snmp_port, 
count(snmp_port)"
                                " FROM poller_item"
                                " WHERE host_id = %i"
                                " AND poller_id = %i"
@@ -879,6 +880,9 @@
 
                                                                        
snprintf(poll_result, BUFSIZE, "%s", sysUptime);
                                                                } else if 
(strstr(reindex->arg1, ".1.3.6.1.2.1.1.3.0")) {
+                                                                    // Ensure 
uptime is empty to start with
+                                                                    
snprintf(sysUptime, BUFSIZE, "");
+
                                                                        // 
Check the legacy poll result first
                                                                        
poll_result = snmp_get(host, reindex->arg1);
 
@@ -899,9 +903,12 @@
 
                                                                        if 
(poll_result && is_numeric(poll_result)) {
                                                                                
snprintf(sysUptime, BUFSIZE, "%llu", atoll(poll_result) * 100);
-                                                                               
snprintf(poll_result, BUFSIZE, "%s", sysUptime);
                                                                        }
 
+                                                                       // Use 
the primed uptime to repopulate the poll_result
+                                                                       // This 
ensures whichever response was valid gets used
+                                                                       
snprintf(poll_result, BUFSIZE, "%s", sysUptime);
+
                                                                        if 
(is_debug_device(host->id)) {
                                                                                
SPINE_LOG(("Device[%i] HT[%i] DQ[%i] Extended Uptime Result: %s, Is Numeric: 
%d", host->id, host_thread, reindex->data_query_id, poll_result, 
is_numeric(poll_result) ));
                                                                        } else {
@@ -2127,6 +2134,7 @@
        double begin_time = 0;
        double end_time = 0;
        double script_timeout;
+       double remaining_usec = 0;
        struct timeval timeout;
        char *proc_command;
        char *result_string;
@@ -2232,10 +2240,16 @@
                                        end_time = get_time_as_double();
 
                                        /* re-establish new timeout value */
-                                       timeout.tv_sec = 
rint(floor(script_timeout-(end_time-begin_time)));
-                                       timeout.tv_usec = 
rint((script_timeout-(end_time-begin_time)-timeout.tv_sec)*1000000);
+                                       timeout.tv_sec  = 
rint(floor(script_timeout-(end_time-begin_time)));
+                                       remaining_usec  = set.script_timeout - 
timeout.tv_sec - (end_time - begin_time);
+
+                                       if (remaining_usec > 0) {
+                                               timeout.tv_usec = 
rint(remaining_usec * 1000000);
+                                       } else {
+                                               timeout.tv_usec = 0;
+                                       }
 
-                                       if ((end_time - begin_time) < 
set.script_timeout) {
+                                       if (timeout.tv_sec + timeout.tv_usec > 
0) {
                                                goto retry;
                                        } else {
                                                SPINE_LOG(("WARNING: A script 
timed out while processing EINTR's."));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/spine.c 
new/cacti-spine-1.2.23/spine.c
--- old/cacti-spine-1.2.22/spine.c      2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/spine.c      2023-01-02 15:48:31.000000000 +0100
@@ -619,9 +619,9 @@
 
        /* obtain the list of hosts to poll */
        if (set.device_threads_exists) {
-               qp += sprintf(qp, "SELECT id, device_threads FROM host");
+               qp += sprintf(qp, "SELECT SQL_NO_CACHE id, device_threads FROM 
host");
        } else {
-               qp += sprintf(qp, "SELECT id, '1' as device_threads FROM host");
+               qp += sprintf(qp, "SELECT SQL_NO_CACHE id, '1' as 
device_threads FROM host");
        }
        qp += sprintf(qp, " WHERE disabled=''");
        if (!strlen(set.host_id_list)) {
@@ -733,9 +733,9 @@
 
                /* adjust device threads in cases where the host does not have 
sufficient data sources */
                if (set.active_profiles != 1) {
-                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
COUNT(local_data_id) FROM poller_item WHERE host_id=%i AND rrd_next_step <=0", 
host_id);
+                       snprintf(querybuf, BIG_BUFSIZE, "SELECT SQL_NO_CACHE 
COUNT(local_data_id) FROM poller_item WHERE host_id=%i AND rrd_next_step <=0", 
host_id);
                } else {
-                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
COUNT(local_data_id) FROM poller_item WHERE host_id=%i", host_id);
+                       snprintf(querybuf, BIG_BUFSIZE, "SELECT SQL_NO_CACHE 
COUNT(local_data_id) FROM poller_item WHERE host_id=%i", host_id);
                }
 
                tresult   = db_query(&mysql, LOCAL, querybuf);
@@ -754,9 +754,9 @@
                if (device_threads > 1) {
                        if (current_thread == 1) {
                                if (set.active_profiles != 1) {
-                                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
CEIL(COUNT(local_data_id)/%i) FROM poller_item WHERE host_id=%i AND 
rrd_next_step <=0", device_threads, host_id);
+                                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
SQL_NO_CACHE CEIL(COUNT(local_data_id)/%i) FROM poller_item WHERE host_id=%i 
AND rrd_next_step <=0", device_threads, host_id);
                                } else {
-                                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
CEIL(COUNT(local_data_id)/%i) FROM poller_item WHERE host_id=%i", 
device_threads, host_id);
+                                       snprintf(querybuf, BIG_BUFSIZE, "SELECT 
SQL_NO_CACHE CEIL(COUNT(local_data_id)/%i) FROM poller_item WHERE host_id=%i", 
device_threads, host_id);
                                }
 
                                tresult   = db_query(&mysql, LOCAL, querybuf);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/spine.h 
new/cacti-spine-1.2.23/spine.h
--- old/cacti-spine-1.2.22/spine.h      2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/spine.h      2023-01-02 15:48:31.000000000 +0100
@@ -377,6 +377,7 @@
        unsigned int db_port;
        char   dbversion[SMALL_BUFSIZE];
        int    dbonupdate;
+       int   cacti_version;
        /* path information */
        char   path_logfile[DBL_BUFSIZE];
        char   path_php[BUFSIZE];
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/sql.c new/cacti-spine-1.2.23/sql.c
--- old/cacti-spine-1.2.22/sql.c        2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/sql.c        2023-01-02 15:48:31.000000000 +0100
@@ -350,6 +350,7 @@
                free(hostname);
        }
 
+    #ifdef HAS_MYSQL_OPT_SSL_KEY
        if (ssl_key != NULL) {
                free(ssl_key);
        }
@@ -361,6 +362,7 @@
        if (ssl_cert != NULL) {
                free(ssl_cert);
        }
+    #endif
 
        if (!success){
                printf("FATAL: Connection Failed, Error:'%i', Message:'%s'\n", 
error, mysql_error(mysql));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.22/util.c 
new/cacti-spine-1.2.23/util.c
--- old/cacti-spine-1.2.22/util.c       2022-08-14 23:44:27.000000000 +0200
+++ new/cacti-spine-1.2.23/util.c       2023-01-02 15:48:31.000000000 +0100
@@ -95,7 +95,7 @@
                }
        }
 
-       sprintf(qstring, "SELECT value FROM settings WHERE name = '%s'", 
setting);
+       sprintf(qstring, "SELECT SQL_NO_CACHE value FROM settings WHERE name = 
'%s'", setting);
 
        result = db_query(psql, mode, qstring);
 
@@ -187,7 +187,7 @@
                }
        }
 
-       sprintf(qstring, "SELECT %s FROM poller WHERE id = '%d'", setting, 
set.poller_id);
+       sprintf(qstring, "SELECT SQL_NO_CACHE %s FROM poller WHERE id = '%d'", 
setting, set.poller_id);
 
        result = db_query(psql, mode, qstring);
 
@@ -368,6 +368,12 @@
                set.dbonupdate = 0;
        }
 
+       /* get the cacti version from the database */
+       set.cacti_version = get_cacti_version(&mysql, LOCAL);
+
+       /* log the path_webroot variable */
+       SPINE_LOG_DEBUG(("DEBUG: The binary Cacti version is %s", 
set.cacti_version));
+
        /* get logging level from database - overrides spine.conf */
        if ((res = getsetting(&mysql, LOCAL, "log_verbosity")) != 0) {
                const int n = atoi(res);
@@ -679,7 +685,7 @@
        /* log the requirement for the script server */
        if (!strlen(set.host_id_list)) {
                sqlp = sqlbuf;
-               sqlp += sprintf(sqlp, "SELECT action FROM poller_item");
+               sqlp += sprintf(sqlp, "SELECT SQL_NO_CACHE action FROM 
poller_item");
                sqlp += sprintf(sqlp, " WHERE action=%d", 
POLLER_ACTION_PHP_SCRIPT_SERVER);
                sqlp += append_hostrange(sqlp, "host_id");
                if (set.poller_id_exists) {
@@ -699,7 +705,7 @@
                        num_rows));
        } else {
                sqlp = sqlbuf;
-               sqlp += sprintf(sqlp, "SELECT action FROM poller_item");
+               sqlp += sprintf(sqlp, "SELECT SQL_NO_CACHE action FROM 
poller_item");
                sqlp += sprintf(sqlp, " WHERE action=%d", 
POLLER_ACTION_PHP_SCRIPT_SERVER);
                sqlp += sprintf(sqlp, " AND host_id IN(%s)", set.host_id_list);
                if (set.poller_id_exists) {
@@ -806,7 +812,7 @@
        SPINE_LOG_MEDIUM(("Pushing Host Status to Main Server"));
 
        if (strlen(set.host_id_list)) {
-               snprintf(query, MEGA_BUFSIZE, "SELECT id, snmp_sysDescr, 
snmp_sysObjectID, "
+               snprintf(query, MEGA_BUFSIZE, "SELECT SQL_NO_CACHE id, 
snmp_sysDescr, snmp_sysObjectID, "
                        "snmp_sysUpTimeInstance, snmp_sysContact, snmp_sysName, 
snmp_sysLocation, "
                        "status, status_event_count, status_fail_date, 
status_rec_date, "
                        "status_last_error, min_time, max_time, cur_time, 
avg_time, polling_time, "
@@ -815,7 +821,7 @@
                        "WHERE poller_id = %d "
                        "AND id IN (%s)", set.poller_id, set.host_id_list);
        } else {
-               snprintf(query, MEGA_BUFSIZE, "SELECT id, snmp_sysDescr, 
snmp_sysObjectID, "
+               snprintf(query, MEGA_BUFSIZE, "SELECT SQL_NO_CACHE id, 
snmp_sysDescr, snmp_sysObjectID, "
                        "snmp_sysUpTimeInstance, snmp_sysContact, snmp_sysName, 
snmp_sysLocation, "
                        "status, status_event_count, status_fail_date, 
status_rec_date, "
                        "status_last_error, min_time, max_time, cur_time, 
avg_time, polling_time, "
@@ -952,12 +958,12 @@
        SPINE_LOG_MEDIUM(("Pushing Poller Item RRD Next Step to Main Server"));
 
        if (strlen(set.host_id_list)) {
-               snprintf(query, MEGA_BUFSIZE, "SELECT local_data_id, host_id, 
rrd_name, rrd_step, rrd_next_step "
+               snprintf(query, MEGA_BUFSIZE, "SELECT SQL_NO_CACHE 
local_data_id, host_id, rrd_name, rrd_step, rrd_next_step "
                        "FROM poller_item "
                        "WHERE poller_id = %d "
                        "AND host_id IN (%s)", set.poller_id, set.host_id_list);
        } else {
-               snprintf(query, MEGA_BUFSIZE, "SELECT local_data_id, host_id, 
rrd_name, rrd_step, rrd_next_step "
+               snprintf(query, MEGA_BUFSIZE, "SELECT SQL_NO_CACHE 
local_data_id, host_id, rrd_name, rrd_step, rrd_next_step "
                        "FROM poller_item "
                        "WHERE poller_id = %d ",
                        set.poller_id);
@@ -1956,3 +1962,55 @@
        #endif
        #endif
 }
+
+/*! \fn int get_cacti_version(MYSQL *psql, int mode, const char *setting)
+ *  \brief Returns the version of Cacti as a decimal
+ *
+ *  Given a pointer to a database get the version of Cacti and convert
+ *  to an integer.
+ *
+ *  \return the cacti version
+ *
+ */
+int get_cacti_version(MYSQL *psql, int mode) {
+       char      qstring[256];
+       char      *retval;
+       MYSQL_RES *result;
+       MYSQL_ROW mysql_row;
+       int       i;
+       int       major, minor, point;
+       int       cacti_version;
+
+       assert(psql != 0);
+
+       sprintf(qstring, "SELECT cacti FROM version LIMIT 1");
+
+       result = db_query(psql, mode, qstring);
+
+       if (result != 0) {
+               if (mysql_num_rows(result) > 0) {
+                       mysql_row = mysql_fetch_row(result);
+
+                       if (mysql_row != NULL) {
+                               retval = strdup(mysql_row[0]);
+                               db_free_result(result);
+
+                               if (STRIMATCH(retval, "new_install")) {
+                                       return 0;
+                               } else {
+                                       sscanf(retval, "%d.%d.%d", &major, 
&minor, &point);
+                                       cacti_version = (major * 1000) + (minor 
* 100) + (point * 1);
+                                       return cacti_version;
+                               }
+                       }else{
+                               return 0;
+                       }
+               }else{
+                       db_free_result(result);
+                       return 0;
+               }
+       }else{
+               return 0;
+       }
+}
+

Reply via email to