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-12-25 19:06:04
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cacti-spine (Old)
 and      /work/SRC/openSUSE:Factory/.cacti-spine.new.28375 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cacti-spine"

Mon Dec 25 19:06:04 2023 rev:41 rq:1134984 version:1.2.26

Changes:
--------
--- /work/SRC/openSUSE:Factory/cacti-spine/cacti-spine.changes  2023-09-06 
19:03:44.179414603 +0200
+++ /work/SRC/openSUSE:Factory/.cacti-spine.new.28375/cacti-spine.changes       
2023-12-25 19:06:18.823701265 +0100
@@ -1,0 +2,11 @@
+Sun Dec 24 13:00:25 UTC 2023 - Andreas Stieger <[email protected]>
+
+- cacti-spine 1.2.26:
+  * Fix: Errors when uptime OID is not present
+  * Fix: MySQL reconnect option is depreciated
+  * Fix: Spine does not check a host with no poller items
+  * Fix: Poller may report the wrong number of devices polled
+  * Feature: Allow users to override the threads setting at the command line
+  * Feature: Allow spine to run in ping-only mode
+
+-------------------------------------------------------------------

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

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

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

Other differences:
------------------
++++++ cacti-spine.spec ++++++
--- /var/tmp/diff_new_pack.YSPK0E/_old  2023-12-25 19:06:19.307718928 +0100
+++ /var/tmp/diff_new_pack.YSPK0E/_new  2023-12-25 19:06:19.311719074 +0100
@@ -18,12 +18,12 @@
 
 %{!?make_build: %define make_build make %{?_smp_mflags}}
 Name:           cacti-spine
-Version:        1.2.25
+Version:        1.2.26
 Release:        0
 Summary:        Threaded poller for Cacti written in C
 License:        LGPL-2.1-or-later
 URL:            https://www.cacti.net/spine_info.php
-Source:         http://files.cacti.net/spine/%{name}-%{version}.tar.gz
+Source:         https://www.cacti.net/downloads/spine/%{name}-%{version}.tar.gz
 BuildRequires:  help2man
 BuildRequires:  libtool
 BuildRequires:  mysql-devel

++++++ cacti-spine-1.2.25.tar.gz -> cacti-spine-1.2.26.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/CHANGELOG 
new/cacti-spine-1.2.26/CHANGELOG
--- old/cacti-spine-1.2.25/CHANGELOG    2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/CHANGELOG    2023-12-24 03:18:40.000000000 +0100
@@ -1,5 +1,13 @@
 The Cacti Group | spine
 
+1.2.26
+-issue#315: Errors cam be reported when uptime OID is not present
+-issue#317: MySQL reconnect option is depreciated
+-issue#321: Spine does not check a host with no poller items
+-issue#323: Poller may report the wrong number of devices polled
+-feature#329: Allow users to override the threads setting at the command line
+-feature#331: Allow spine to run in ping-only mode
+
 1.2.25
 -issue#234: Spine should see if script to be executed is executable
 -issue#291: Enhance number recognition
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/README.md 
new/cacti-spine-1.2.26/README.md
--- old/cacti-spine-1.2.25/README.md    2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/README.md    2023-12-24 03:18:40.000000000 +0100
@@ -20,6 +20,7 @@
 following:
 
 ```shell
+./bootstrap
 ./configure
 make
 make install
@@ -31,6 +32,7 @@
 following:
 
 ```shell
+./bootstrap
 ./configure --with-reentrant
 make
 make install
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/configure.ac 
new/cacti-spine-1.2.26/configure.ac
--- old/cacti-spine-1.2.25/configure.ac 2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/configure.ac 2023-12-24 03:18:40.000000000 +0100
@@ -20,7 +20,7 @@
 # +-------------------------------------------------------------------------+
 
 AC_PREREQ([2.63])
