more improvments to collectd

git-svn-id: http://www.observium.org/svn/observer/trunk@1603 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2010-08-01 16:30:43 +00:00
parent c8513a22ba
commit 7a0db16f2c
4 changed files with 26 additions and 20 deletions
+8 -2
View File
@@ -209,6 +209,14 @@ if (isset($MetaGraphDefs[$type])) {
$rrd_cmd = collectd_draw_rrd($host, $plugin, $pinst, $type, $tinst);
}
if(isset($rrd_cmd))
{
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
if($_GET['from']) { $from = mres($_GET['from']); }
if($_GET['to']) { $to = mres($_GET['to']); }
$rrd_cmd .= " -s " . $from . " -e " . $to;
}
if (isset($_GET['debug'])) {
header('Content-Type: text/plain; charset=utf-8');
printf("Would have executed:\n%s\n", $rrd_cmd);
@@ -217,9 +225,7 @@ if (isset($_GET['debug'])) {
header('Content-Type: image/png');
header('Cache-Control: max-age=60');
$rt = 0;
if($config['rrdcached']) { $rrd_cmd .= " --daemon ".$config['rrdcached'] . " "; }
passthru($rrd_cmd, $rt);
# echo("$rrd_cmd");
if ($rt != 0)
return error500($graph_identifier, "RRD failed to generate the graph: ".$rt);
return $rt;
+9 -9
View File
@@ -550,8 +550,8 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null,
$graph[] = sprintf('GPRINT:%s_avg:LAST:%%5.1lf%%s\\l', $k);
}
#$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds'], '-t', $rrdfile);
$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds']);
#$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrdfile);
$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']);
if($config['rrd_width'] <= "300") {
$small_opts = array ('--font', "LEGEND:7:mono", '--font', "AXIS:6:mono", "--font-render-mode", "normal");
$rrd_cmd = array_merge($rrd_cmd, $small_opts);
@@ -579,7 +579,7 @@ function collectd_draw_rrd($host, $plugin, $pinst = null, $type, $tinst = null,
*/
function collectd_draw_generic($timespan, $host, $plugin, $pinst = null, $type, $tinst = null) {
global $config, $GraphDefs;
$timespan_def = null;
$timespan_def = NULL;
foreach ($config['timespan'] as &$ts)
if ($ts['name'] == $timespan)
$timespan_def = $ts;
@@ -590,8 +590,8 @@ function collectd_draw_generic($timespan, $host, $plugin, $pinst = null, $type,
return false;
$rrd_file = sprintf('%s/%s%s%s/%s%s%s', $host, $plugin, is_null($pinst) ? '' : '-', $pinst, $type, is_null($tinst) ? '' : '-', $tinst);
#$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds'], '-t', $rrd_file);
$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds']);
#$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $rrd_file);
$rrd_cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']);
if($config['rrd_width'] <= "300") {
$small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal');
@@ -643,10 +643,10 @@ function collectd_draw_meta_stack(&$opts, &$sources) {
if (isset($opts['logarithmic']) && $opts['logarithmic'])
array_unshift($opts['rrd_opts'], '-o');
# $cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds'],
# $cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'],
# '-t', $opts['title']);
$cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds']);
$cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']);
if($config['rrd_width'] <= "300") {
$small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal');
@@ -741,10 +741,10 @@ function collectd_draw_meta_line(&$opts, &$sources) {
if (isset($opts['logarithmic']) && $opts['logarithmic'])
array_unshift($opts['rrd_opts'], '-o');
# $cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds'], '-t', $opts['title']);
# $cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-t', $opts['title']);
# $cmd = array_merge($cmd, $config['rrd_opts_array'], $opts['rrd_opts']);
$cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height'], '-s', -1*$timespan_def['seconds']);
$cmd = array(RRDTOOL, 'graph', '-', '-a', 'PNG', '-w', $config['rrd_width'], '-h', $config['rrd_height']);
if($config['rrd_width'] <= "300") {
$small_opts = array ('--font', 'LEGEND:7:mono', '--font', 'AXIS:6:mono', '--font-render-mode', 'normal');
+1 -1
View File
@@ -12,7 +12,7 @@ if(!$scale_min && !$scale_max) { $rrd_options .= " --alt-autoscale-max"; }
if(isset($scale_min)) { $rrd_options .= " -l $scale_min"; }
if(isset($scale_max)) { $rrd_options .= " -u $scale_max"; }
$rrd_options .= " -E --start ".$from." --end " . ($to - 150) . " --width ".$width." --height ".$height." ";
$rrd_options .= " -E --start ".$from." --end " . $to . " --width ".$width." --height ".$height." ";
$rrd_options .= $config['rrdgraph_def_text'];
if($_GET['bg']) { $rrd_options .= " -c CANVAS#" . mres($_GET['bg']) . " "; }
+8 -8
View File
@@ -88,24 +88,24 @@ print_optionbar_end();
}
echo("</div>");
$daily_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=day&to=$now&width=215&height=100";
$daily_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$day&to=$now&width=215&height=100";
$daily_traffic .= $args;
$daily_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=day&to=$now&width=400&height=150";
$daily_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$day&to=$now&width=400&height=150";
$daily_url .= $args;
$weekly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=week&to=$now&width=215&height=100";
$weekly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$week&to=$now&width=215&height=100";
$weekly_traffic .= $args;
$weekly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=week&to=$now&width=400&height=150";
$weekly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$week&to=$now&width=400&height=150";
$weekly_url .= $args;
$monthly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=month&to=$now&width=215&height=100";
$monthly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$month&to=$now&width=215&height=100";
$monthly_traffic .= $args;
$monthly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=month&to=$now&width=400&height=150";
$monthly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$month&to=$now&width=400&height=150";
$monthly_url .= $args;
$yearly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=year&to=$now&width=215&height=100";
$yearly_traffic = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$year&to=$now&width=215&height=100";
$yearly_traffic .= $args;
$yearly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&timespan=year&to=$now&width=400&height=150";
$yearly_url = $config['base_url'] . "/collectd-graph.php?host=" . $device['hostname'] . "&plugin=".$_GET['opta']."&type=".$_GET['opta']."&plugin_instance=".$instance."&type=".$type."&type_instance=".$tinst."&from=$year&to=$now&width=400&height=150";
$yearly_url .= $args;