");
echo("
Change Password
");
diff --git a/includes/common.php b/includes/common.php
index 7c17d00621..40fae3b697 100644
--- a/includes/common.php
+++ b/includes/common.php
@@ -2,6 +2,12 @@
## Common Functions
+function getifhost($id) {
+ $sql = mysql_query("SELECT `device_id` from `interfaces` WHERE `interface_id` = '$id'");
+ $result = @mysql_result($sql, 0);
+ return $result;
+}
+
function gethostbyid($id) {
$sql = mysql_query("SELECT `hostname` FROM `devices` WHERE `device_id` = '$id'");
$result = @mysql_result($sql, 0);
diff --git a/includes/discovery/cisco-physical.php b/includes/discovery/cisco-physical.php
index e492c99f55..02130a4e16 100755
--- a/includes/discovery/cisco-physical.php
+++ b/includes/discovery/cisco-physical.php
@@ -13,7 +13,7 @@
foreach(explode("\n", $ents) as $entPhysicalIndex) {
- $ent_data = $config['snmpget'] . " -m ENTITY-MIB -Ovqs -";
+ $ent_data = $config['snmpget'] . " -m ENTITY-MIB:IF-MIB -Ovqs -";
$ent_data .= $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] .":".$device['port'];
$ent_data .= " entPhysicalDescr." . $entPhysicalIndex;
$ent_data .= " entPhysicalContainedIn." . $entPhysicalIndex;
@@ -28,7 +28,8 @@
list($entPhysicalDescr,$entPhysicalContainedIn,$entPhysicalClass,$entPhysicalName,$entPhysicalSerialNum,$entPhysicalModelName,$entPhysicalMfgName,$entPhysicalVendorType,$entPhysicalParentRelPos, $ifIndex) = explode("\n", `$ent_data`);
- if(strpos($ifIndex, "o") || $ifIndex == "") { unset($ifIndex); }
+ if(!strpos($ifIndex, "fIndex") || $ifIndex == "") { unset($ifIndex); }
+ list(,$ifIndex) = explode(".", $ifIndex);
$entPhysicalModelName = trim($entPhysicalModelName);
$entPhysicalSerialNum = trim($entPhysicalSerialNum);
@@ -39,12 +40,17 @@
$entPhysicalModelName = $entPhysicalVendorTypes[$entPhysicalVendorType];
}
- if(mysql_result(mysql_query("SELECT COUNT(*) FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0)) {
-
- ### TO DO : WRITE CODE FOR UPDATES!
+ $entPhysical_id = @mysql_result(mysql_query("SELECT entPhysical_id FROM `entPhysical` WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'"),0);
+ if($entPhysical_id) {
+ $sql = "UPDATE `entPhysical` SET `ifIndex` = '$ifIndex'";
+ $sql .= ", entPhysicalIndex = '$entPhysicalIndex', entPhysicalDescr = '$entPhysicalDescr', entPhysicalClass = '$entPhysicalClass', entPhysicalName = '$entPhysicalName'";
+ $sql .= ", entPhysicalModelName = '$entPhysicalModelName', entPhysicalSerialNum = '$entPhysicalSerialNum', entPhysicalContainedIn = '$entPhysicalContainedIn'";
+ $sql .= ", entPhysicalMfgName = '$entPhysicalMfgName', entPhysicalParentRelPos = '$entPhysicalParentRelPos', entPhysicalVendorType = '$entPhysicalVendorType'";
+ $sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
+
+ mysql_query($sql);
echo(".");
-
} else {
$sql = "INSERT INTO `entPhysical` ( `device_id` , `entPhysicalIndex` , `entPhysicalDescr` , `entPhysicalClass` , `entPhysicalName` , `entPhysicalModelName` , `entPhysicalSerialNum` , `entPhysicalContainedIn`, `entPhysicalMfgName`, `entPhysicalParentRelPos`, `entPhysicalVendorType`, `ifIndex` ) ";
$sql .= "VALUES ( '" . $device['device_id'] . "', '$entPhysicalIndex', '$entPhysicalDescr', '$entPhysicalClass', '$entPhysicalName', '$entPhysicalModelName', '$entPhysicalSerialNum', '$entPhysicalContainedIn', '$entPhysicalMfgName','$entPhysicalParentRelPos' , '$entPhysicalVendorType', '$ifIndex')";
@@ -55,17 +61,23 @@
if($entPhysicalClass == "sensor") {
$sensor_cmd = $config['snmpget'] . " -m CISCO-ENTITY-SENSOR-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'];
$sensor_cmd .= " entSensorType.$entPhysicalIndex entSensorScale.$entPhysicalIndex entSensorPrecision.$entPhysicalIndex";
- $sensor_cmd .= " entSensorMeasuredEntity.$entPhysicalIndex";
-
+ $sensor_cmd .= " entSensorValueUpdateRate.$entPhysicalIndex entSensorMeasuredEntity.$entPhysicalIndex";
$sensor_data = shell_exec($sensor_cmd);
-
list($entSensorType,$entSensorScale,$entSensorPrecision,$entSensorValueUpdateRate,$entSensorMeasuredEntity) = explode("\n", $sensor_data);
+ if($entSensorMeasuredEntity) {
+ echo("M:$entSensorMeasuredEntity");
+ }
+ if($config['allow_entity_sensor'][$entSensorType]) {
+ $sql = "UPDATE `entPhysical` SET entSensorType = '$entSensorType', entSensorScale = '$entSensorScale', entSensorPrecision = '$entSensorPrecision', ";
+ $sql .= " entSensorMeasuredEntity = '$entSensorMeasuredEntity'";
+ $sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
+ } else {
+ echo("!$entSensorType");
+ $sql = "UPDATE `entPhysical` SET entSensorType = '', entSensorScale = '', entSensorPrecision = '', entSensorMeasuredEntity = ''";
+ $sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
+ }
- $sql = "UPDATE `entPhysical` SET entSensorType = '$entSensorType', entSensorScale = '$entSensorScale', entSensorPrecision = '$entSensorPrecision', ";
- $sql .= " entSensorMeasuredEntity = '$entSensorMeasuredEntity'";
- $sql .= " WHERE device_id = '".$device['device_id']."' AND entPhysicalIndex = '$entPhysicalIndex'";
mysql_query($sql);
-
}
$valid[$entPhysicalIndex] = 1;
}
@@ -74,12 +86,11 @@
$sql = "SELECT * FROM `entPhysical` WHERE `device_id` = '".$device['device_id']."'";
$query = mysql_query($sql);
-
while ($test = mysql_fetch_array($query)) {
- $id = $test['entPhysical_id'];
+ $id = $test['entPhysicalIndex'];
if(!$valid[$id]) {
echo("-");
-# mysql_query("DELETE FROM `entPhysical` WHERE entPhysical_id = '".$test['entPhysical_id']."'");
+ mysql_query("DELETE FROM `entPhysical` WHERE entPhysical_id = '".$test['entPhysical_id']."'");
}
}
diff --git a/includes/discovery/storage.php b/includes/discovery/storage.php
index 49eb5c3ef6..9dfb02c2b8 100755
--- a/includes/discovery/storage.php
+++ b/includes/discovery/storage.php
@@ -10,9 +10,9 @@
foreach(explode("\n", $oids) as $data) {
$data = trim($data);
list($oid,$hrStorageIndex) = explode(" ", $data);
- $temp = shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid");
+ $temp = shell_exec($config['snmpget'] . " -m HOST-RESOURCES-MIB:HOST-RESOURCES-TYPES -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid");
$temp = trim($temp);
- list($descr, $units, $size, $type) = explode("\n", $temp);
+ list($descr, $units, $size, $fstype) = explode("\n", $temp);
list($units) = explode(" ", $units);
$allow = 1;
@@ -23,7 +23,9 @@
}
}
- if(strstr($type, "FixedDisk") && $size > '0' && $allow) {
+ echo("$fstype\n");
+
+ if(strstr($fstype, "FixedDisk") && $size > '0' && $allow) {
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '".$device['device_id']."'"),0) == '0') {
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) ";
$query .= "values ('".$device['device_id']."', '$hrStorageIndex', '$descr', '$size', '$units')";
diff --git a/includes/functions.php b/includes/functions.php
index a866a0ce70..be87a847c0 100755
--- a/includes/functions.php
+++ b/includes/functions.php
@@ -634,12 +634,6 @@ function hoststatus($id) {
return $result;
}
-function getifhost($id) {
- $sql = mysql_query("SELECT `device_id` from `interfaces` WHERE `interface_id` = '$id'");
- $result = @mysql_result($sql, 0);
- return $result;
-}
-
function match_network ($nets, $ip, $first=false) {
$return = false;
if (!is_array ($nets)) $nets = array ($nets);
diff --git a/test-discovery.php b/test-discovery.php
index c5a97de7e5..0fbf4b66d0 100755
--- a/test-discovery.php
+++ b/test-discovery.php
@@ -42,7 +42,7 @@ $devices_polled = 0;
$device_query = mysql_query("SELECT * FROM `devices` WHERE status = '1' $where ORDER BY device_id ASC");
while ($device = mysql_fetch_array($device_query)) {
- echo("\n" . $device['hostname'] ."\n");
+ echo("includes/discovery/".$type.".php");
include("includes/discovery/".$type.".php");