port graphs cleanup

git-svn-id: http://www.observium.org/svn/observer/trunk@1905 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-03-17 13:25:37 +00:00
parent 75edcd1323
commit e1db733590
16 changed files with 136 additions and 119 deletions

View File

@ -20,8 +20,9 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}
?>
?>

View File

@ -20,8 +20,9 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}
?>
?>

View File

@ -20,8 +20,9 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}
?>
?>

View File

@ -20,8 +20,9 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}
?>
?>

View File

@ -21,8 +21,9 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}
?>
?>

View File

@ -1,14 +1,14 @@
<?php
if(is_numeric($id) && ($config['allow_unauth_graphs'] || port_permitted($id))) {
if (is_numeric($id) && ($config['allow_unauth_graphs'] || port_permitted($id)))
{
$port = get_port_by_id($id);
$device = device_by_id_cache($port['device_id']);
$title = generate_device_link($device);
$title .= " :: Port ".generate_port_link($port);
$auth = TRUE;
$auth = TRUE;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
}
?>
?>

View File

@ -5,4 +5,4 @@ $rra_out = "OUTOCTETS";
include("includes/graphs/generic_bits.inc.php");
?>
?>

View File

@ -25,6 +25,6 @@ $colours_out = 'blues';
$nototal = 1;
include ("includes/graphs/generic_multi_seperated.inc.php");
include("includes/graphs/generic_multi_seperated.inc.php");
?>
?>

View File

@ -7,10 +7,13 @@ $oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingle
'dot3StatsInternalMacTransmitErrors', 'dot3StatsCarrierSenseErrors', 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors',
'dot3StatsSymbolErrors');
$i=0;
$i = 0;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("port-" . $port['ifIndex'] . "-dot3.rrd");
if(is_file($rrd_filename)) {
foreach($oids as $oid){
if (is_file($rrd_filename))
{
foreach ($oids as $oid)
{
$oid = str_replace("dot3Stats", "", $oid);
$oid_rra = truncate($oid, 19, '');
$rrd_list[$i]['filename'] = $rrd_filename;
@ -18,14 +21,12 @@ if(is_file($rrd_filename)) {
$rrd_list[$i]['rra'] = $oid_rra;
$i++;
}
} else {echo("file missing: $file"); }
} else { echo("file missing: $file"); }
$colours = "mixed";
$nototal = 1;
$unit_text = "Errors";
include ("includes/graphs/generic_multi_simplex_seperated.inc.php");
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>
?>

View File

@ -4,19 +4,19 @@ $scale_min = "0";
include("includes/graphs/common.inc.php");
$rrd_options .= " COMMENT:' Last Max\\n'";
$rrd_options .= " COMMENT:' Last Max\\n'";
$fanspeed = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND sensor_id = '".mres($_GET['id'])."'"));
$fanspeed = mysql_fetch_array(mysql_query("SELECT * FROM sensors WHERE sensor_class='fanspeed' AND sensor_id = '".mres($_GET['id'])."'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $fanspeed['device_id'] . "'"),0);
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $fanspeed['device_id'] . "'"),0);
$fanspeed['sensor_descr_fixed'] = substr(str_pad($fanspeed['sensor_descr'], 20),0,20);
$fanspeed['sensor_descr_fixed'] = substr(str_pad($fanspeed['sensor_descr'], 20),0,20);
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("fan-" . $fanspeed['sensor_descr'] . ".rrd");
$rrd_filename = $config['rrd_dir'] . "/".$hostname."/" . safename("fan-" . $fanspeed['sensor_descr'] . ".rrd");
$rrd_options .= " DEF:fan=$rrd_filename:fan:AVERAGE";
$rrd_options .= " LINE1.5:fan#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($fanspeed['sensor_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " GPRINT:fan:LAST:%3.0lfrpm";
$rrd_options .= " GPRINT:fan:MAX:%3.0lfrpm\\\\l";
$rrd_options .= " DEF:fan=$rrd_filename:fan:AVERAGE";
$rrd_options .= " LINE1.5:fan#cc0000:'" . str_replace(':','\:',str_replace('\*','*',quotemeta($fanspeed['sensor_descr_fixed'])))."'"; # Ugly hack :(
$rrd_options .= " GPRINT:fan:LAST:%3.0lfrpm";
$rrd_options .= " GPRINT:fan:MAX:%3.0lfrpm\\\\l";
?>
?>

View File

@ -1,10 +1,11 @@
<?php
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$acc = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"))) {
if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
{
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/". safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
}
@ -13,4 +14,4 @@ $rra_out = "OUT";
include("includes/graphs/generic_bits.inc.php");
?>
?>

View File

@ -1,10 +1,11 @@
<?php
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
$query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.ma_id = '".mres($_GET['id'])."'
AND I.interface_id = M.interface_id AND I.device_id = D.device_id");
$acc = mysql_fetch_array($query);
if(is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd"))) {
if (is_file($config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd")))
{
$rrd_filename = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
}
@ -24,4 +25,4 @@ $unit_text = "Pkts\ \ \ ";
include("includes/graphs/generic_duplex.inc.php");
?>
?>

View File

@ -1,73 +1,84 @@
<?php
$port = mres($_GET['id']);
if($_GET['stat']) { $stat = mres($_GET['stat']); } else { $stat = "bits"; }
if ($_GET['stat']) { $stat = mres($_GET['stat']); } else { $stat = "bits"; }
$sort = mres($_GET['sort']);
if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
if (is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
include("includes/graphs/common.inc.php");
include("includes/graphs/common.inc.php");
if($stat == "pkts") {
$units='pps'; $unit = 'p'; $multiplier = '1';
$colours = 'purples';
$prefix = "P";
if($sort == "in") {
$sort = "cipMacHCSwitchedPkts_input_rate";
} elseif($sort == "out") {
$sort = "cipMacHCSwitchedPkts_output_rate";
} else {
$sort = "bps";
}
} elseif ($stat == "bits") {
$units='bps'; $unit='B'; $multiplier='8';
$colours='greens';
if($sort == "in") {
$sort = "cipMacHCSwitchedBytes_input_rate";
} elseif($sort == "out") {
$sort = "cipMacHCSwitchedBytes_output_rate";
} else {
$sort = "bps";
}
if ($stat == "pkts")
{
$units='pps'; $unit = 'p'; $multiplier = '1';
$colours = 'purples';
$prefix = "P";
if ($sort == "in")
{
$sort = "cipMacHCSwitchedPkts_input_rate";
} elseif ($sort == "out") {
$sort = "cipMacHCSwitchedPkts_output_rate";
} else {
$sort = "bps";
}
} elseif ($stat == "bits") {
$units='bps'; $unit='B'; $multiplier='8';
$colours='greens';
if ($sort == "in")
{
$sort = "cipMacHCSwitchedBytes_input_rate";
} elseif ($sort == "out") {
$sort = "cipMacHCSwitchedBytes_output_rate";
} else {
$sort = "bps";
}
}
$sql = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps,
(M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps
FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.interface_id = '".$port."'
AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn;
$sql = "SELECT *, (M.cipMacHCSwitchedBytes_input_rate + M.cipMacHCSwitchedBytes_output_rate) AS bps,
(M.cipMacHCSwitchedPkts_input_rate + M.cipMacHCSwitchedPkts_output_rate) AS pps
FROM `mac_accounting` AS M, `ports` AS I, `devices` AS D WHERE M.interface_id = '".$port."'
AND I.interface_id = M.interface_id AND D.device_id = I.device_id ORDER BY $sort DESC LIMIT 0," . $topn;
$query = mysql_query($sql);
$pluses = ""; $iter = '0';
$rrd_options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'";
while($acc = mysql_fetch_array($query)) {
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
if(is_file($this_rrd)) {
$mac = formatmac($acc['mac']);
$name = $mac;
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'"));
if($addy) {
$name = $addy['ipv4_address'] . " (".$mac.")";
$peer = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D
WHERE A.ipv4_address = '".$addy['ipv4_address']."'
AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if($peer) {
$name = $peer['hostname'] . " " . makeshortif($peer['ifDescr']) . " (".$mac.")";
}
$query = mysql_query($sql);
$pluses = ""; $iter = '0';
$rrd_options .= " COMMENT:' In\: Current Maximum Total Out\: Current Maximum Total\\\\n'";
if(mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".
$addy['ipv4_address']."'"),0)) {
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'");
$peer_info = mysql_fetch_array($peer_query);
$name .= " - AS".$peer_info['bgpPeerRemoteAs'];
}
if($peer_info) { $asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext']; } else {
unset ($as); unset ($astext); unset($asn);
}
while ($acc = mysql_fetch_array($query))
{
$this_rrd = $config['rrd_dir'] . "/" . $acc['hostname'] . "/" . safename("cip-" . $acc['ifIndex'] . "-" . $acc['mac'] . ".rrd");
if (is_file($this_rrd))
{
$mac = formatmac($acc['mac']);
$name = $mac;
$addy = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_mac where mac_address = '".$acc['mac']."' AND interface_id = '".$acc['interface_id']."'"));
if ($addy)
{
$name = $addy['ipv4_address'] . " (".$mac.")";
$peer = mysql_fetch_array(mysql_query("SELECT * FROM ipv4_addresses AS A, ports AS I, devices AS D
WHERE A.ipv4_address = '".$addy['ipv4_address']."'
AND I.interface_id = A.interface_id AND D.device_id = I.device_id"));
if ($peer)
{
$name = $peer['hostname'] . " " . makeshortif($peer['ifDescr']) . " (".$mac.")";
}
if (mysql_result(mysql_query("SELECT count(*) FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".
$addy['ipv4_address']."'"),0))
{
$peer_query = mysql_query("SELECT * FROM bgpPeers WHERE device_id = '".$acc['device_id']."' AND bgpPeerIdentifier = '".$addy['ipv4_address']."'");
$peer_info = mysql_fetch_array($peer_query);
$name .= " - AS".$peer_info['bgpPeerRemoteAs'];
}
if ($peer_info) {
$asn = "AS".$peer_info['bgpPeerRemoteAs']; $astext = $peer_info['astext'];
} else {
unset ($as); unset ($astext); unset($asn);
}
}
}
$this_id = str_replace(".", "", $acc['mac']);
if(!$config['graph_colours'][$colours][$iter]) { $iter = 0; }
if (!$config['graph_colours'][$colours][$iter]) { $iter = 0; }
$colour=$config['graph_colours'][$colours][$iter];
$descr = str_pad($name, 36);
$descr = substr($descr,0,36);
@ -84,7 +95,7 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
$rrd_options .= " VDEF:totout".$this_id."=outB".$this_id."temp,TOTAL";
$rrd_options .= " VDEF:tot".$this_id."=octets".$this_id.",TOTAL";
$rrd_options .= " AREA:inB".$this_id."#" . $colour . ":'" . $descr . "':STACK";
if($rrd_optionsb) {$stack="STACK";}
if ($rrd_optionsb) { $stack="STACK"; }
$rrd_optionsb .= " AREA:outB".$this_id."#" . $colour . "::$stack";
$rrd_options .= " GPRINT:inB".$this_id.":LAST:%6.2lf%s$units";
$rrd_options .= " GPRINT:inB".$this_id.":MAX:%6.2lf%s$units";
@ -94,9 +105,10 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
$rrd_options .= " GPRINT:outB".$this_id."temp:MAX:%6.2lf%s$units";
$rrd_options .= " GPRINT:totout".$this_id.":%6.2lf%s$unit\\\\n";
$iter++;
}
}
$rrd_options .= $rrd_optionsb;
$rrd_options .= " HRULE:0#999999";
}
?>
$rrd_options .= $rrd_optionsb;
$rrd_options .= " HRULE:0#999999";
?>

View File

@ -1,8 +1,8 @@
<?php
if(1)
# FIXME uhh..
if (1)
{
$rrd_list[1]['filename'] = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
$rrd_list[1]['descr'] = $int['ifDescr'];
$rrd_list[1]['rra_in'] = "INNUCASTPKTS";
@ -11,7 +11,6 @@ if(1)
$rrd_list[1]['colour_area_in'] = "BB77BB";
$rrd_list[1]['colour_area_out'] = "FFDD88";
$rrd_list[2]['filename'] = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
$rrd_list[2]['descr'] = $int['ifDescr'];
$rrd_list[2]['rra_in'] = "INBROADCASTPKTS";
@ -38,9 +37,8 @@ if(1)
$nototal = 1;
include ("includes/graphs/generic_multi_seperated.inc.php");
}
elseif(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd")))
elseif (is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd")))
{
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($port['ifIndex'] . ".rrd");
@ -60,7 +58,6 @@ elseif(is_file($config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename($
$graph_max = 1;
include("includes/graphs/generic_duplex.inc.php");
}
?>
?>

View File

@ -5,18 +5,20 @@
$query = mysql_query("SELECT * FROM `ports` WHERE `device_id` = '".$port['device_id']."' AND `pagpGroupIfIndex` = '".$port['ifIndex']."'");
$i=0;
while($int = mysql_fetch_array($query)) {
if(is_file($config['rrd_dir'] . "/" . $hostname . "/port-" . safename($int['ifIndex'] . ".rrd"))) {
while ($int = mysql_fetch_array($query))
{
if (is_file($config['rrd_dir'] . "/" . $hostname . "/port-" . safename($int['ifIndex'] . ".rrd")))
{
$rrd_list[$i]['filename'] = $config['rrd_dir'] . "/" . $hostname . "/port-" . safename($int['ifIndex'] . ".rrd");
$rrd_list[$i]['descr'] = $int['ifDescr'];
$i++;
}
}
$units='bps';
$total_units='B';
$colours_in='greens';
$multiplier = "8";
$units='bps';
$total_units='B';
$colours_in='greens';
$multiplier = "8";
$colours_out = 'blues';
$nototal = 1;
@ -25,6 +27,4 @@ $rra_out = "OUTOCTETS";
include ("includes/graphs/generic_multi_bits_separated.inc.php");
?>
?>

View File

@ -16,4 +16,4 @@ $unit_text = "Packets";
include("includes/graphs/generic_duplex.inc.php");
?>
?>