mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-28 16:04:35 +02:00
fixes
git-svn-id: http://www.observium.org/svn/observer/trunk@339 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
./poll-mac_accounting.php >> /var/log/observer.log &
|
||||
./discover-bgp_peers.php >> /var/log/observer.log &
|
||||
./poll-device.php --odd >> /var/log/observer.log &
|
||||
./poll-device.php --even >> /var/log/observer.log &
|
||||
|
||||
@@ -77,6 +77,12 @@
|
||||
case 'global_bits':
|
||||
$graph = graph_global_bits ("global_bits.png", $from, $to, $width, $height);
|
||||
break;
|
||||
case 'mac_acc_int':
|
||||
$graph = graph_mac_acc_interface ($_GET['if'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
case 'mac_acc':
|
||||
$graph = graph_mac_acc ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
case 'device_bits':
|
||||
$graph = graph_device_bits ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
|
||||
break;
|
||||
|
||||
@@ -52,6 +52,13 @@
|
||||
}
|
||||
|
||||
echo("</span>");
|
||||
|
||||
echo("</td><td width=100>");
|
||||
|
||||
if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){
|
||||
echo("<a href='/?page=mac-accounting&id=".$interface['interface_id']."'><img src='/images/16/chart_curve.png' align='absmiddle'> Mac Acc</a>");
|
||||
}
|
||||
|
||||
echo("</td><td width=120>");
|
||||
if($interface['ifOperStatus'] == "up") {
|
||||
|
||||
|
||||
@@ -15,7 +15,14 @@ if($_GET['type']) {
|
||||
if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
|
||||
echo("<tr bgcolor='$bg'>
|
||||
<td><span class=list-large>" . generateiflink($interface,$interface['ifAlias']) . "</span><br />
|
||||
<span class=interface-desc>".generatedevicelink($interface)." ".generateiflink($interface)." </span></td></tr><tr bgcolor='$bg'><td>");
|
||||
<span class=interface-desc style='float: left;'>".generatedevicelink($interface)." ".generateiflink($interface)." </span>");
|
||||
|
||||
if(mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'"),0)){
|
||||
echo("<span style='float: right;'><a href='/?page=mac-accounting&id=".$interface['interface_id']."'><img src='/images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>");
|
||||
}
|
||||
|
||||
|
||||
echo("</td></tr><tr bgcolor='$bg'><td>");
|
||||
|
||||
if(file_exists($rrd_dir . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd")) {
|
||||
|
||||
|
||||
+95
-1
@@ -89,7 +89,6 @@ function temp_graph ($temp, $graph, $from, $to, $width, $height, $title, $vertic
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
|
||||
function temp_graph_dev ($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 ";
|
||||
@@ -160,6 +159,101 @@ function graph_device_bits ($device, $graph, $from, $to, $width, $height) {
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
function graph_mac_acc ($id, $graph, $from, $to, $width, $height) {
|
||||
global $config;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.ma_id = '".$id."' AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
|
||||
$acc = mysql_fetch_array($query);
|
||||
|
||||
$database = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd";
|
||||
|
||||
|
||||
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
|
||||
if($height < "33") { $options .= " --only-graph"; }
|
||||
$period = $to - $from;
|
||||
$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,+";
|
||||
$options .= " CDEF:doutoctets=outoctets,-1,*";
|
||||
$options .= " CDEF:inbits=inoctets,8,*";
|
||||
$options .= " CDEF:outbits=outoctets,8,*";
|
||||
$options .= " CDEF:doutbits=doutoctets,8,*";
|
||||
$options .= " VDEF:totin=inoctets,TOTAL";
|
||||
$options .= " VDEF:totout=outoctets,TOTAL";
|
||||
$options .= " VDEF:tot=octets,TOTAL";
|
||||
$options .= " VDEF:95thin=inbits,95,PERCENT";
|
||||
$options .= " VDEF:95thout=outbits,95,PERCENT";
|
||||
$options .= " VDEF:d95thout=doutbits,5,PERCENT";
|
||||
$options .= " AREA:inbits#CDEB8B:";
|
||||
$options .= " COMMENT:BPS\ \ \ \ Current\ \ \ Average\ \ \ \ \ \ Max\ \ \ 95th\ %\\\\n";
|
||||
$options .= " LINE1.25:inbits#006600:In\ ";
|
||||
$options .= " GPRINT:inbits:LAST:%6.2lf%s";
|
||||
$options .= " GPRINT:inbits:AVERAGE:%6.2lf%s";
|
||||
$options .= " GPRINT:inbits:MAX:%6.2lf%s";
|
||||
$options .= " GPRINT:95thin:%6.2lf%s\\\\n";
|
||||
$options .= " AREA:doutbits#C3D9FF:";
|
||||
$options .= " LINE1.25:doutbits#000099:Out";
|
||||
$options .= " GPRINT:outbits:LAST:%6.2lf%s";
|
||||
$options .= " GPRINT:outbits:AVERAGE:%6.2lf%s";
|
||||
$options .= " GPRINT:outbits:MAX:%6.2lf%s";
|
||||
$options .= " GPRINT:95thout:%6.2lf%s\\\\n";
|
||||
$options .= " GPRINT:tot:Total\ %6.2lf%s";
|
||||
$options .= " GPRINT:totin:\(In\ %6.2lf%s";
|
||||
$options .= " GPRINT:totout:Out\ %6.2lf%s\)\\\\l";
|
||||
$options .= " LINE1:95thin#aa0000";
|
||||
$options .= " LINE1:d95thout#aa0000";
|
||||
|
||||
#echo($config['rrdtool'] . " graph $imgfile $options");
|
||||
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function graph_mac_acc_interface ($interface, $graph, $from, $to, $width, $height) {
|
||||
global $config, $installdir;
|
||||
$imgfile = "graphs/" . "$graph";
|
||||
$options = "--alt-autoscale-max -E --start $from --end " . ($to - 150) . " --width $width --height $height ";
|
||||
if($height < "33") { $options .= " --only-graph"; }
|
||||
$hostname = gethostbyid($device);
|
||||
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `interfaces` AS I, `devices` AS D WHERE M.interface_id = '$interface' AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
|
||||
if($width <= "300") { $options .= "--font LEGEND:7:".$config['mono_font']." --font AXIS:6:".$config['mono_font']." --font-render-mode normal "; }
|
||||
$pluses = "";
|
||||
$options .= " COMMENT:' In Out\\\\n'";
|
||||
while($acc = mysql_fetch_array($query)) {
|
||||
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/mac-accounting/" . $acc['ifIndex'] . "-" . $acc['peer_ip'] . ".rrd";
|
||||
if(is_file($this_rrd)) {
|
||||
$this_id = str_replace(".", "", $acc['peer_ip']);
|
||||
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); } else {$colour="C600C6";}
|
||||
$descr = str_pad($acc['peer_desc'], 36);
|
||||
$descr = substr($descr,0,36);
|
||||
$options .= " DEF:in".$this_id."=$this_rrd:IN:AVERAGE ";
|
||||
$options .= " DEF:out".$this_id."temp=$this_rrd:OUT:AVERAGE ";
|
||||
$options .= " CDEF:out".$this_id."=out".$this_id."temp,-1,* ";
|
||||
$options .= " CDEF:octets".$this_id."=in".$this_id.",out".$this_id."temp,+";
|
||||
$options .= " VDEF:totin".$this_id."=in".$this_id.",TOTAL";
|
||||
$options .= " VDEF:totout".$this_id."=out".$this_id."temp,TOTAL";
|
||||
$options .= " VDEF:tot".$this_id."=octets".$this_id.",TOTAL";
|
||||
$options .= " LINE1.25:in".$this_id."#" . $colour . ":'" . $descr . "'";
|
||||
$options .= " LINE1.25:out".$this_id."#" . $colour . "::";
|
||||
$options .= " GPRINT:in".$this_id.":LAST:%6.2lf%sbps";
|
||||
$options .= " GPRINT:totin".$this_id.":\(%6.2lf%sB\)";
|
||||
$options .= " GPRINT:out".$this_id."temp:LAST:%6.2lf%sbps";
|
||||
$options .= " GPRINT:totout".$this_id.":\(%6.2lf%sB\)\\\\n";
|
||||
$iter++;
|
||||
}
|
||||
}
|
||||
#echo($config['rrdtool'] . " graph $imgfile $options");
|
||||
$thing = shell_exec($config['rrdtool'] . " graph $imgfile $options");
|
||||
return $imgfile;
|
||||
}
|
||||
|
||||
|
||||
function trafgraph ($rrd, $graph, $from, $to, $width, $height) {
|
||||
global $config, $installdir;
|
||||
$database = $config['rrd_dir'] . "/" . $rrd;
|
||||
|
||||
Reference in New Issue
Block a user