スポンサーサイト

上記の広告は1ヶ月以上更新のないブログに表示されています。
新しい記事を書く事で広告が消せます。

ganglia apache 用 グラフ

ganglia apache 用 グラフ

<?php
/* Pass in by reference! */
function graph_apache_status_report ( &$rrdtool_graph ) {

global $context,
$hostname,
$range,
$rrd_dir,
$size;

$metric_array = array(
array("ap_open_slot", "#3366FF", "Open slot with no current process" ),
array("ap_waiting", "#33FF66", "Waiting for Connection" ),
array("ap_reading_request", "#BB9933", "Reading Request" ),
array("ap_sending_reply", "#FF3366", "Sending Reply" ),
array("ap_keepalive", "#FFFF00", "Keepalive (read)" ),
array("ap_dns_lookup", "#00FF00", "DNS Lookup" ),
array("ap_logging", "#AA0000", "Logging" ),
array("ap_closing", "#FFFFAA", "Closing connection" ),
array("ap_starting", "#FF33CC", "Starting up" ),
array("ap_gracefully_fin", "#FF0000", "Gracefully finishing" ),
array("ap_idle", "#CC0000", "Idle cleanup of worker" )
);

$title = "apache status";
if ($context != 'host') {
$rrdtool_graph['title'] = $title;
} else {
$rrdtool_graph['title'] = "$hostname $title last $range";
}

$rrdtool_graph['lower-limit'] = '0';
$rrdtool_graph['vertical-label'] = 'connections';
$rrdtool_graph['extras'] = '--slope-mode';

# Initialize some of the RRDtool components
$rrd_defs = "";
$rrd_graphs = "";
$rrd_legend = "";
$counter = 0;
for ( $i = 0 ; $i < sizeof($metric_array); $i++ ) {
$metric = $metric_array[$i];
# Need index for generating RRD labels
$index = chr($counter + 97);
$rrd_file = $rrd_dir . "/" . $metric[0] . ".rrd";
if ( file_exists($rrd_file)) {
$rrd_defs .= "DEF:" . $index . "='" . $rrd_file . "':'sum':AVERAGE ";
$rrd_graphs .= "CDEF:n" . $index . "=" . $index . ",UN,0," . $index . ",IF ";
##################################################################################
if ( $counter == 0) {
$rrd_legend .= "AREA:" . $index . $metric[1] . "91" . ":'" . $metric[2] . "' ";
} else {
$rrd_legend .= "STACK:" . $index . $metric[1] . "91" . ":'" . $metric[2] . "' ";
}
if ($size == 'large') {
$rrd_legend .= "VDEF:n" . $index . "_max" . "=" . $index . ",MAXIMUM ";
$rrd_legend .= "GPRINT:n" . $index . "_max" . ":" . '"Max\:%6.0lf" ';
$rrd_legend .= "VDEF:n" . $index . "_min" . "=" . $index . ",MINIMUM ";
$rrd_legend .= "GPRINT:n" . $index . "_min" . ":" . '"Min\:%6.0lf" ';
$rrd_legend .= "VDEF:n" . $index . "_avg" . "=" . $index . ",AVERAGE ";
$rrd_legend .= "GPRINT:n" . $index . "_avg" . ":" . '"Avg\:%6.0lf" ';
$rrd_legend .= "VDEF:n" . $index . "_last" . "=" . $index . ",LAST ";
# Can't figure out an easy way to line up the legend
$rrd_legend .= "GPRINT:n" . $index . "_last" . ":" .'"Now\:%6.0lf \r" ';
}
$counter++;
}
}

$rrdtool_graph['series'] = $rrd_defs . $rrd_graphs . $rrd_legend;
return $rrdtool_graph;
}
?>
スポンサーサイト

コメントの投稿

非公開コメント

検索フォーム
RSSリンクの表示
リンク
exabugsをフォローしましょう
上記広告は1ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。