From c5f7f9ac5f8776dd56b239aa62ee9d5512ba151d Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Sun, 4 Jul 2010 21:09:22 +0000 Subject: [PATCH] rrdcached support (yarly!) git-svn-id: http://www.observium.org/svn/observer/trunk@1291 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 4 ++++ html/graph.php | 7 +++++-- includes/rrdtool.inc.php | 11 +++++++++-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config.php.default b/config.php.default index 1be3e3c67..f079f6761 100755 --- a/config.php.default +++ b/config.php.default @@ -15,6 +15,10 @@ $config['rrd_dir'] = "/opt/observer/rrd"; $config['temp_dir'] = "/tmp"; $config['observer_log'] = $config['install_dir'] . "/observer.log"; +### Enable the below to use rrdcached. be sure rrd_dir is within the rrdcached dir +### and that your web server has permission to talk to rrdcached. +#$config['rrdcached'] = "unix:/var/run/rrdcached.sock"; + ### Default community $config['community'] = "public"; diff --git a/html/graph.php b/html/graph.php index 340b4626b..d2e15ea0d 100644 --- a/html/graph.php +++ b/html/graph.php @@ -56,8 +56,11 @@ if($_GET['debug']) { } if($rrd_options) { - if($_GET['debug']) { echo("
".$config['rrdtool'] . " graph $graphfile $rrd_options\n\n"); }
-    $thing = shell_exec($config['rrdtool'] . " graph $graphfile $rrd_options");    
+    
+    if($config['rrdcached']) { $rrd_switches = " --daemon ".$config['rrdcached'] . " "; }
+    $rrd_cmd = $config['rrdtool'] . " graph $graphfile $rrd_options" . $rrd_switches;
+    $woo = shell_exec($rrd_cmd);
+    if($_GET['debug']) { echo("
".$rrd_cmd."
"); } # $thing = popen($config['rrdtool'] . " -",'w'); # fputs($thing, "graph $graphfile $rrd_options"); # pclose($thing); diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php index 3c201a941..d0888841d 100644 --- a/includes/rrdtool.inc.php +++ b/includes/rrdtool.inc.php @@ -33,8 +33,15 @@ function rrdtool_lastupdate($rrdfile, $rrdupdate) function rrdtool($command, $file, $options) { global $config; global $debug; - if ($debug) { echo($config['rrdtool'] . " $command $file $options \n"); } - return shell_exec($config['rrdtool'] . " $command $file $options"); + + $command = $config['rrdtool'] . " $command $file $options"; + if($config['rrdcached']) + { + $command .= " --daemon " . $config['rrdcached']; + } + + if ($debug) { echo($command."\n"); } + return shell_exec($command); } ?>