Fixed some cosmetic issues with cisco graphs. Added cisco-specific OID for getting better ifType.

git-svn-id: http://www.observium.org/svn/observer/trunk@60 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-04-04 22:05:52 +00:00
parent 2ca09bdfd0
commit 6e1a7bbd6b
6 changed files with 144 additions and 73 deletions

View File

@@ -40,6 +40,91 @@ function temp_graph ($device, $graph, $from, $to, $width, $height, $title, $vert
}
}
function graph_global_bits ($graph, $from, $to, $width, $height) {
global $rrdtool, $installdir, $mono_font, $rrd_dir;
$imgfile = "graphs/" . $graph;
$opts = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
$query = mysql_query("SELECT `ifIndex`, I.id as id, D.hostname FROM `interfaces` AS I, `devices` AS D WHERE I.host = D.id AND I.iftype LIKE '%ethernet%'");
while($int = mysql_fetch_row($query)) {
$hostname = $int[2];
$id = $int[1];
if(is_file($rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd")) {
$opts .= "DEF:inoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:INOCTETS:AVERAGE \
DEF:outoctets" . $int[1] . "=" . $rrd_dir . "/" . $hostname . "." . $int[0] . ".rrd:OUTOCTETS:AVERAGE \
";
$in_thing .= $seperator . "inoctets" . $int[1] . ",UN,0," . "inoctets" . $int[1] . ",IF";
$out_thing .= $seperator . "outoctets" . $int[1] . ",UN,0," . "outoctets" . $int[1] . ",IF";
$pluses .= $plus;
$seperator = ",";
$plus = ",+";
}
}
$opts .= " CDEF:inoctets=" . $in_thing . $pluses . " \
CDEF:outoctets=" . $out_thing . $pluses . " \
CDEF:doutoctets=outoctets,-1,* \
CDEF:inbits=inoctets,8,* \
CDEF:outbits=outoctets,8,* \
CDEF:doutbits=doutoctets,8,* \
AREA:inbits#CDEB8B: \
COMMENT:BPS Current Average Max 95th %\\n \
LINE1.25:inbits#006600:In \
GPRINT:inbits:LAST:%6.2lf%s \
GPRINT:inbits:AVERAGE:%6.2lf%s \
GPRINT:inbits:MAX:%6.2lf%s\l \
AREA:doutbits#C3D9FF: \
LINE1.25:doutbits#000099:Out \
GPRINT:outbits:LAST:%6.2lf%s \
GPRINT:outbits:AVERAGE:%6.2lf%s \
GPRINT:outbits:MAX:%6.2lf%s ";
if($width <= '300') {
$opts .= " --font LEGEND:7:$mono_font --font AXIS:6:$mono_font --font-render-mode normal ";
}
echo("<pre>");
echo($imgfile . "\n" . $opts);
$cmd = "/usr/bin/rrdtool";
`rm /tmp/poo`;
$handle = fopen("/tmp/poo", "w");
fwrite($handle, " graph test.png " . $opts);
if (( $fh = popen($cmd, 'r')) === false)
die("Open failed : ${php_errormsg}\n");
fwrite($fh, " graph $imgfile " . $opts);
pclose($fh);
echo`$rrdtool graph $imgfile $opts`;
# $ret = rrd_graph("$imgfile", $opts, count($opts));
# if( !is_array($ret) )
# {
# $err = rrd_error();
# echo "rrd_graph() ERROR: $err\n";
# if ( !is_file($installdir . $imgfile) ) {
# return FALSE;
# } else {
return $imgfile;
# }
}
function graph_device_bits ($device, $graph, $from, $to, $width, $height)
{
global $rrdtool, $installdir, $mono_font, $rrd_dir;
@@ -76,7 +161,7 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height)
"CDEF:outbits=outoctets,8,*",
"CDEF:doutbits=doutoctets,8,*",
"AREA:inbits#CDEB8B:",
"COMMENT:BPS Current Average Max 95th %\\n",
"COMMENT:BPS Current Average Max\\n",
"LINE1.25:inbits#006600:In ",
"GPRINT:inbits:LAST:%6.2lf%s",
"GPRINT:inbits:AVERAGE:%6.2lf%s",