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
+19 -5
View File
@@ -1,10 +1,12 @@
<?php
if($_GET['debug']) {
ini_set('display_errors', 1);
ini_set('display_startup_errors', 0);
ini_set('log_errors', 0);
ini_set('allow_url_fopen', 0);
# ini_set('error_reporting', E_ALL);
ini_set('error_reporting', E_ALL);
}
include("../config.php");
include("../includes/functions.php");
@@ -26,7 +28,7 @@
$device_id = getpeerhost($_GET['peer']);
}
if($_GET['legend']) { $legend = $_GET['legend']; }
if($_GET['legend']) { $legend = $_GET['legend']; } else { $legend = '1'; }
if($_GET['inverse']) { $inverse = $_GET['inverse']; }
if($device_id) { $hostname = gethostbyid($device_id); }
@@ -152,17 +154,24 @@
case 'dev_cpmCPU':
$graph = graph_device_cpmCPU ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'cpmCPU':
$graph = graph_cpmCPU ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'temp':
$graph = temp_graph ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'dev_temp':
$graph = temp_graph_dev ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'cempMemPool':
$graph = graph_cempMemPool ($_GET['id'], $graphfile, $from, $to, $width, $height, $title, $vertical);
break;
case 'mem':
if($os == "Linux" || $os == "FreeBSD" || $os == "DragonFly" || $os == "OpenBSD" || $os == "NetBSD" ) {
$graph = memgraphUnix ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
} elseif($os == "IOS" || $os == "IOS XE") {
$graph = memgraph ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
$graph = graph_device_cempMemPool ($device_id, $graphfile, $from, $to, $width, $height, $title, $vertical);
#$graph = memgraph ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
} elseif($os == "Windows") {
} elseif($os == "ProCurve") {
$graph = memgraphHP ($hostname . "/mem.rrd", $graphfile, $from, $to, $width, $height, $title, $vertical);
@@ -224,8 +233,13 @@
}
break;
default:
echo("INCORRECT GRAPH TYPE");
exit;
if(is_file($config['install_dir'] . "/html/includes/graphs/$type.inc.php")) {
include($config['install_dir'] . "/html/includes/graphs/$type.inc.php");
} else {
echo("INCORRECT GRAPH TYPE");
exit;
}
break;
}
if($graph) {
+9 -1
View File
@@ -1,16 +1,24 @@
<?php
$daily_traffic = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$day&to=$now&width=215&height=100";
$daily_traffic .= $args;
$daily_url = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$day&to=$now&width=400&height=150";
$daily_url .= $args;
$weekly_traffic = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$week&to=$now&width=215&height=100";
$weekly_traffic .= $args;
$weekly_url = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$week&to=$now&width=400&height=150";
$weekly_url .= $args;
$monthly_traffic = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$month&to=$now&width=215&height=100";
$monthly_traffic .= $args;
$monthly_url = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$month&to=$now&width=400&height=150";
$monthly_url .= $args;
$yearly_traffic = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$year&to=$now&width=215&height=100";
$yearly_url = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150";
$yearly_traffic .= $args;
$yearly_url = "graph.php?host=" . $device['device_id'] . "&type=$graph_type&from=$year&to=$now&width=400&height=150";
$yearly_url .= $args;
echo("<a onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\" onmouseout=\"return nd();\">
<img src='$daily_traffic' border=0></a> ");
+22 -31
View File
@@ -5,41 +5,31 @@
$interface['device_id'] = $device['device_id'];
$interface['hostname'] = $device['hostname'];
if(!$graph_type) { $graph_type = "bits"; }
$if_id = $interface['interface_id'];
$ifDescr = fixifName($interface['ifDescr']);
$ifIndex = $interface['ifIndex'];
$ifAlias = $interface['ifAlias'];
$ifSpeed = humanspeed($interface['ifSpeed']);
$ifPhysAddress = $interface['ifPhysAddress'];
$ifType = fixiftype($interface['ifType']);
$ifHardType = $interface['ifHardType'];
# $ifType = fixiftype($interface['ifType']);
# $ifHardType = $interface['ifHardType'];
# if($ifAlias) {$ifAlias = $ifAlias . ;}
#if($bg == "#ffffff") { $bg = "#e5e5e5"; } else { $bg="#ffffff"; }
if($bg == "#e5e5e5") { $bg = "#ffffff"; } else { $bg="#e5e5e5"; }
if($interface['in_errors'] > 0 || $interface['out_errors'] > 0) {
$error_img = generateiflink($interface,"<img src='images/16/chart_curve_error.png' alt='Interface Errors' border=0>",errors);
} else { $error_img = ""; }
# $graph_url = "graph.php?if=$if_id&from=$twoday&to=$now&width=400&height=120&type=bits";
echo("<tr style=\"background-color: $bg; padding: 5px;\" valign=top onmouseover=\"this.style.backgroundColor='#fdd';\" onmouseout=\"this.style.backgroundColor='$bg';\" onclick=\"location.href='/device/".$device['device_id']."/interface/".$interface['interface_id']."/'\" style='cursor: hand;'>
<td valign=top width=300>");
echo(" <span class=list-large>
" . generateiflink($interface, "$i. $ifDescr") . " $error_img
" . generateiflink($interface, "$i. ".fixifName($interface['ifDescr'])) . " $error_img
</span><br /><span class=interface-desc>$ifAlias</span>");
</span><br /><span class=interface-desc>".$interface['ifAlias']."</span>");
if($ifAlias) { echo("<br />"); }
if($interface['ifAlias']) { echo("<br />"); }
unset ($break);
if(!$dographs) {
if($port_details) {
$ipdata = mysql_query("SELECT * FROM `ipv4_addresses` WHERE `interface_id` = '" . $interface['interface_id'] . "'");
while($ip = mysql_fetch_Array($ipdata)) {
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=$ip[ipv4_address]')\">$ip[ipv4_address]/$ip[ipv4_prefixlen]</a>");
@@ -50,7 +40,8 @@
echo("$break <a class=interface-desc href=\"javascript:popUp('/netcmd.php?cmd=whois&query=".$ip6['ipv6_address']."')\">".Net_IPv6::compress($ip6['ipv6_address'])."/".$ip6['ipv6_prefixlen']."</a>");
$break = "<br />";
}
}
echo("</span>");
echo("</td><td width=100>");
@@ -61,23 +52,21 @@
echo("</td><td width=120>");
if($interface['ifOperStatus'] == "up") {
$in_perc = @round($interface['in_rate']/$interface['ifSpeed']*100);
$out_perc = @round($interface['in_rate']/$interface['ifSpeed']*100);
echo("<img src='images/16/arrow_left.png' align=absmiddle> <span style='color: " . percent_colour($in_perc) . "'>" .
formatRates($interface['in_rate']) . "</span><br />");
echo("<img align=absmiddle src='images/16/arrow_out.png'> <span style='color: " . percent_colour($out_perc) . "'>" .
formatRates($interface['out_rate']) . "</span>");
formatRates($interface['out_rate']) . "</span>");
}
echo("</td><td width=75Barbuda>");
if($ifSpeed && $ifSpeed != "") { echo("<span class=box-desc>$ifSpeed</span>"); }
echo("</td><td width=75>");
if($interface['ifSpeed'] && $interface['ifAlias'] != "") { echo("<span class=box-desc>".humanspeed($interface['ifSpeed'])."</span>"); }
echo("<br />");
# if($interface[ifDuplex] != unknown) { echo("<span class=box-desc>Duplex " . $interface['ifDuplex'] . "</span>"); } else { echo("-"); }
if($device['os'] == "IOS" || $device['os'] == "IOS XE") {
if($interface['ifTrunk']) {
echo("<span class=box-desc><span class=red>" . $interface['ifTrunk'] . "</span></span>");
} elseif ($interface['ifVlan']) {
@@ -86,22 +75,22 @@
$vrf = mysql_fetch_array(mysql_query("SELECT * FROM vrfs WHERE vrf_id = '".$interface['ifVrf']."'"));
echo("<span style='color: green;'>" . $vrf['vrf_name'] . "</span>");
}
}
echo("</td><td width=150>");
if($ifType && $ifType != "") { echo("<span class=box-desc>" . $ifType . "</span>"); } else { echo("-"); }
if($interface['ifType'] && $interface['ifType'] != "") { echo("<span class=box-desc>" . fixiftype($interface['ifType']) . "</span>"); } else { echo("-"); }
echo("<br />");
if($ifHardType && $ifHardType != "") { echo("<span class=box-desc>" . $ifHardType . "</span>"); } else { echo("-"); }
echo("</td><td width=150>");
if($interface['ifPhysAddress'] && $interface['ifPhysAddress'] != "") { echo("<span class=box-desc>" . $interface['ifPhysAddress'] . "</span>"); } else { echo("-"); }
echo("<br />");
if($interface['ifMtu'] && $interface['ifMtu'] != "") { echo("<span class=box-desc>MTU " . $interface['ifMtu'] . "</span>"); } else { echo("-"); }
}
#}
echo("</td>");
echo("<td width=375 valign=top class=interface-desc>");
if ( strpos($ifDescr, "oopback") === false && !$dographs) {
if ( strpos($interface['ifDescr'], "oopback") === false && !$graph_type) {
$link_query = mysql_query("select * from links AS L, interfaces AS I, devices AS D WHERE L.src_if = '$if_id' AND L.dst_if = I.interface_id AND I.device_id = D.device_id");
while($link = mysql_fetch_array($link_query)) {
# echo("<img src='images/16/connect.png' align=absmiddle alt='Directly Connected' /> " . generateiflink($link, makeshortif($link['ifDescr'])) . " on " . generatedevicelink($link, shorthost($link['hostname'])) . "</a><br />");
@@ -112,6 +101,8 @@ echo("</td>");
unset($br);
if($port_details) { ## Show which other devices are on the same subnet as this interface
$sql = "SELECT `ipv4_network_id` FROM `ipv4_addresses` WHERE `interface_id` = '".$interface['interface_id']."' AND `ipv4_address` NOT LIKE '127.%'";
$nets_query = mysql_query($sql);
while($net = mysql_fetch_array($nets_query)) {
@@ -129,7 +120,6 @@ echo("</td>");
$this_ifname = fixifName($new['ifDescr']);
$int_links[$this_ifid] = $this_ifid;
$int_links_v4[$this_ifid] = 1;
}
}
@@ -152,6 +142,7 @@ echo("</td>");
$int_links_v6[$this_ifid] = 1;
}
}
}
foreach($int_links as $int_link) {
@@ -187,7 +178,7 @@ echo("</td>");
echo("</td></tr>");
// If we're showing graphs, generate the graph and print the img tags
if($dographs && is_file($config['rrd_dir'] . "/" . $hostname . "/". $ifIndex . ".rrd")) {
if($graph_type && is_file($config['rrd_dir'] . "/" . $hostname . "/". $interface['ifIndex'] . ".rrd")) {
$type = $graph_type;
@@ -203,7 +194,7 @@ echo("</td>");
$yearly_traffic = "graph.php?if=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=210&height=100";
$yearly_url = "graph.php?if=$if_id&type=" . $graph_type . "&from=$year&to=$now&width=500&height=150";
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=3>");
echo("<tr style='background-color: $bg; padding: 5px;'><td colspan=7>");
echo("<a href='?page=interface&id=" . $interface['interface_id'] . "' onmouseover=\"return overlib('<img src=\'$daily_url\'>', LEFT".$config['overlib_defaults'].");\"
onmouseout=\"return nd();\"> <img src='$daily_traffic' border=0></a>");
+40 -21
View File
@@ -37,6 +37,40 @@ echo("<li class=" . $select['graphs'] . ">
</li>
");
$health = mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) +
mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) +
mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0);
if($health) {
echo("
<li class=" . $select['health'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/health/'>
<img src='images/16/chart_curve.png' align=absmiddle border=0> Health
</a>
</li>
");
}
if(is_dir($config['collectd_dir'] . "/" . $device['hostname'] ."/")) {
echo("
<li class=" . $select['collectd'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/collectd/'>
<img src='images/16/chart_line.png' align=absmiddle border=0> CollectD
</a>
</li>
");
}
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['ports'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/".$config['ports_page_default']."'>
<img src='images/16/connect.png' align=absmiddle border=0> Ports
</a>
</li>");
}
if(@mysql_result(mysql_query("select count(vlan_id) from vlans WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['vlans'] . ">
@@ -65,22 +99,17 @@ if($config['enable_bgp'] && $device['bgpLocalAs']) {
</li>");
}
if(@mysql_result(mysql_query("select count(interface_id) from interfaces WHERE device_id = '" . $device['device_id'] . "'"), 0) > '0') {
if(@mysql_result(mysql_query("SELECT count(*) FROM nagios_hosts WHERE address = '".$device['hostname']."'", $nagios_link), 0) > '0') {
echo("
<li class=" . $select['ifs'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/ports/'>
<img src='images/16/connect.png' align=absmiddle border=0> Ports
<li class=" . $select['nagios'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/nagios/'>
<img src='images/16/transmit_blue.png' align=absmiddle border=0> Nagios
</a>
</li>");
#<li class=" . $select['ifgraphs'] . ">
# <a href='".$config['base_url']."/device/" . $device['device_id'] . "/ifgraphs/'>
# <img src='images/16/port_graphs.png' align=absmiddle border=0> Port Graphs
# </a>
#</li>");
}
if($_SESSION[userlevel] >= "5") {
if($_SESSION[userlevel] >= "5" && mysql_result(mysql_query("SELECT count(*) FROM links AS L, interfaces AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.src_if"),0)) {
echo("
<li class=" . $select['map'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/map/'>
@@ -102,16 +131,6 @@ if($config['enable_inventory'] && @mysql_result(mysql_query("SELECT * FROM `entP
}
if(mysql_result(mysql_query("select count(temp_id) from temperature WHERE temp_host = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['temp'] . ">
<a href='".$config['base_url']."/device/" . $device['device_id'] . "/temp/'>
<img src='images/16/weather_sun.png' align=absmiddle border=0> Temps
</a>
</li>
");
}
if(mysql_result(mysql_query("select count(storage_id) from storage WHERE host_id = '" . $device['device_id'] . "'"), 0) > '0') {
echo("
<li class=" . $select['storage'] . ">
+6 -15
View File
@@ -7,6 +7,11 @@ while($device = mysql_fetch_array($device_query)) {
echo("<div style='clear: both;'>");
$os = strtolower(str_replace(" ", "_", $device['os']));
if(is_file($config['install_dir'] . "/html/pages/device/graphs/os-$os.inc.php")) {
include($config['install_dir'] . "/html/pages/device/graphs/os-$os.inc.php");
}
switch ($device['os']) {
case "JunOS":
echo("<div class=graphhead>Processor Utilisation</div>");
@@ -165,22 +170,8 @@ while($device = mysql_fetch_array($device_query)) {
break;
case "IOS":
case "IOS XE":
echo("<div class=graphhead>CPU Usage</div>");
$graph_type = "cpu"; include ("includes/print-device-graph.php");
echo("<br />");
echo("<div class=graphhead>Memory Usage</div>");
$graph_type = "mem"; include ("includes/print-device-graph.php");
echo("<br />");
if(mysql_result(mysql_query("SELECT count(*) FROM temperature WHERE temp_host = '" . $device['device_id'] . "'"),0)) {
echo("<div class=graphhead>Temperatures</div>");
$graph_type = "dev_temp"; include ("includes/print-device-graph.php");
echo("<br />");
}
include("graphs/netstats.inc.php");
include("graphs/uptime.inc.php");
break;
case "Snom":
case "Snom":
echo("<div class=graphhead>Calls</div>");
$graph_type = "calls"; include ("includes/print-device-graph.php");
}