スポンサーサイト

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

ganglia TCP 用 グラフ

ganglia TCP 用 グラフ

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

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

$metric_array = array(
array("tcp_closed", "#3366FF", "CLOSED" ),
array("tcp_closewait", "#33FF66", "CLOSE_WAIT" ),
array("tcp_closing", "#BB9933", "CLOSING" ),
array("tcp_established", "#FF3366", "ESTABLISHED" ),
array("tcp_finwait1", "#FFFF00", "FIN_WAIT_1" ),
array("tcp_finwait2", "#00FF00", "FIN_WAIT_2" ),
array("tcp_lastack", "#AA0000", "LAST_ACK" ),
array("tcp_listen", "#FFFFAA", "LISTEN" ),
array("tcp_synrecv", "#FF33CC", "SYN_RECEIVED" ),
array("tcp_synsent", "#FF0000", "SYN_SENT" ),
array("tcp_synwait", "#CC0000", "SYN_WAIT" ),
array("tcp_timewait", "#FF00FF", "TIME_WAIT" )
);

$title = "TCP 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ヶ月以上更新のないブログに表示されています。新しい記事を書くことで広告を消せます。