a million fixes. half way to 0.6.0! :D

git-svn-id: http://www.observium.org/svn/observer/trunk@407 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-04-23 21:13:56 +00:00
parent 35bc68a0d9
commit bc6ad69724
26 changed files with 616 additions and 406 deletions
+123 -20
View File
@@ -4,8 +4,9 @@ include("graphing/screenos.php");
include("graphing/fortigate.php");
include("graphing/windows.php");
include("graphing/unix.php");
include("graphing/collectd.inc.php");
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '0') {
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') {
global $config, $installdir;
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
@@ -25,17 +26,19 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $ti
$i++;
}
}
if($inverse) { $in = 'out'; $out = 'in'; } else { $in = 'in'; $out = 'out'; }
$options .= " CDEF:".$in."octets=" . $in_thing . $pluses;
$options .= " CDEF:".$out."octets=" . $out_thing . $pluses;
$options .= " CDEF:doutoctets=outoctets,-1,*";
$options .= " CDEF:inbits=inoctets,8,*";
$options .= " CDEF:outbits=outoctets,8,*";
$options .= " CDEF:doutbits=doutoctets,8,*";
if($legend) {
if($legend == "no") {
$options .= " AREA:inbits#CDEB8B:";
$options .= " LINE1.25:inbits#006600:";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:";
} else {
$options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n";
$options .= " LINE1.25:inbits#006600:In\ ";
@@ -47,11 +50,6 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $ti
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
$options .= " GPRINT:outbits:MAX:%6.2lf%s";
} else {
$options .= " AREA:inbits#CDEB8B:";
$options .= " LINE1.25:inbits#006600:";
$options .= " AREA:doutbits#C3D9FF:";
$options .= " LINE1.25:doutbits#000099:";
}
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal"; }
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
@@ -94,6 +92,35 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
return $imgfile;
}
function graph_cpmCPU ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
$options .= " -l 0 -E -b 1024 --title '$title' ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM `cpmCPU` AS C, `devices` AS D where C.`cpmCPU_id` = '$id' AND C.device_id = D.device_id");
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
while($proc = mysql_fetch_array($sql)) {
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$proc['descr_fixed'] = str_pad($proc['entPhysicalDescr'], 28);
$proc['descr_fixed'] = substr($proc['descr_fixed'],0,28);
$rrd = $config['rrd_dir'] . "/".$proc['hostname']."/cpmCPU-" . $proc['cpmCPU_oid'] . ".rrd";
$options .= " DEF:proc" . $proc['cpmCPU_oid'] . "=$rrd:usage:AVERAGE ";
$options .= " LINE1:proc" . $proc['cpmCPU_oid'] . "#" . $colour . ":'" . $proc['descr_fixed'] . "' ";
$options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":LAST:%3.0lf";
$options .= " GPRINT:proc" . $proc['cpmCPU_oid'] . ":MAX:%3.0lf\\\l ";
$iter++;
}
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
@@ -121,6 +148,81 @@ function graph_device_cpmCPU ($device, $graph, $from, $to, $width, $height, $tit
return $imgfile;
}
function graph_device_cempMemPool ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
$options .= " -l 0 -E -b 1024 --title '$title' ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM `cempMemPool` where `device_id` = '$device'");
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
while($mempool = mysql_fetch_array($sql)) {
$entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$device."'
AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName'];
$mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 28);
$mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,28);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$rrd = $config['rrd_dir'] . "/$hostname/cempMemPool-$oid.rrd";
$id = $mempool['entPhysicalIndex'] . "-" . $mempool['Index'];
$options .= " DEF:mempool" . $id . "free=$rrd:free:AVERAGE ";
$options .= " DEF:mempool" . $id . "used=$rrd:used:AVERAGE ";
$options .= " CDEF:mempool" . $id . "total=mempool" . $id . "used,mempool" . $id . "used,mempool" . $id . "free,+,/,100,* ";
$options .= " LINE1:mempool" . $id . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' ";
$options .= " GPRINT:mempool" . $id . "total:LAST:%3.0lf";
$options .= " GPRINT:mempool" . $id . "total:MAX:%3.0lf\\\l ";
$iter++;
}
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function graph_cempMemPool ($id, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
$options = "--start $from --end $to --width $width --height $height --vertical-label '$vertical' --alt-autoscale-max ";
$options .= " -l 0 -E -b 1024 --title '$title' ";
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$hostname = gethostbyid($device);
$imgfile = $config['install_dir'] . "/graphs/" . "$graph";
$iter = "1";
$sql = mysql_query("SELECT * FROM `cempMemPool` AS C, `devices` AS D where C.`cempMemPool_id` = '$id' AND C.device_id = D.device_id");
$options .= "COMMENT:\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ Cur\ \ \ \ Max\\\\n";
while($mempool = mysql_fetch_array($sql)) {
$entPhysicalName = mysql_result(mysql_query("SELECT entPhysicalName from entPhysical WHERE device_id = '".$mempool['device_id']."'
AND entPhysicalIndex = '".$mempool['entPhysicalIndex']."'"),0);
if($iter=="1") {$colour="CC0000";} elseif($iter=="2") {$colour="008C00";} elseif($iter=="3") {$colour="4096EE";
} elseif($iter=="4") {$colour="73880A";} elseif($iter=="5") {$colour="D01F3C";} elseif($iter=="6") {$colour="36393D";
} elseif($iter=="7") {$colour="FF0084"; unset($iter); }
$mempool['descr_fixed'] = $entPhysicalName . " " . $mempool['cempMemPoolName'];
$mempool['descr_fixed'] = str_replace("Routing Processor", "RP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Switching Processor", "SP", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_replace("Processor", "Proc", $mempool['descr_fixed']);
$mempool['descr_fixed'] = str_pad($mempool['descr_fixed'], 28);
$mempool['descr_fixed'] = substr($mempool['descr_fixed'],0,28);
$oid = $mempool['entPhysicalIndex'] . "." . $mempool['Index'];
$rrd = $config['rrd_dir'] . "/".$mempool['hostname']."/cempMemPool-$oid.rrd";
$id = $mempool['entPhysicalIndex'] . "-" . $mempool['Index'];
$options .= " DEF:mempool" . $id . "free=$rrd:free:AVERAGE ";
$options .= " DEF:mempool" . $id . "used=$rrd:used:AVERAGE ";
$options .= " CDEF:mempool" . $id . "total=mempool" . $id . "used,mempool" . $id . "used,mempool" . $id . "free,+,/,100,* ";
$options .= " LINE1:mempool" . $id . "total#" . $colour . ":'" . $mempool['descr_fixed'] . "' ";
$options .= " GPRINT:mempool" . $id . "total:LAST:%3.0lf";
$options .= " GPRINT:mempool" . $id . "total:MAX:%3.0lf\\\l ";
$iter++;
}
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;
}
function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $vertical) {
global $config, $installdir;
@@ -179,6 +281,7 @@ function graph_mac_acc ($id, $graph, $from, $to, $width, $height) {
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; }
if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:inoctets=$database:IN:AVERAGE";
$options .= " DEF:outoctets=$database:OUT:AVERAGE";
$options .= " CDEF:octets=inoctets,outoctets,+";
@@ -390,22 +493,22 @@ function graph_cbgp_prefixes ($rrd, $graph, $from, $to, $width, $height) {
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($width <= "300") {$options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
$options .= " DEF:Accepted=$database:AcceptedPrefixes:AVERAGE";
$options .= " DEF:Denied=$database:DeniedPrefixes:AVERAGE";
$options .= " DEF:Advertised=$database:AdvertisedPrefixes:AVERAGE";
$options .= " DEF:Suppressed=$database:SuppressedPrefixes:AVERAGE";
$options .= " DEF:Withdrawn=$database:WithdrawnPrefixes:AVERAGE";
$options .= " CDEF:dAdvertised=Advertised,-1,*";
#$options .= " DEF:Denied=$database:DeniedPrefixes:AVERAGE";
#$options .= " DEF:Advertised=$database:AdvertisedPrefixes:AVERAGE";
#$options .= " DEF:Suppressed=$database:SuppressedPrefixes:AVERAGE";
#$options .= " DEF:Withdrawn=$database:WithdrawnPrefixes:AVERAGE";
#$options .= " CDEF:dAdvertised=Advertised,-1,*";
$options .= " COMMENT:Prefixes\ \ \ \ \ \ Current\ \ Minimum\ \ Maximum\\\\n";
$options .= " AREA:Accepted#eeaaaa:";
$options .= " LINE2:Accepted#cc0000:Accepted\ \ ";
$options .= " GPRINT:Accepted:LAST:%6.2lf%s";
$options .= " GPRINT:Accepted:MIN:%6.2lf%s";
$options .= " GPRINT:Accepted:MAX:%6.2lf%s\\\\l";
$options .= " AREA:dAdvertised#aaeeaa:";
$options .= " LINE2:dAdvertised#00cc00:Advertised";
$options .= " GPRINT:Advertised:LAST:%6.2lf%s";
$options .= " GPRINT:Advertised:MIN:%6.2lf%s";
$options .= " GPRINT:Advertised:MAX:%6.2lf%s\\\\l";
#$options .= " AREA:dAdvertised#aaeeaa:";
#$options .= " LINE2:dAdvertised#00cc00:Advertised";
#$options .= " GPRINT:Advertised:LAST:%6.2lf%s";
#$options .= " GPRINT:Advertised:MIN:%6.2lf%s";
#$options .= " GPRINT:Advertised:MAX:%6.2lf%s\\\\l";
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
# echo($config['rrdtool'] . " graph $imgfile $options");
return $imgfile;