Links to Graphs - Relative Timeframes

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
jeffhochberg
Posts: 14
Joined: Mon Jul 01, 2013 8:35 pm

Links to Graphs - Relative Timeframes

Post by jeffhochberg »

Hello,

I would like to embed links to several of my Cacti graphs on an external web server such that, any time someone browses to the website, the graphs displayed show the:

  • Past 24 Hours
  • Past 7 Days
I used the option to 'Copy Graph Link' then added some HTML with <img src> and the corresponding URL. What I found is that, due to the graph_start and graph_end attributes embedded in the link, the graphs are snapshots from the point at which I copied the URL from within the Cacti admin console.

Code: Select all

<img src="https://mycactiserver.mydomain.com/cacti/graph_image.php?local_graph_id=168&graph_start=1596262380&graph_end=1596348780&graph_width=750&graph_height=240">
Is there a way I can accomplish this by specifying relative start/end times?

Thank you,

-JeffH
jeffhochberg
Posts: 14
Joined: Mon Jul 01, 2013 8:35 pm

Re: Links to Graphs - Relative Timeframes

Post by jeffhochberg »

Hang tight - this isn't working as well as expected! The URL for 24 hours seems to be working OK but the URL for the past 7 days is not. I'm still trying to figure this out. I'll update this post again once I figure it out. If anyone has any ideas in the meantime, I would really appreciate a hand with this!

Instead of reviewing the Cacti documentation, I looked at the documentation for RRDTool:

https://oss.oetiker.ch/rrdtool/doc/rrdgraph.en.html
Time range

[-s|--start time] [-e|--end time] [-S|--step seconds]

The start and end of the time series you would like to display, and which RRA the data should come from. Defaults are: 1 day ago until now, with the best possible resolution. Start and end can be specified in several formats, see "AT-STYLE TIME SPECIFICATION" in rrdfetch and rrdgraph_examples. By default, rrdtool graph calculates the width of one pixel in the time domain and tries to get data from an RRA with that resolution. With the step option you can alter this behavior. If you want rrdtool graph to get data at a one-hour resolution from the RRD, set step to 3'600. Note: a step smaller than one pixel will silently be ignored.

For non-image --imgformats see "OUTPUT FORMAT" in rrdxport for details on how this affects the output.
I used the following:

For past 24 hours:

Code: Select all

--end now --start end-86400s
For past 7 days:

Code: Select all

--end now --start end-604800s


If you take the example I provided in my original post:

Code: Select all

<img src="https://mycactiserver.mydomain.com/cacti/graph_image.php?local_graph_id=209&graph_start=1596346200&graph_end=1596432564&graph_width=750&graph_height=240">
Then remove graph_start and graph_end and replace them with end and start (this example is for the past 24 hours = 86400 seconds):

Code: Select all

<img src="https://mycactiserver.mydomain.com/cacti/graph_image.php?local_graph_id=168&end=now&start=end-86400s&graph_width=750&graph_height=240">
That worked perfectly!!!
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Links to Graphs - Relative Timeframes

Post by netniV »

I was also going to suggest this as I have been playing with manual graph creation of RRDTool. The only other part is that unless you have guest access or some form of automatic auth then the images may not show for unauthed users.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
jeffhochberg
Posts: 14
Joined: Mon Jul 01, 2013 8:35 pm

Re: Links to Graphs - Relative Timeframes

Post by jeffhochberg »

I was also going to suggest this as I have been playing with manual graph creation of RRDTool. The only other part is that unless you have guest access or some form of automatic auth then the images may not show for unauthed users.
Yes - I do have guest auth enabled. "View Graphs" is the only option enabled. I'm proxying all traffic through Cloudflare's SSL proxy. It's not the end-all-be-all in terms of security, but it seems to be working nicely thus far.

I still haven't been able to get back to figuring out the values for start/end in the URL to display the previous 7 days. The previous 24 hours option works perfectly!
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: Links to Graphs - Relative Timeframes

Post by netniV »

It may or may not be being filtered out. The chances are, we are disallowing any value that isn't numeric on the start and end fields, thus you can't pass nice things like -10days or +2hours through to RRDTool. You could request that as a change for the future, we would consider it for 1.3 but I wouldn't want to break 1.2.x as we are not doing new features for that branch now, only bug and security fixes.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
jeffhochberg
Posts: 14
Joined: Mon Jul 01, 2013 8:35 pm

Re: Links to Graphs - Relative Timeframes

Post by jeffhochberg »

Ok no worries. I can submit an enhancement request. Would it be better to do that in the forums or via the GitHub repository?
kaf3773
Posts: 22
Joined: Sun Sep 09, 2012 8:48 pm

Re: Links to Graphs - Relative Timeframes

Post by kaf3773 »

@netniV,

I do not think this works for graphs beyond 24 hours.

I have been trying this out on Cacti 1.2.16

Regardless of the specified end and start epoch time values the graph only displays for the last 24 hours.

http://hostname/cacti/graph_image.php?l ... 1612199734

Is there something i am missing?

Appreciate help on this.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests