Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When selecting Presets "Last Day" (or Hour, Year etc.) in Graph Filters in Tree Mode the "To time" is always "2022-01-08 12:55" #6102

Open
matskv54 opened this issue Feb 18, 2025 · 10 comments
Labels
bug Undesired behaviour unverified Some days we don't have a clue

Comments

@matskv54
Copy link

Describe the bug

When selecting the "Presets" with "Last Day" (or Hour, Year etc.) in Graph Filters in Tree Mode the "To time" is always "2022-01-08 12:55".
When selecting a Custom time frame the graph is shows correct dates/times but if you go back to select "Last ___" the end time is again "2022-01-08 12:55". The end time is the same in the To-box as on the graph.

Cacti is only used to present data in rrd-files which is updated via a shell script.

I have tried to find out where the "To time" is updated (default value i guess) but I can find that the variable is named "date2" in the code but I can not figure out where the "date2" is updated to default value.

I hade this problem in version 1.2.28 and 1.2.29 but not in 1.2.27 or earlier. Cacti is running on FreeBSD 14.2-RELEASE-p1 but Cacti version 1.2.27 and 1.2.28 were running on FreeBSD 13.X. Cacti is installed via pkg and not via ports.

The time is correct on FreeBSD system: "Tue Feb 18 17:27:22 CET 2025"

When I upgraded to Cacti v1.2.29 the date shown in the Installation Wizard was 2022-01-08 22:02:53.

To Reproduce

Steps to reproduce the behavior:

  1. Open Cacti in Tree mode.

  2. The "Last Day" ends at 2022-01-08 12:55.

  3. Change to a Custom time frame the end date is what you set it to e.a. 2025-02-18

  4. When you again select Last Day the end date goes back to 2022-01-08 12:55

Expected behavior

I expect that Last day ends at current date and time

Screenshots

Installation of Cacti v1.2.29:
Image

Graph Filter selection for Last Day:
Image

PHP-Info:
Image

Server

  • OS: FreeBSD 14.2-RELEASE-p1
  • Cacti v 1.2.29
  • PHP 8.3.15

Desktop (please complete the following information)

  • OS: OpenSuse Tumbleweed

  • Browser : Brave or Firefox

Smartphone (please complete the following information)

  • Device: Not used.

Additional context

When looking in the logfile for creation of the graphs the time is --end='1641646500' which represents: GMT: Saturday, January 8, 2022 12:55:00 PM

@matskv54 matskv54 added bug Undesired behaviour unverified Some days we don't have a clue labels Feb 18, 2025
@TheWitness
Copy link
Member

Clear your browser cache.

@bmfmancini
Copy link
Member

unable to reproduce

Image

@matskv54
Copy link
Author

My feeling is that the problem is related to Cacti running on FreeBSD (that is what I use).
I have tried to find out where (in some of the *.php files) the defaut value of date2 (sess_current_date2) is read (probably with the time() command). As I understand the code correct, the default value should be the current date and time.

@xmacan
Copy link
Member

xmacan commented Feb 20, 2025

I have cacti 1.2.28 on FreeBSD 13.x and I don't have similar problem. I will try update to 1.2.29 ...

updated. Without issue 1.2.29 on FreeBSD 13.x

@xmacan
Copy link
Member

xmacan commented Feb 20, 2025

weird ... I installed from ports and in file include/global.php is hardcoded path to rra:
config['rra_path'] = '/var/db/cacti/rra';

@matskv54
Copy link
Author

Thank you for all the comments.

I am just looking in to the problem and it looks like it have to do with Polling. I don't use polling since my rrd is updated by a separate shell script.

What I have found so far:

In ../cacti/lib/timespan_settings.php line 195:
$time = read_config_option('poller_lastrun_1', true);

If I comment that line out the presentation works as expected.

I am looking in to where "poller_lastrun_1" is updated (or in my case not updated) and try to find out where the date (2022-01-08 12:55) comes from.

The above problem should not explane the date (2022-01-08 22:02:53) that is that is shown in my installation.

@matskv54
Copy link
Author

I have found a difference in 1.2.27 and 1.2.28 (and 1.2.29)

I have not found out where the date 2022-01-08 comes from but:

There are changes made from version 1.2.27 to 1.2.28 and 1.2.29 that create the problem I have.

In version 1.2.27 of timespan_settings.php:

/* establish graph timespan from either a user select or the default */
function set_preset_timespan(&$timespan) {
	/* no current timespan: get default timespan */
	if (!isset($_SESSION['sess_current_timespan'])) {
		$_SESSION['sess_current_timespan'] = read_user_setting('default_timespan');
	}

	/* get config option for first-day-of-the-week */
	$first_weekdayid = read_user_setting('first_weekdayid');

	/* get start/end time-since-epoch for actual time (now()) and given current-session-timespan */
	get_timespan($timespan, time(), $_SESSION['sess_current_timespan'], $first_weekdayid);

	$_SESSION['custom'] = 0;
}

In version 1.2.28 of timespan_settings.php:

/* establish graph timespan from either a user select or the default */
function set_preset_timespan(&$timespan) {
	/* no current timespan: get default timespan */
	if (!isset($_SESSION['sess_current_timespan'])) {
		$_SESSION['sess_current_timespan'] = read_user_setting('default_timespan');
	}

	if (preg_match('/graph/i', get_current_page())) {
		$graph = true;
	} else {
		$graph = false;
	}

	/* get config option for first-day-of-the-week */
	$first_weekdayid = read_user_setting('first_weekdayid');

	/* operate like graphs if graphs is set */
	if ($graph) {
		$time = read_config_option('poller_lastrun_1');

		if (empty($time)) {
			$time = time();
		}
	} else {
		$time = time();
	}

	/* get start/end time-since-epoch for actual time (now()) and given current-session-timespan */
	get_timespan($timespan, $time, $_SESSION['sess_current_timespan'], $first_weekdayid);

	$_SESSION['custom'] = 0;
}

In version 1.2.29 of timespan_settings.php:

/* establish graph timespan from either a user select or the default */
function set_preset_timespan(&$timespan) {
	/* no current timespan: get default timespan */
	if (!isset($_SESSION['sess_current_timespan'])) {
		$_SESSION['sess_current_timespan'] = read_user_setting('default_timespan');
	}

	if (preg_match('/graph/i', get_current_page())) {
		$graph = true;
	} else {
		$graph = false;
	}

	/* get config option for first-day-of-the-week */
	$first_weekdayid = read_user_setting('first_weekdayid');

	/* operate like graphs if graphs is set */
	if ($graph) {
		$time = read_config_option('poller_lastrun_1', true);

		if (empty($time)) {
			$time = time();
		}
	} else {
		$time = time();
	}

	/* get start/end time-since-epoch for actual time (now()) and given current-session-timespan */
	get_timespan($timespan, $time, $_SESSION['sess_current_timespan'], $first_weekdayid);

	$_SESSION['custom'] = 0;
}

As can be seen there are some code that was added to version 1.2.28 (and some further small change to 1.2.29) that was not present in 1.2.27.

I don't know how to solve this problen in general more than comment out the line I mentioned in my previous comment in my local version.

Turning on and of polling

I tried to turn on and then turn of polling to see if something changed but I could not see any difference.

Image

@TheWitness
Copy link
Member

Thank you for all the comments.

I am just looking in to the problem and it looks like it have to do with Polling. I don't use polling since my rrd is updated by a separate shell script.

What I have found so far:

In ../cacti/lib/timespan_settings.php line 195: $time = read_config_option('poller_lastrun_1', true);

If I comment that line out the presentation works as expected.

I am looking in to where "poller_lastrun_1" is updated (or in my case not updated) and try to find out where the date (2022-01-08 12:55) comes from.

The above problem should not explane the date (2022-01-08 22:02:53) that is that is shown in my installation.

This may have something to do with the problem. We attempt to calculate the proper display time to align with the last time the device was polled through the Cacti Data Collector. Are all your Data Sources listed as 'External'?

@matskv54
Copy link
Author

Thank you very much for your comment.

I am not suprized that there are something strange with my Data Sources.
I can not find out where to see if the Data Sources are listed as 'External' or how to mark it as 'External'.
Advise is needed!

@TheWitness
Copy link
Member

Post a screen shot of your Console > Management > Data Sources page. It should look similar to the following with the Poller Interval being 'External'. I did not QA this. So, it may say something else. Please advise.

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Undesired behaviour unverified Some days we don't have a clue
Projects
None yet
Development

No branches or pull requests

4 participants