add rancid config integration

git-svn-id: http://www.observium.org/svn/observer/trunk@343 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2009-02-04 16:18:11 +00:00
parent acfc14a887
commit 7fa663d9f5
5 changed files with 61 additions and 9 deletions

View File

@@ -76,6 +76,8 @@ $config['enable_syslog'] = 1; # Enable Syslog
$config['enable_billing'] = 1; # Enable BGP session collection and display $config['enable_billing'] = 1; # Enable BGP session collection and display
$config['enable_inventory'] = 1; # Enable Inventory $config['enable_inventory'] = 1; # Enable Inventory
## Uncomment this to enable display of rancid-collected configs
#$config['rancid_configs'] = '/var/lib/rancid/network/configs/';
## If a syslog entry contails these strings it is deleted from the database ## If a syslog entry contails these strings it is deleted from the database
$config['syslog_filter'] = array("last message repeated", "Connection from UDP: [127.0.0.1]:"); $config['syslog_filter'] = array("last message repeated", "Connection from UDP: [127.0.0.1]:");

View File

@@ -26,6 +26,12 @@
$device_id = getpeerhost($_GET['peer']); $device_id = getpeerhost($_GET['peer']);
} }
if($_GET['legend']) {
$legend = $_GET['legend'];
}
if($_GET['inverse']) {
$inverse = $_GET['inverse'];
}
if($device_id) { if($device_id) {
$hostname = gethostbyid($device_id); $hostname = gethostbyid($device_id);
@@ -63,7 +69,7 @@
$graph = graph_netscreen_memory ($hostname . "/netscreen-memory.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); $graph = graph_netscreen_memory ($hostname . "/netscreen-memory.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
break; break;
case 'multi_bits': case 'multi_bits':
$graph = graph_multi_bits ($_GET['interfaces'], $graphfile, $from, $to, $width, $height); $graph = graph_multi_bits ($_GET['interfaces'], $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
break; break;
case 'adsl_rate': case 'adsl_rate':
$graph = graph_adsl_rate ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height); $graph = graph_adsl_rate ($hostname. "/adsl-4.rrd", $graphfile, $from, $to, $width, $height);
@@ -87,7 +93,7 @@
$graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical); $graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break; break;
case 'bits': case 'bits':
$graph = trafgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); $graph = graph_bits ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical, $inverse, $legend);
break; break;
case 'pkts': case 'pkts':
$graph = pktsgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical); $graph = pktsgraph ($hostname . "/". $ifIndex . ".rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);

View File

@@ -137,6 +137,16 @@ if($config['enable_syslog']) { echo("
</li> </li>
"); } "); }
if($_SESSION[userlevel] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) {
echo("
<li class=" . $select['showconfig'] . ">
<a href='/device/" . $device['device_id'] . "/showconfig/'>
<img src='images/16/page_white_text.png' align=absmiddle border=0> Config
</a>
</li>
");
}
if($_SESSION[userlevel] >= "5") { if($_SESSION[userlevel] >= "5") {
echo(" echo("
<li class=" . $select['edit'] . "> <li class=" . $select['edit'] . ">

View File

@@ -0,0 +1,16 @@
<?php
if($_SESSION[userlevel] >= "5" && is_file($config['rancid_configs'] . $device['hostname'])) {
$file = $config['rancid_configs'] . $device['hostname'];
$fh = fopen($file, 'r') or die("Can't open file");
echo(highlight_string(fread($fh, filesize($file))));
fclose($fh);
} else {
print_error("Error : Insufficient access.");
}
?>

View File

@@ -5,7 +5,7 @@ include("graphing/fortigate.php");
include("graphing/windows.php"); include("graphing/windows.php");
include("graphing/unix.php"); include("graphing/unix.php");
function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $legend = '0') { function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '0') {
global $config, $installdir; global $config, $installdir;
$imgfile = "graphs/" . "$graph"; $imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height"; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height";
@@ -25,12 +25,16 @@ function graph_multi_bits ($interfaces, $graph, $from, $to, $width, $height, $le
$i++; $i++;
} }
} }
$options .= " CDEF:inoctets=" . $in_thing . $pluses;
$options .= " CDEF:outoctets=" . $out_thing . $pluses; 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:doutoctets=outoctets,-1,*";
$options .= " CDEF:inbits=inoctets,8,*"; $options .= " CDEF:inbits=inoctets,8,*";
$options .= " CDEF:outbits=outoctets,8,*"; $options .= " CDEF:outbits=outoctets,8,*";
$options .= " CDEF:doutbits=doutoctets,8,*"; $options .= " CDEF:doutbits=doutoctets,8,*";
if($legend) { if($legend) {
$options .= " AREA:inbits#CDEB8B:"; $options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n"; $options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\\\\n";
@@ -118,7 +122,7 @@ function temp_graph_dev ($device, $graph, $from, $to, $width, $height, $title, $
return $imgfile; return $imgfile;
} }
function graph_device_bits ($device, $graph, $from, $to, $width, $height) { function graph_device_bits ($device, $graph, $from, $to, $width, $height, $title, $vertical, $inverse, $legend = '1') {
global $config, $installdir; global $config, $installdir;
$imgfile = "graphs/" . "$graph"; $imgfile = "graphs/" . "$graph";
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height "; $options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
@@ -254,7 +258,7 @@ function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $heigh
} }
function trafgraph ($rrd, $graph, $from, $to, $width, $height) { function graph_bits ($rrd, $graph, $from, $to, $width, $height, $title, $vertical, $inverse = '0', $legend = '1') {
global $config, $installdir; global $config, $installdir;
$database = $config['rrd_dir'] . "/" . $rrd; $database = $config['rrd_dir'] . "/" . $rrd;
$imgfile = "graphs/" . "$graph"; $imgfile = "graphs/" . "$graph";
@@ -262,8 +266,13 @@ function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
$options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height "; $options = "--alt-autoscale-max -E --start $from --end $to --width $width --height $height ";
if($height < "33") { $options .= " --only-graph"; } 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 "; } if($width <= "300") { $options .= " --font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
if($inverse) {
$options .= " DEF:inoctets=$database:OUTOCTETS:AVERAGE";
$options .= " DEF:outoctets=$database:INOCTETS:AVERAGE";
} else {
$options .= " DEF:inoctets=$database:INOCTETS:AVERAGE"; $options .= " DEF:inoctets=$database:INOCTETS:AVERAGE";
$options .= " DEF:outoctets=$database:OUTOCTETS:AVERAGE"; $options .= " DEF:outoctets=$database:OUTOCTETS:AVERAGE";
}
$options .= " CDEF:octets=inoctets,outoctets,+"; $options .= " CDEF:octets=inoctets,outoctets,+";
$options .= " CDEF:doutoctets=outoctets,-1,*"; $options .= " CDEF:doutoctets=outoctets,-1,*";
$options .= " CDEF:inbits=inoctets,8,*"; $options .= " CDEF:inbits=inoctets,8,*";
@@ -275,6 +284,7 @@ function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " VDEF:95thin=inbits,95,PERCENT"; $options .= " VDEF:95thin=inbits,95,PERCENT";
$options .= " VDEF:95thout=outbits,95,PERCENT"; $options .= " VDEF:95thout=outbits,95,PERCENT";
$options .= " VDEF:d95thout=doutbits,5,PERCENT"; $options .= " VDEF:d95thout=doutbits,5,PERCENT";
if ($legend) {
$options .= " AREA:inbits#CDEB8B:"; $options .= " AREA:inbits#CDEB8B:";
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n"; $options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n";
$options .= " LINE1.25:inbits#006600:In\ "; $options .= " LINE1.25:inbits#006600:In\ ";
@@ -293,6 +303,14 @@ function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l"; $options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
$options .= " LINE1:95thin#aa0000"; $options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000"; $options .= " LINE1:d95thout#aa0000";
} else {
$options .= " AREA:inbits#CDEB8B";
$options .= " LINE1.25:inbits#006600";
$options .= " AREA:doutbits#C3D9FF";
$options .= " LINE1.25:doutbits#000099";
$options .= " LINE1:95thin#aa0000";
$options .= " LINE1:d95thout#aa0000";
}
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options"); $thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
return $imgfile; return $imgfile;
} }