Cactiusers.org


It is currently Mon May 21, 2012 5:23 pm




Post new topic Reply to topic  [ 4 posts ] 
 Graph Cache plug-in 
Author Message
New User

Joined: Mon Feb 19, 2007 9:59 am
Posts: 4
Post Graph Cache plug-in
We run Cacti in a VM at work, and I got tired of waiting for it to render all of the graphs for the preview page (we have several hundred graphs, and right now load 60+ on one page). Thus the itch that needed scratching to produce a plug-in to act as a server-side cache.

I've whacked a copy up at http://www.cricalix.net/~dhill/cacti/gr ... 0.1.tar.gz - you have to hack lib/rrd.php to use it unfortunately:

Around line 1168, where the rrdtool_execute call is made with $output_flag, duplicate the call. Change that flag to RRDTOOL_OUTPUT_STDOUT:
Code:
$savefile = rrdtool_execute("graph $graph_opts$graph_defs$txt_graph_items", false, RRDTOOL_OUTPUT_STDOUT, $rrd_struc);

Then change the hook call to reference savefile instead:
Code:
do_hook_function("rrdtool_function_graph_set_file", array('output' => $savefile, ...

Add it in like any other plug-in to config.php and you'll get an on-disk (which could point to a ramdrive) cache for each graph which gets picked up by the rrdtool_function_graph_cache_check hook.

This code is not written for Win32, as the on-disk location is /tmp. Nothing stops you hacking that though :) Cache is set for 280 seconds, and self-cleans when the requested file is older than that (and hands off to the main routine for generation).


Mon Feb 26, 2007 5:13 am
New User

Joined: Mon Feb 19, 2007 9:59 am
Posts: 4
Post 
Note, this cache code seems to break the thold plug-in when it attempts to attach the graph to the e-mail alert. I suspect it's because the read_file routine doesn't know if it was meant to return the graph or the graph size (which the actual graphing routine does based on the output flag).


Mon Feb 26, 2007 5:32 am
New User

Joined: Mon Feb 19, 2007 9:59 am
Posts: 4
Post 
Fixed the thold problem by honouring the output_flag. Bit more cross-platform by using some php definitions for directory separators etc.


Mon Feb 26, 2007 11:21 am
Site Admin

Joined: Thu Nov 11, 2004 11:12 am
Posts: 2007
Post 
Actually, I wrote a plugin to do this about 6 months ago, but instead it has been rolled into the Boost Plugin (which you can download on the cacti.net forums)


Mon Feb 26, 2007 6:41 pm
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: