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,7 +20,8 @@ $scale_min = "0";
$nototal = 1;
if ($rrd_list) {
if ($rrd_list)
{
include ("includes/graphs/generic_multi_line.inc.php");
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,7 @@
<?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);
@@ -8,7 +9,6 @@ if(is_numeric($id) && ($config['allow_unauth_graphs'] || port_permitted($id))) {
$auth = TRUE;
$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
}
?>

View File

@@ -9,8 +9,11 @@ $oids = array('dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingle
$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;
@@ -26,6 +29,4 @@ $unit_text = "Errors";
include("includes/graphs/generic_multi_simplex_seperated.inc.php");
?>

View File

@@ -4,7 +4,8 @@ $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `device
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");
}

View File

@@ -4,7 +4,8 @@ $query = mysql_query("SELECT * FROM `mac_accounting` AS M, `ports` AS I, `device
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");
}

View File

@@ -8,11 +8,13 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
include("includes/graphs/common.inc.php");
if($stat == "pkts") {
if ($stat == "pkts")
{
$units='pps'; $unit = 'p'; $multiplier = '1';
$colours = 'purples';
$prefix = "P";
if($sort == "in") {
if ($sort == "in")
{
$sort = "cipMacHCSwitchedPkts_input_rate";
} elseif ($sort == "out") {
$sort = "cipMacHCSwitchedPkts_output_rate";
@@ -22,7 +24,8 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
} elseif ($stat == "bits") {
$units='bps'; $unit='B'; $multiplier='8';
$colours='greens';
if($sort == "in") {
if ($sort == "in")
{
$sort = "cipMacHCSwitchedBytes_input_rate";
} elseif ($sort == "out") {
$sort = "cipMacHCSwitchedBytes_output_rate";
@@ -39,33 +42,41 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
$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)) {
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)) {
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) {
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) {
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)) {
$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 {
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; }
$colour=$config['graph_colours'][$colours][$iter];
@@ -96,6 +107,7 @@ if(is_numeric($_GET['topn'])) { $topn = $_GET['topn']; } else { $topn = '10'; }
$iter++;
}
}
$rrd_options .= $rrd_optionsb;
$rrd_options .= " HRULE:0#999999";

View File

@@ -1,8 +1,8 @@
<?php
# 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,7 +37,6 @@ if(1)
$nototal = 1;
include ("includes/graphs/generic_multi_seperated.inc.php");
}
elseif (is_file($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,8 +5,10 @@
$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++;
@@ -25,6 +27,4 @@ $rra_out = "OUTOCTETS";
include ("includes/graphs/generic_multi_bits_separated.inc.php");
?>