-AC_INIT([Spine Poller],[1.2.25],[http://www.cacti.net/issues.php])
+AC_INIT([Spine Poller],[1.2.26],[http://www.cacti.net/issues.php])
 
 AC_CONFIG_AUX_DIR(config)
 AC_SUBST(ac_aux_dir)
@@ -284,7 +284,7 @@
 unamestr=$(uname)
 if test $unamestr == 'OpenBSD'; then
   AC_CHECK_LIB(mysqlclient, mysql_init,
-    [ LIBS="-lmysqlclient -lm $LIBS"
+    [ LIBS="-lmysqlclient -lexecinfo -lm $LIBS"
       AC_DEFINE(HAVE_MYSQL, 1, MySQL Client API)
       HAVE_MYSQL=yes ],
     [ HAVE_MYSQL=no ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/error.c 
new/cacti-spine-1.2.26/error.c
--- old/cacti-spine-1.2.25/error.c      2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/error.c      2023-12-24 03:18:40.000000000 +0100
@@ -52,7 +52,6 @@
        time_t nowbin;
        struct tm now_time;
        struct tm *now_ptr;
-       struct timeval now;
 
        /* get time for poller_output table */
        nowbin = time(&nowbin);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/ping.c 
new/cacti-spine-1.2.26/ping.c
--- old/cacti-spine-1.2.25/ping.c       2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/ping.c       2023-12-24 03:18:40.000000000 +0100
@@ -47,6 +47,8 @@
 int ping_host(host_t *host, ping_t *ping) {
        int ping_result;
        int snmp_result;
+       double start_time;
+       double end_time;
 
        /* snmp pinging has been selected at a minimum */
        ping_result = 0;
@@ -102,7 +104,23 @@
                        snmp_result = HOST_UP;
                        if ((host->availability_method != AVAIL_SNMP_OR_PING) &&
                                ((strlen(host->snmp_community) > 0) || 
(host->snmp_version >= 3))) {
+                               start_time = get_time_as_double();
                                snmp_result = ping_snmp(host, ping);
+                               end_time = get_time_as_double();
+
+                               if (snmp_result == HOST_UP) {
+                                       if (is_debug_device(host->id)) {
+                                               SPINE_LOG(("Device[%i] INFO: 
SNMP Device Alive, Time:%.4f ms", host->id, end_time - start_time));
+                                       } else {
+                                               SPINE_LOG_MEDIUM(("Device[%i] 
INFO: SNMP Device Alive, Time:%.4f ms", host->id, end_time - start_time));
+                                       }
+                               } else {
+                                       if (is_debug_device(host->id)) {
+                                               SPINE_LOG(("Device[%i] INFO: 
SNMP Device Down, Time:%.4f ms", host->id, end_time - start_time));
+                                       } else {
+                                               SPINE_LOG_MEDIUM(("Device[%i] 
INFO: SNMP Device Down, Time:%.4f ms", host->id, end_time - start_time));
+                                       }
+                               }
                        }
                }
        }
@@ -194,9 +212,9 @@
                                        }
                                } else {
                                        if (host->snmp_status == STAT_TIMEOUT) {
-                                               SPINE_LOG_MEDIUM(("Device[%i] 
SNMP Ping Timeout", host->id));
+                                               SPINE_LOG_HIGH(("Device[%i] 
SNMP Ping Timeout", host->id));
                                        } else {
-                                               SPINE_LOG_MEDIUM(("Device[%i] 
SNMP Ping Unknown Error", host->id));
+                                               SPINE_LOG_HIGH(("Device[%i] 
SNMP Ping Unknown Error", host->id));
                                        }
                                }
 
@@ -424,9 +442,9 @@
                                                if (fromname.sin_addr.s_addr == 
recvname.sin_addr.s_addr) {
                                                        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)));
+                                                                       
SPINE_LOG(("Device[%i] INFO: ICMP Device Alive, Try Count:%i, Time:%.4f ms", 
host->id, retry_count+1, (total_time)));
                                                                } else {
-                                                                       
SPINE_LOG_DEBUG(("Device[%i] DEBUG: ICMP Device Alive, Try Count:%i, Time:%.4f 
ms", host->id, retry_count+1, (total_time)));
+                                                                       
SPINE_LOG_MEDIUM(("Device[%i] INFO: ICMP Device Alive, Try Count:%i, Time:%.4f 
ms", host->id, retry_count+1, (total_time)));
                                                                }
                                                                
snprintf(ping->ping_response, SMALL_BUFSIZE, "ICMP: Device is Alive");
                                                                
snprintf(ping->ping_status, 50, "%.5f", total_time);
@@ -643,9 +661,9 @@
 
                                                if (return_code == -1 && (errno 
== EHOSTUNREACH || errno == ECONNRESET || errno == ECONNREFUSED)) {
                                                        if 
(is_debug_device(host->id)) {
-                                                               
SPINE_LOG(("Device[%i] DEBUG: UDP Device Alive, Try Count:%i, Time:%.4f ms", 
host->id, retry_count+1, (total_time)));
+                                                               
SPINE_LOG(("Device[%i] INFO: UDP Device Alive, Try Count:%i, Time:%.4f ms", 
host->id, retry_count+1, (total_time)));
                                                        } else {
-                                                               
SPINE_LOG_DEBUG(("Device[%i] DEBUG: UDP Device Alive, Try Count:%i, Time:%.4f 
ms", host->id, retry_count+1, (total_time)));
+                                                               
SPINE_LOG_MEDIUM(("Device[%i] INFO: UDP Device Alive, Try Count:%i, Time:%.4f 
ms", host->id, retry_count+1, (total_time)));
                                                        }
                                                        
snprintf(ping->ping_response, SMALL_BUFSIZE, "UDP: Device is Alive");
                                                        
snprintf(ping->ping_status, 50, "%.5f", total_time);
@@ -765,9 +783,9 @@
 
                                if ((return_code == -1 && errno == 
ECONNREFUSED) || return_code == 0) {
                                        if (is_debug_device(host->id)) {
-                                               SPINE_LOG(("Device[%i] DEBUG: 
TCP Device Alive, Try Count:%i, Time:%.4f ms", host->id, retry_count+1, 
(total_time)));
+                                               SPINE_LOG(("Device[%i] INFO: 
TCP Device Alive, Try Count:%i, Time:%.4f ms", host->id, retry_count+1, 
(total_time)));
                                        } else {
-                                               SPINE_LOG_DEBUG(("Device[%i] 
DEBUG: TCP Device Alive, Try Count:%i, Time:%.4f ms", host->id, retry_count+1, 
(total_time)));
+                                               SPINE_LOG_MEDIUM(("Device[%i] 
INFO: TCP Device Alive, Try Count:%i, Time:%.4f ms", host->id, retry_count+1, 
(total_time)));
                                        }
                                        snprintf(ping->ping_response, 
SMALL_BUFSIZE, "TCP: Device is Alive");
                                        snprintf(ping->ping_status, 50, "%.5f", 
total_time);
@@ -813,7 +831,7 @@
 int get_address_type(host_t *host) {
        struct addrinfo hints, *res, *res_list;
        char addrstr[255];
-       void *ptr;
+       void *ptr = NULL;
        int addr_found = FALSE;
 
        memset(&hints, 0, sizeof(hints));
@@ -869,7 +887,7 @@
  *
  */
 int init_sockaddr(struct sockaddr_in *name, const char *hostname, unsigned 
short int port) {
-       struct addrinfo hints, *hostinfo, *p;
+       struct addrinfo hints, *hostinfo;
        int rv, retry_count;
 
        // Initialize the hints structure
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/poller.c 
new/cacti-spine-1.2.26/poller.c
--- old/cacti-spine-1.2.25/poller.c     2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/poller.c     2023-12-24 03:18:40.000000000 +0100
@@ -152,14 +152,7 @@
        char *query12 = NULL;
        char posuffix[BUFSIZE];
 
-       int query1_len   = 0;
-       int query2_len   = 0;
-       int query4_len   = 0;
-       int query5_len   = 0;
-       int query6_len   = 0;
        int query8_len   = 0;
-       int query9_len   = 0;
-       int query10_len  = 0;
        int query11_len  = 0;
        int posuffix_len = 0;
 
@@ -556,14 +549,7 @@
                "INSERT INTO poller_output_boost"
                " (local_data_id, rrd_name, time, output) VALUES");
 
-       query1_len   = strlen(query1);
-       query2_len   = strlen(query2);
-       query4_len   = strlen(query4);
-       query5_len   = strlen(query5);
-       query6_len   = strlen(query6);
        query8_len   = strlen(query8);
-       query9_len   = strlen(query9);
-       query10_len  = strlen(query10);
        query11_len  = strlen(query11);
        posuffix_len = strlen(posuffix);
 
@@ -581,6 +567,7 @@
 
                        if (num_rows != 1) {
                                mysql_free_result(result);
+
                                if (local_cnn != NULL) {
                                        db_release_connection(LOCAL, 
local_cnn->id);
                                } else {
@@ -598,6 +585,9 @@
                                SPINE_FREE(host);
                                SPINE_FREE(reindex);
                                SPINE_FREE(ping);
+                               SPINE_FREE(error_string);
+                               SPINE_FREE(buf_size);
+                               SPINE_FREE(buf_errors);
 
                                return;
                        }
@@ -753,7 +743,7 @@
                                                        
update_host_status(HOST_UP, host, ping, host->availability_method);
 
                                                        if 
((host->availability_method != AVAIL_PING) && (host->availability_method != 
AVAIL_NONE)) {
-                                                               if 
(host->snmp_session != NULL) {
+                                                               if 
(host->snmp_session != NULL && set.mibs) {
                                                                        
get_system_information(host, &mysql, 1);
                                                                        
ignore_sysinfo = FALSE;
                                                                }
@@ -859,6 +849,33 @@
                host->ignore_host  = FALSE;
        }
 
+       if (set.ping_only) {
+               SPINE_FREE(host);
+               SPINE_FREE(reindex);
+               SPINE_FREE(ping);
+               SPINE_FREE(error_string);
+               SPINE_FREE(buf_size);
+               SPINE_FREE(buf_errors);
+
+               if (local_cnn != NULL) {
+                       db_release_connection(LOCAL, local_cnn->id);
+               } else {
+                       SPINE_LOG(("WARNING: Device[%i] HT[%i] Trying to close 
uninitialized local connection.", host_id, host_thread));
+               }
+
+               if (set.poller_id > 1 && set.mode == REMOTE_ONLINE) {
+                       if (remote_cnn != NULL) {
+                               db_release_connection(REMOTE, remote_cnn->id);
+                       } else {
+                               SPINE_LOG(("WARNING: Device[%i] HT[%i] Trying 
to close uninitialized remote connection.", host_id, host_thread));
+                       }
+               }
+
+               mysql_thread_end();
+
+               return;
+       }
+
        /* do the reindex check for this host if not script based */
        if ((!host->ignore_host) && (host_id)) {
                if ((result = db_query(&mysql, LOCAL, query4)) != 0) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/snmp.c 
new/cacti-spine-1.2.26/snmp.c
--- old/cacti-spine-1.2.25/snmp.c       2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/snmp.c       2023-12-24 03:18:40.000000000 +0100
@@ -189,7 +189,7 @@
        session.retries     = set.snmp_retries;
        session.timeout     = (snmp_timeout * 1000); /* net-snmp likes 
microseconds */
 
-       SPINE_LOG_MEDIUM(("Device[%i] INFO: SNMP Device '%s' has a timeout of 
%ld (%d), with %d retries", host_id, hostnameport, session.timeout, 
snmp_timeout, session.retries));
+       SPINE_LOG_HIGH(("Device[%i] INFO: SNMP Device '%s' has a timeout of %ld 
(%d), with %d retries", host_id, hostnameport, session.timeout, snmp_timeout, 
session.retries));
 
        if ((snmp_version == 2) || (snmp_version == 1)) {
                session.community     = (unsigned char*) snmp_community;
@@ -458,7 +458,13 @@
                                } else if (vars->type == SNMP_NOSUCHINSTANCE) {
                                        SET_UNDEFINED(result_string);
                                        status = STAT_ERROR;
-                                       SPINE_LOG_HIGH(("ERROR: No such 
Instance for oid '%s' for Device[%d] with Status[%d]",  snmp_oid, 
current_host->id, status));
+
+                                       // We will ignore the new OID error
+                                       if (!strstr(snmp_oid, 
".1.3.6.1.6.3.10.2.1.3.0")) {
+                                               SPINE_LOG_HIGH(("WARNING: No 
such Instance for oid '%s' for Device[%d] with Status[%d]",  snmp_oid, 
current_host->id, status));
+                                       } else {
+                                               SPINE_LOG_DEBUG(("NOTE: Legacy 
SNMP agent found!  No per second Uptime oid found '%s' for Device[%d] with 
Status[%d]",  snmp_oid, current_host->id, status));
+                                       }
                                } else if (vars->type == SNMP_ENDOFMIBVIEW) {
                                        SET_UNDEFINED(result_string);
                                        status = STAT_ERROR;
@@ -481,7 +487,13 @@
                        } else if (vars->type == SNMP_NOSUCHINSTANCE) {
                                SET_UNDEFINED(result_string);
                                status = STAT_ERROR;
-                               SPINE_LOG_HIGH(("ERROR: No such Instance for 
oid '%s' for Device[%d] with Status[%d]",  snmp_oid, current_host->id, status));
+
+                               // We will ignore the new OID error
+                               if (!strstr(snmp_oid, 
".1.3.6.1.6.3.10.2.1.3.0")) {
+                                       SPINE_LOG_HIGH(("WARNING: No such 
Instance for oid '%s' for Device[%d] with Status[%d]",  snmp_oid, 
current_host->id, status));
+                               } else {
+                                       SPINE_LOG_DEBUG(("NOTE: Per second 
level uptime oid missing oid '%s' for Device[%d] with Status[%d]",  snmp_oid, 
current_host->id, status));
+                               }
                        } else if (vars->type == SNMP_ENDOFMIBVIEW) {
                                SET_UNDEFINED(result_string);
                                status = STAT_ERROR;
@@ -575,7 +587,7 @@
                                        if (vars != NULL) {
                                                snprint_value(temp_result, 
RESULTS_BUFFER, vars->name, vars->name_length, vars);
 
-                                               
snprint_asciistring(result_string, RESULTS_BUFFER, temp_result, 
strlen(temp_result));
+                                               
snprint_asciistring(result_string, RESULTS_BUFFER, (unsigned char 
*)temp_result, strlen(temp_result));
                                        } else {
                                                SET_UNDEFINED(result_string);
                                                status = STAT_ERROR;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/spine.c 
new/cacti-spine-1.2.26/spine.c
--- old/cacti-spine-1.2.25/spine.c      2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/spine.c      2023-12-24 03:18:40.000000000 +0100
@@ -256,6 +256,10 @@
        /* initialize icmp_avail */
        set.icmp_avail = TRUE;
 
+       /* initialize number of threads */
+       set.threads = 1;
+       set.threads_set = FALSE;
+
        /* detect and compensate for stdin/stderr ttys */
        if (!isatty(fileno(stdout))) {
                set.stdout_notty = TRUE;
@@ -322,6 +326,7 @@
        set.logfile_processed = FALSE;
        set.parent_fork       = SPINE_PARENT;
        set.mode              = REMOTE_ONLINE;
+       set.has_device_0      = FALSE;
 
        for (argv++; *argv; argv++) {
                char    *arg = *argv;
@@ -357,6 +362,15 @@
                        set.poller_id = atoi(getarg(opt, &argv));
                }
 
+               else if (STRMATCH(arg, "-t") || STRIMATCH(arg, "--threads")) {
+                       set.threads = atoi(getarg(opt, &argv));
+                       set.threads_set = TRUE;
+               }
+
+               else if (STRMATCH(arg, "-P") || STRIMATCH(arg, "--pingonly")) {
+                       set.ping_only = TRUE;
+               }
+
                else if (STRMATCH(arg, "-N") || STRIMATCH(arg, "--mode")) {
                        if (STRIMATCH(getarg(opt, &argv), "online")) {
                                set.mode = REMOTE_ONLINE;
@@ -435,6 +449,10 @@
                }
        }
 
+       if (set.ping_only) {
+               set.mibs = 0;
+       }
+
        /* we attempt to support scripts better in cygwin */
        #if defined(__CYGWIN__)
        setenv("CYGWIN", "nodosfilewarning", 1);
@@ -532,6 +550,14 @@
                mode = LOCAL;
        }
 
+
+       /* check for device 0 items */
+       result = db_query(&mysql, LOCAL, "SELECT * FROM (SELECT COUNT(*) AS 
items FROM poller_item WHERE host_id = 0 AND poller_id = 1) AS rs WHERE 
rs.items > 0");
+       if (mysql_num_rows(result)) {
+               set.has_device_0 = TRUE;
+       }
+       db_free_result(result);
+
        /* Since MySQL 5.7 the sql_mode defaults are too strict for cacti */
        db_insert(&mysql, LOCAL, "SET SESSION sql_mode = (SELECT 
REPLACE(@@sql_mode,'NO_ZERO_DATE', ''))");
        db_insert(&mysql, LOCAL, "SET SESSION sql_mode = (SELECT 
REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', ''))");
@@ -560,6 +586,12 @@
                }
        }
 
+       if (set.has_device_0) {
+               SPINE_LOG_MEDIUM(("Device 0 Poller Items found.  Ensure that 
these entries are accurate"));
+       } else {
+               SPINE_LOG_MEDIUM(("No Device 0 Poller Items found."));
+       }
+
        /* see if mysql is thread safe */
        if (mysql_thread_safe()) {
                if (set.log_level == POLLER_VERBOSITY_DEBUG) {
@@ -583,7 +615,7 @@
        set.parent_fork = SPINE_PARENT;
 
        /* initialize the script server */
-       if (set.php_required) {
+       if (set.php_required && !set.ping_only) {
                php_init(PHP_INIT);
                set.php_initialized    = TRUE;
                set.php_current_server = 0;
@@ -603,7 +635,7 @@
        db_free_result(result);
 
        /* obtain the list of hosts to poll */
-       qp += sprintf(qp, "SELECT SQL_NO_CACHE id, device_threads, picount, 
picount/device_threads AS tppi FROM host INNER JOIN (SELECT host_id, COUNT(*) 
AS picount FROM poller_item GROUP BY host_id) AS pi ON host.id = pi.host_id");
+       qp += sprintf(qp, "SELECT SQL_NO_CACHE id, device_threads, picount, 
picount/device_threads AS tppi FROM host LEFT JOIN (SELECT host_id, COUNT(*) AS 
picount FROM poller_item GROUP BY host_id) AS pi ON host.id = pi.host_id");
        qp += sprintf(qp, " WHERE disabled = ''");
 
        if (!strlen(set.host_id_list)) {
@@ -621,7 +653,11 @@
        result = db_query(&mysql, LOCAL, querybuf);
 
        if (set.poller_id == 1) {
-               num_rows = mysql_num_rows(result) + 1; /* pollerid 1 takes care 
of not host based data sources */
+               if (set.has_device_0) {
+                       num_rows = mysql_num_rows(result) + 1; /* pollerid 1 
takes care of non host based data sources */
+               } else {
+                       num_rows = mysql_num_rows(result); /* pollerid 1 takes 
care of non host based data sources */
+               }
        } else {
                num_rows = mysql_num_rows(result);
        }
@@ -648,11 +684,13 @@
        SOCK_STARTUP;
 
        /* mark the spine process as started */
-       snprintf(querybuf, BIG_BUFSIZE, "INSERT INTO poller_time (poller_id, 
pid, start_time, end_time) VALUES (%i, %i, NOW(), '0000-00-00 00:00:00')", 
set.poller_id, getpid());
-       if (mode == REMOTE) {
-               db_insert(&mysqlr, REMOTE, querybuf);
-       } else {
-               db_insert(&mysql, LOCAL, querybuf);
+       if (!set.ping_only) {
+               snprintf(querybuf, BIG_BUFSIZE, "INSERT INTO poller_time 
(poller_id, pid, start_time, end_time) VALUES (%i, %i, NOW(), '0000-00-00 
00:00:00')", set.poller_id, getpid());
+               if (mode == REMOTE) {
+                       db_insert(&mysqlr, REMOTE, querybuf);
+               } else {
+                       db_insert(&mysql, LOCAL, querybuf);
+               }
        }
 
        /* initialize threads and mutexes */
@@ -675,7 +713,7 @@
        until_spec.tv_nsec = 0;
 
        sem_getvalue(&available_threads, &a_threads_value);
-       SPINE_LOG_MEDIUM(("DEBUG: Initial Value of Available Threads is %i (%i 
outstanding)", a_threads_value, set.threads - a_threads_value));
+       SPINE_LOG_HIGH(("DEBUG: Initial Value of Available Threads is %i (%i 
outstanding)", a_threads_value, set.threads - a_threads_value));
 
        /* tell fork processes that they are now active */
        set.parent_fork = SPINE_FORK;
@@ -684,8 +722,8 @@
        device_threads   = 1;
        current_thread   = 0;
 
-       /* poller 0 always polls host 0 */
-       if (set.poller_id == 1) {
+       /* poller 1 always polls host 0 but only if it exists */
+       if (set.poller_id == 1 && set.has_device_0 == TRUE) {
                host_id     = 0;
                change_host = FALSE;
        } else {
@@ -716,20 +754,24 @@
                }
 
                /* adjust device threads in cases where the host does not have 
sufficient data sources */
-               if (set.active_profiles != 1) {
-                       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 SQL_NO_CACHE 
COUNT(local_data_id) FROM poller_item WHERE host_id=%i", host_id);
-               }
+               if (!set.ping_only) {
+                       if (set.active_profiles != 1) {
+                               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 
SQL_NO_CACHE COUNT(local_data_id) FROM poller_item WHERE host_id=%i", host_id);
+                       }
 
-               tresult   = db_query(&mysql, LOCAL, querybuf);
-               mysql_row = mysql_fetch_row(tresult);
+                       tresult   = db_query(&mysql, LOCAL, querybuf);
+                       mysql_row = mysql_fetch_row(tresult);
 
-               total_items = atoi(mysql_row[0]);
-               db_free_result(tresult);
+                       total_items = atoi(mysql_row[0]);
+                       db_free_result(tresult);
 
-               if (total_items && total_items < device_threads) {
-                       device_threads = total_items;
+                       if (total_items && total_items < device_threads) {
+                               device_threads = total_items;
+                       }
+               } else {
+                       device_threads = 1;
                }
 
                change_host = (current_thread >= device_threads) ? TRUE : FALSE;
@@ -757,7 +799,13 @@
                                host_time_double = get_time_as_double();
                        }
                } else {
-                       items_per_thread = 0;
+                       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);
+                       tresult   = db_query(&mysql, LOCAL, querybuf);
+                       mysql_row = mysql_fetch_row(tresult);
+
+                       items_per_thread = atoi(mysql_row[0]);
+
+                       db_free_result(tresult);
 
                        sprintf(host_time, "%lu", (unsigned long) time(NULL));
                        host_time_double = get_time_as_double();
@@ -883,14 +931,14 @@
                        thread_status = 
pthread_create(&threads[device_counter], &attr, child, poller_details);
 
                        if (thread_status == 0) {
-                               SPINE_LOG_DEBUG(("DEBUG: Valid Thread to be 
Created (%ld)", threads[device_counter]));
+                               SPINE_LOG_DEBUG(("DEBUG: Device[%i] Valid 
Thread to be Created (%ld)", poller_details->host_id, (unsigned long 
int)threads[device_counter]));
 
                                if (change_host) {
                                        device_counter++;
                                }
 
                                sem_getvalue(&available_threads, 
&a_threads_value);
-                               SPINE_LOG_MEDIUM(("DEBUG: Available Threads is 
%i (%i outstanding)", a_threads_value, set.threads - a_threads_value));
+                               SPINE_LOG_HIGH(("DEBUG: Device[%i] Available 
Threads is %i (%i outstanding)", poller_details->host_id, a_threads_value, 
set.threads - a_threads_value));
 
                                sem_post(&thread_init_sem);
 
@@ -925,11 +973,11 @@
                cur_time = get_time_as_double();
 
                if (cur_time - begin_time > set.poller_interval) {
-                       SPINE_LOG(("ERROR: Device[%i] polling timed out while 
waiting for %d Threads to End", host_id, set.threads - a_threads_value));
+                       SPINE_LOG(("ERROR: Polling timed out while waiting for 
%d Threads to End", set.threads - a_threads_value));
                        break;
                }
 
-               SPINE_LOG_HIGH(("WARNING: Device[%i] polling sleeping while 
waiting for %d Threads to End", host_id, set.threads - a_threads_value));
+               SPINE_LOG_HIGH(("NOTE: Polling sleeping while waiting for %d 
Threads to End", set.threads - a_threads_value));
                usleep(500000);
                sem_getvalue(&available_threads, &a_threads_value);
        }
@@ -938,30 +986,32 @@
 
        SPINE_LOG_HIGH(("The final count of Threads is %i", threads_final));
 
-       for (threads_count = 0; threads_count < num_rows; threads_count++) {
+       if (!set.ping_only) {
                thread_mutex_lock(LOCK_THDET);
 
-               poller_thread_t* det = details[threads_count];
+               for (threads_count = 0; threads_count < num_rows; 
threads_count++) {
+                       poller_thread_t* det = details[threads_count];
 
-               if (threads_missing == -1 && det == NULL) {
-                       threads_missing = threads_count;
-               }
+                       if (threads_missing == -1 && det == NULL) {
+                               threads_missing = threads_count;
+                       }
+
+                       if (det != NULL) { // && !det->complete) {
+                               SPINE_LOG_HIGH(("INFO: Device[%i] Thread 
%scomplete and %d to %d sources",
+                                       det->host_id,
+                                       det->complete ? "":"in",
+                                       det->host_data_ids * (det->host_thread 
- 1),
+                                       det->host_data_ids * 
(det->host_thread)));
 
-               if (det != NULL) { // && !det->complete) {
-                       SPINE_LOG_HIGH(("INFO: Thread %scomplete for Device[%d] 
and %d to %d sources",
-                               det->complete ? "":"in",
-                               det->host_id,
-                               det->host_data_ids * (det->host_thread - 1),
-                               det->host_data_ids * (det->host_thread)));
-
-                       SPINE_LOG_DEVDBG(("DEBUG: DTF: device = %d, host_id = 
%d, host_thread = %d,"
-                               " host_threads = %d, host_data_ids = %d, 
complete = %d",
-                               threads_count,
-                               det->host_id,
-                               det->host_thread,
-                               det->host_threads,
-                               det->host_data_ids,
-                               det->complete));
+                               SPINE_LOG_DEVDBG(("DEBUG: DTF: device = %d, 
host_id = %d, host_thread = %d,"
+                                       " host_threads = %d, host_data_ids = 
%d, complete = %d",
+                                       threads_count,
+                                       det->host_id,
+                                       det->host_thread,
+                                       det->host_threads,
+                                       det->host_data_ids,
+                                       det->complete));
+                       }
                }
 
                thread_mutex_unlock(LOCK_THDET);
@@ -980,15 +1030,17 @@
        }
 
        /* update the db for |data_time| on graphs */
-       if (set.poller_id == 1) {
-               db_insert(&mysql, LOCAL, "REPLACE INTO settings (name,value) 
VALUES ('date',NOW())");
-       }
+       if (!set.ping_only) {
+               if (set.poller_id == 1) {
+                       db_insert(&mysql, LOCAL, "REPLACE INTO settings 
(name,value) VALUES ('date',NOW())");
+               }
 
-       snprintf(querybuf, BIG_BUFSIZE, "UPDATE poller_time SET end_time=NOW() 
WHERE poller_id=%i AND pid=%i", set.poller_id, getpid());
-       if (mode == REMOTE) {
-               db_insert(&mysqlr, REMOTE, querybuf);
-       } else {
-               db_insert(&mysql, LOCAL, querybuf);
+               snprintf(querybuf, BIG_BUFSIZE, "UPDATE poller_time SET 
end_time=NOW() WHERE poller_id=%i AND pid=%i", set.poller_id, getpid());
+               if (mode == REMOTE) {
+                       db_insert(&mysqlr, REMOTE, querybuf);
+               } else {
+                       db_insert(&mysql, LOCAL, querybuf);
+               }
        }
 
        if (db_pool_local) {
@@ -1005,7 +1057,7 @@
        SPINE_LOG_DEBUG(("DEBUG: Thread Cleanup Complete"));
 
        /* close the php script server */
-       if (set.php_required) {
+       if (set.php_required && !set.ping_only) {
                php_close(PHP_INIT);
        }
 
@@ -1050,7 +1102,7 @@
        } else {
                /* provide output if running from command line */
                if (!set.stdout_notty) {
-                       fprintf(stdout,"Time: %.4f s, Threads: %i, Devices: 
%i\n", (end_time - begin_time), set.threads, num_rows);
+                       fprintf(stdout, "Time: %.4f s, Threads: %i, Devices: 
%i\n", (end_time - begin_time), set.threads, num_rows);
                }
        }
 
@@ -1082,6 +1134,7 @@
                "  -l/--last=X        End polling with host id X",
                "  -H/--hostlist=X    Poll the list of host ids, separated by 
comma's",
                "  -p/--poller=X      Set the poller id to X",
+               "  -t/--threads=X     Override the database threads setting.",
                "  -C/--conf=F        Read spine configuration from file F",
                "  -O/--option=S:V    Override DB settings 'set' with value 
'V'",
                "  -M/--mibs          Refresh the device System Mib data",
@@ -1090,6 +1143,7 @@
                "                     The default is 'online'.",
                "  -R/--readonly      Spine will not write output to the DB",
                "  -S/--stdout        Logging is performed to standard output",
+               "  -P/--pingonly      Ping device and update device status 
only",
                "  -V/--verbosity=V   Set logging verbosity to <V>",
                "",
                "Either both of --first/--last must be provided, a valid 
hostlist must be provided.",
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/spine.h 
new/cacti-spine-1.2.26/spine.h
--- old/cacti-spine-1.2.25/spine.h      2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/spine.h      2023-12-24 03:18:40.000000000 +0100
@@ -352,6 +352,7 @@
        int    active_profiles;
        int    total_snmp_ports;
        int    threads;
+       int    threads_set;
        int    logfile_processed;
        int    boost_enabled;
        int    boost_redirect;
@@ -363,6 +364,7 @@
        int    start_host_id;
        int    end_host_id;
        char   host_id_list[BIG_BUFSIZE];
+       int    has_device_0;
        /* database connection information */
        char   db_host[SMALL_BUFSIZE];
        char   db_db[SMALL_BUFSIZE];
@@ -399,6 +401,7 @@
        int    ping_timeout;
        int    ping_failure_count;
        int    ping_recovery_count;
+       int    ping_only;
        /* snmp options */
        int    snmp_max_get_size;
        int    snmp_retries;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/sql.c new/cacti-spine-1.2.26/sql.c
--- old/cacti-spine-1.2.25/sql.c        2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/sql.c        2023-12-24 03:18:40.000000000 +0100
@@ -277,7 +277,10 @@
        MYSQL_SET_OPTION(MYSQL_OPT_READ_TIMEOUT, (int *)&rtimeout, "read 
timeout");
        MYSQL_SET_OPTION(MYSQL_OPT_WRITE_TIMEOUT, (int *)&wtimeout, "write 
timeout");
        MYSQL_SET_OPTION(MYSQL_OPT_CONNECT_TIMEOUT, (int *)&timeout, "general 
timeout");
-       MYSQL_SET_OPTION(MYSQL_OPT_RECONNECT, &reconnect, "reconnect");
+
+       #if defined(MARIADB_BASE_VERSION) || (MYSQL_VERSION_ID < 80034 && 
MYSQL_VERSION_ID >= 50013)
+               MYSQL_SET_OPTION(MYSQL_OPT_RECONNECT, &reconnect, "reconnect");
+       #endif
 
        #ifdef HAS_MYSQL_OPT_RETRY_COUNT
        MYSQL_SET_OPTION(MYSQL_OPT_RETRY_COUNT, &tries, "retry count");
@@ -401,15 +404,13 @@
 
                        db_connect(type, &db_pool_local[id].mysql);
 
-                       if (&db_pool_local[id].mysql != NULL) {
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_IN_DATE', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_AUTO_VALUE_ON_ZERO', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'TRADITIONAL', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_ALL_TABLES', ''))");
-                               db_insert(&db_pool_local[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES', ''))");
-                       }
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_IN_DATE', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'NO_AUTO_VALUE_ON_ZERO', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'TRADITIONAL', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_ALL_TABLES', ''))");
+                       db_insert(&db_pool_local[id].mysql, LOCAL, "SET SESSION 
sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES', ''))");
 
                        db_pool_local[id].free = TRUE;
                        db_pool_local[id].id   = id;
@@ -422,15 +423,13 @@
 
                        db_connect(type, &db_pool_remote[id].mysql);
 
-                       if (&db_pool_remote[id].mysql != NULL) {
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE', ''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_IN_DATE', ''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', ''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_AUTO_VALUE_ON_ZERO', 
''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'TRADITIONAL', ''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_ALL_TABLES', ''))");
-                               db_insert(&db_pool_remote[id].mysql, LOCAL, 
"SET SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES', 
''))");
-                       }
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_DATE', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_ZERO_IN_DATE', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'NO_AUTO_VALUE_ON_ZERO', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'TRADITIONAL', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_ALL_TABLES', ''))");
+                       db_insert(&db_pool_remote[id].mysql, LOCAL, "SET 
SESSION sql_mode = (SELECT REPLACE(@@sql_mode,'STRICT_TRANS_TABLES', ''))");
 
                        db_pool_remote[id].free = TRUE;
                        db_pool_remote[id].id   = id;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cacti-spine-1.2.25/util.c 
new/cacti-spine-1.2.26/util.c
--- old/cacti-spine-1.2.25/util.c       2023-09-05 01:57:16.000000000 +0200
+++ new/cacti-spine-1.2.26/util.c       2023-12-24 03:18:40.000000000 +0100
@@ -372,7 +372,7 @@
        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));
+       SPINE_LOG_DEBUG(("DEBUG: The binary Cacti version is %d", 
set.cacti_version));
 
        /* get logging level from database - overrides spine.conf */
        if ((res = getsetting(&mysql, LOCAL, "log_verbosity")) != 0) {
@@ -555,11 +555,13 @@
        SPINE_LOG_DEBUG(("DEBUG: The log_pstats variable is %i", 
set.log_pstats));
 
        /* get Cacti defined max threads override spine.conf */
-       if ((res = getpsetting(&mysql, mode, "threads")) != 0) {
-               set.threads = atoi(res);
-               free((char *)res);
-               if (set.threads > MAX_THREADS) {
-                       set.threads = MAX_THREADS;
+       if (set.threads_set == FALSE) {
+               if ((res = getpsetting(&mysql, mode, "threads")) != 0) {
+                       set.threads = atoi(res);
+                       free((char *)res);
+                       if (set.threads > MAX_THREADS) {
+                               set.threads = MAX_THREADS;
+                       }
                }
        }
 
@@ -1260,7 +1262,8 @@
        fp = stdout;
 
        /* log message prefix */
-       snprintf(logprefix, SMALL_BUFSIZE, "SPINE: Poller[%i] PID[%i] PT[%ld] 
", set.poller_id, getpid(), pthread_self());
+
+       snprintf(logprefix, SMALL_BUFSIZE, "SPINE: Poller[%i] PID[%i] PT[%ld] 
", set.poller_id, getpid(), (unsigned long int)pthread_self());
 
        /* get time for poller_output table */
        nowbin = time(&nowbin);

Reply via email to