plugin_thold icon indicating copy to clipboard operation
plugin_thold copied to clipboard

Navigator will not be updated when content changes

Open skyjou opened this issue 1 year ago • 3 comments

Describe the bug Navigator will not be updated when content changes.

To Reproduce Steps to reproduce the behavior:

  1. Go to 'Thold'
  2. Click on 'Device Status'
  3. See error

Expected behavior Navigator will be updated when content changes.

Plugin:

  • Version: 1.8.1
  • Source: GitHub

Desktop:

  • OS: Ubuntu 24.04
  • Browser: Chrome, Firefox

Additional context It seems that the get_total_row_data() function causes the navigator to cache outdated information for 86400 seconds.

skyjou avatar Oct 17 '24 04:10 skyjou

Cannot reproduce this. Try to update to 1.8.2, it was released yesterday

xmacan avatar Oct 17 '24 06:10 xmacan

I just upgraded to the new version. The issue still exist:

Screenshot from 2024-10-17 14-59-31

There are 8 not-up devices, but the navbar shows 7 only.

skyjou avatar Oct 17 '24 07:10 skyjou

If I change line 8072 in thold_functions.php from: $total_rows = get_total_row_data($user_id, $sql, array(), 'thold_device');

to: $total_rows = get_total_row_data($user_id, $sql, array(), 'thold_device', 10);

or: $total_rows = db_fetch_cell($sql);

Narbar can update correctly, but this is not a good solution. The narbar total_rows should be cached only before the next poller run, or just not cache it.

skyjou avatar Oct 17 '24 08:10 skyjou

@skyjou, can you go to the plugins directory and do the following. Return what you find:

grep -r get_total_row_data *

I'm looking for see what plugin is redefining that function. We need to know what plugin is defining that function. It was likely written years ago for some customization that is no longer valid.

TheWitness avatar Jun 08 '25 13:06 TheWitness

This is what I get:

[root@vmhost5 plugins]# grep -r get_total_row_data *
thold/thold_functions.php:      if (function_exists('get_total_row_data') && $graph_id == 0) {
thold/thold_functions.php:              $total_rows = get_total_row_data($user_id, $sql, array(), 'thold');
thold/thold_functions.php:      if (function_exists('get_total_row_data') && $graph_id == 0) {
thold/thold_functions.php:              $total_rows = get_total_row_data($user_id, $sql, array(), 'thold_log');
thold/thold_functions.php:      if (function_exists('get_total_row_data') && $device_id == 0) {
thold/thold_functions.php:              $total_rows = get_total_row_data($user_id, $sql, array(), 'thold_device');

You see that function is not in the thold plugin.

TheWitness avatar Jun 08 '25 13:06 TheWitness

$ grep -r get_total_row_data *
thold/thold_functions.php:	if (function_exists('get_total_row_data') && $graph_id == 0) {
thold/thold_functions.php:		$total_rows = get_total_row_data($user_id, $sql, array(), 'thold');
thold/thold_functions.php:	if (function_exists('get_total_row_data') && $graph_id == 0) {
thold/thold_functions.php:		$total_rows = get_total_row_data($user_id, $sql, array(), 'thold_log');
thold/thold_functions.php:	if (function_exists('get_total_row_data') && $device_id == 0) {
thold/thold_functions.php:        /* $total_rows = get_total_row_data($user_id, $sql, array(), 'thold_device'); */

The only plugin I installed is thold:

$ ls -l
total 8
-rw-rw-r-- 1 www-data www-data 1586 Oct  7  2024 index.php
drwxrwxr-x 9 www-data www-data 4096 Oct 17  2024 thold

It seems that the function get_total_row_data is defined in lib/auth.php.

skyjou avatar Jun 09 '25 00:06 skyjou

So, you must be using Cacti 1.3? I forgot to check that. Thanks for the heads up.

TheWitness avatar Jun 09 '25 23:06 TheWitness

I'm still using version 1.2.28.

skyjou avatar Jun 10 '25 00:06 skyjou

Okay, yea, we need to make that like 30 seconds.

TheWitness avatar Jun 23 '25 03:06 TheWitness

Fixed now. Thanks for reporting and being patient.

TheWitness avatar Jun 23 '25 03:06 TheWitness