Cacti 1.1.38 fails to display graphs and acts erratically

Bug #1779401 reported by Rich James
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cacti (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

Cacti fails to show many graphs, and also has problems reindexing.
The error given is:
 sizeof(): Parameter must be an array or an object that implements Countable in /usr/share/cacti/site/lib/utility.php on line 541

Fix is by patch:
diff --git a/lib/utility.php b/tmp/utility.php
index 6488d98..306e6e4 100644
--- a/lib/utility.php
+++ b/tmp/utility.php
@@ -459,7 +459,7 @@ function push_out_data_input_method($data_input_id) {
  */
 function poller_update_poller_cache_from_buffer($local_data_ids, &$poller_items) {
        /* set all fields present value to 0, to mark the outliers when we are all done */
- $ids = array();
+ $ids = '';
        if (sizeof($local_data_ids)) {
                $count = 0;
                foreach($local_data_ids as $id) {
@@ -538,7 +538,7 @@ function poller_update_poller_cache_from_buffer($local_data_ids, &$poller_items)
        }

        /* remove stale records FROM the poller cache */
- if (sizeof($ids)) {
+ if (strlen($ids)) {
                db_execute("DELETE FROM poller_item WHERE present=0 AND local_data_id IN ($ids)");
        } else {
                /* only handle explicitely given local_data_ids */

Paul White (paulw2u)
affects: ubuntu → cacti (Ubuntu)
Revision history for this message
Paul Gevers (paul-climbing) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cacti (Ubuntu):
status: New → Confirmed
Revision history for this message
Simon Déziel (sdeziel) wrote :

I can confirm the problem and the workaround. For those interested here's the how to fix the code in place:

cd /usr/share/cacti/site/lib
sed -i.orig "/if (sizeof(\$ids)) {/ s/sizeof/strlen/; /\$ids = array();/ s/array()/''/" utility.php

Revision history for this message
simone-c (simone-c) wrote :

Yep, 18.04 is still affected by this
The correct link to a guthub issue is:
https://github.com/Cacti/cacti/issues/1546#issuecomment-382320908

Revision history for this message
Brian Candler (b-candler) wrote :

SNMP data collection is also broken in the Ubuntu 18.04 cacti package

https://github.com/Cacti/cacti/issues/1634
https://github.com/Cacti/cacti/commit/32f1538a4a382b7b27e2340705e9b034f335ae6e
https://github.com/Cacti/cacti/commit/afa01553f574554f782bbed3d2f1efaa355df2d0
https://github.com/Cacti/cacti/commit/9311987e8a22e9c838bc879ff8eceae7abfbeb65

diff to /usr/share/cacti/site:

--- a/lib/snmp.php
+++ b/lib/snmp.php
@@ -74,6 +74,7 @@ function cacti_snmp_session($hostname, $community, $version, $auth_user, $auth_p
                $session->valueretrieval = SNMP_VALUE_LIBRARY;
        }

+ $session->quick_print = false;
        $session->max_oids = $max_oids;

        if (read_config_option('oid_increasing_check_disable') == 'on') {
--- a/cmd.php 2020-06-13 08:45:09.660470210 +0000
+++ b/cmd.php 2020-06-13 08:59:50.586094241 +0000
@@ -504,8 +504,7 @@

                                                        if (isset($sessions[$host_id . '_' . $item['snmp_version'] . '_' . $item['snmp_port']])) {
- $sessions[$host_id . '_' . $item['snmp_version'] . '_' . $item['snmp_port']]->quick_print = true;
- $output = cacti_snmp_session_get($sessions[$host_id . '_' . $item['snmp_version'] . '_' . $item['snmp_port']], $index_item['arg1'], true);
+ $output = cacti_snmp_session_get($sessions[$host_id . '_' . $item['snmp_version'] . '_' . $item['snmp_port']], $index_item['arg1']);
                                                        } else {
                                                                $output = 'U';
                                                        }

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.