git-svn-id: http://www.observium.org/svn/observer/trunk@81 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-04-09 01:58:25 +00:00
parent ab1c68ddf5
commit f12224f78a
6 changed files with 17 additions and 11 deletions

View File

@ -7,7 +7,7 @@ include("config.php");
include("includes/functions.php"); include("includes/functions.php");
$query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D $query = "SELECT *,A.id as id FROM ipaddr AS A, interfaces as I, devices as D
WHERE A.interface_id = I.interface_id AND I.device_id = D.id AND D.status = '1'"; WHERE A.interface_id = I.interface_id AND I.device_id = D.device_id AND D.status = '1'";
$data = mysql_query($query); $data = mysql_query($query);
while($row = mysql_fetch_array($data)) { while($row = mysql_fetch_array($data)) {
@ -23,7 +23,7 @@ while($row = mysql_fetch_array($data)) {
} }
$query = "SELECT * FROM interfaces AS I, devices as D $query = "SELECT * FROM interfaces AS I, devices as D
WHERE I.host = D.id AND D.status = '1'"; WHERE I.device_id = D.device_id AND D.status = '1'";
$data = mysql_query($query); $data = mysql_query($query);
while($row = mysql_fetch_array($data)) { while($row = mysql_fetch_array($data)) {
$index = $row[ifIndex]; $index = $row[ifIndex];
@ -31,8 +31,12 @@ while($row = mysql_fetch_array($data)) {
$community = $row['community']; $community = $row['community'];
$response = trim(`snmpget -v2c -Osq -c $community $hostname ifIndex.$index | cut -d " " -f 2`); $response = trim(`snmpget -v2c -Osq -c $community $hostname ifIndex.$index | cut -d " " -f 2`);
if($response != $index) { if($response != $index) {
mysql_query("delete from interfaces where id = '" . $row['interface_id'] . "'"); mysql_query("DELETE from interfaces where interface_id = '" . $row['interface_id'] . "'");
echo("Deleted $row[ifDescr] from $hostname\n"); mysql_query("DELETE from `adjacencies` WHERE `interface_id` = '" . $row['interface_id'] . "'");
mysql_query("DELETE from `links` WHERE `src_if` = '" . $row['interface_id'] . "'");
mysql_query("DELETE from `links` WHERE `dst_if` = '" . $row['interface_id'] . "'");
mysql_query("DELETE from `ipaddr` WHERE `interface_id` = '" . $row['interface_id'] . "'");
echo("Removed interface " . $row['ifDescr'] . " from " . $row['hostname'] . "<br />");
} }
} }
@ -41,7 +45,7 @@ $interface_query = mysql_query("SELECT interface_id,device_id FROM `interfaces`"
while ($interface = mysql_fetch_array($interface_query)) { while ($interface = mysql_fetch_array($interface_query)) {
$device_id = $interface['device_id']; $device_id = $interface['device_id'];
$interface_id = $interface['interface_id']; $interface_id = $interface['interface_id'];
if(mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `id` = '$device_id'"), 0) == '0') { if(mysql_result(mysql_query("SELECT COUNT(*) FROM `devices` WHERE `device_id` = '$device_id'"), 0) == '0') {
mysql_query("delete from interfaces where `interface_id` = '$interface_id'"); mysql_query("delete from interfaces where `interface_id` = '$interface_id'");
echo("Deleting if $interface_id \n"); echo("Deleting if $interface_id \n");
} }

View File

@ -8,13 +8,13 @@
$type = strtolower($device['os']); $type = strtolower($device['os']);
unset($image); unset($image);
$image = getImage($device[id]); $image = getImage($device['device_id']);
echo(" echo("
<tr > <tr >
<td width='40' align=center valign=middle>$image</td> <td width='40' align=center valign=middle>$image</td>
<td valign=middle><span style='font-weight: bold; font-size: 20px;'>" . generatedevicelink($device) . "</span> <td valign=middle><span style='font-weight: bold; font-size: 20px;'>" . generatedevicelink($device) . "</span>
<br />$device[purpose]</td> <br />" . $device['purpose'] . "</td>
<td></td> <td></td>
</tr>"); </tr>");

View File

@ -6,6 +6,7 @@
$class = "list-device-ignored"; $class = "list-device-ignored";
if ($device['status'] == '1') { $class = "list-device-ignored-up"; } if ($device['status'] == '1') { $class = "list-device-ignored-up"; }
} }
$type = strtolower($device['os']); $type = strtolower($device['os']);
unset($image); unset($image);

View File

@ -72,7 +72,7 @@ echo("
$sql = "SELECT * FROM interfaces WHERE `device_id` = '$id'"; $sql = "SELECT * FROM interfaces WHERE `device_id` = '$id'";
$query = mysql_query($sql); $query = mysql_query($sql);
while($data = mysql_fetch_array($query)) { while($data = mysql_fetch_array($query)) {
echo("$ifsep" . generateiflink($data, makeshortif(strtolower($data['if'])))); echo("$ifsep" . generateiflink($data, makeshortif(strtolower($data['ifDescr']))));
$ifsep = ", "; $ifsep = ", ";
} }
unset($ifsep); unset($ifsep);

View File

@ -13,7 +13,8 @@ $device_query = mysql_query($sql);
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>"); echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
while($device = mysql_fetch_array($device_query)) { while($device = mysql_fetch_array($device_query)) {
$device[uptime] = @mysql_result(mysql_query("SELECT device_uptime FROM device_uptime WHERE device_id = '" . $device[id] ."'" ), 0); $device['uptime'] = mysql_result(mysql_query("SELECT `attrib_value` FROM `devices_attribs` WHERE `device_id` = '" . $device['device_id'] ."' AND `attrib_type` = 'uptime'"), 0);
include("includes/hostbox.inc"); include("includes/hostbox.inc");
} }

View File

@ -3,7 +3,7 @@
$interface_query = mysql_query("select * from interfaces WHERE interface_id = '$_GET[id]'"); $interface_query = mysql_query("select * from interfaces WHERE interface_id = '$_GET[id]'");
$interface = mysql_fetch_array($interface_query); $interface = mysql_fetch_array($interface_query);
$device_query = mysql_query("select * from devices where id = '$interface[host]'"); $device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $interface['device_id'] . "'");
$device = mysql_fetch_array($device_query); $device = mysql_fetch_array($device_query);
$hostname = $device['hostname']; $hostname = $device['hostname'];
@ -24,7 +24,7 @@ $interface = mysql_fetch_array($interface_query);
$i = 1; $i = 1;
$inf = fixifName($ifname); $inf = fixifName($ifname);
# $bg="#ffffff"; $bg="#ffffff";
echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>"); echo("<table cellpadding=7 cellspacing=0 class=devicetable width=100%>");
include("includes/device-header.inc"); include("includes/device-header.inc");
echo("</table>"); echo("</table>");