git-svn-id: http://www.observium.org/svn/observer/trunk@98 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2007-05-20 19:21:35 +00:00
parent edb99764fb
commit ad4160c2ea
16 changed files with 275 additions and 96 deletions
+32 -5
View File
@@ -3,9 +3,9 @@
include("config.php");
include("includes/functions.php");
$device_query = mysql_query("SELECT * FROM `devices` WHERE os = 'Linux' OR os = 'FreeBSD' OR os = 'NetBSD' OR os = 'OpenBSD' OR os = 'DragonFly' AND monowall = '0' AND status = '1'");
$device_query = mysql_query("SELECT * FROM `devices` WHERE os = 'Linux' OR os = 'FreeBSD' OR os = 'NetBSD' OR os = 'OpenBSD' OR os = 'DragonFly' AND status = '1'");
while ($device = mysql_fetch_array($device_query)) {
$id = $device['id'];
$id = $device['device_id'];
$hostname = $device['hostname'];
$community = $device['community'];
echo("\n***$hostname***\n");
@@ -13,19 +13,46 @@ while ($device = mysql_fetch_array($device_query)) {
$oids = trim($oids);
foreach(explode("\n", $oids) as $data) {
$data = trim($data);
list($oid,$ifIndex) = explode(" ", $data);
list($oid,$hrStorageIndex) = explode(" ", $data);
$temp = `snmpget -O qv -v2c -c $community $hostname hrStorageDescr.$oid hrStorageAllocationUnits.$oid hrStorageSize.$oid hrStorageType.$oid`;
$temp = trim($temp);
list($descr, $units, $size, $type) = explode("\n", $temp);
list($units) = explode(" ", $units);
if(strstr($type, "FixedDisk") && $size > '0') {
echo("$oid,$descr,$units,$size\n");
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$ifIndex' AND host_id = '$id'"),0) == '0') {
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) values ('$id', '$ifIndex', '$descr', '$size', '$units')";
if(mysql_result(mysql_query("SELECT count(storage_id) FROM `storage` WHERE hrStorageIndex = '$hrStorageIndex' AND host_id = '$id'"),0) == '0') {
$query = "INSERT INTO storage (`host_id`, `hrStorageIndex`, `hrStorageDescr`,`hrStorageSize`,`hrStorageAllocationUnits`) values ('$id', '$hrStorageIndex', '$descr', '$size', '$units')";
echo("$query \n");
mysql_query($query);
}
$storage_exists[] = "$id $hrStorageIndex";
}
}
}
$sql = "SELECT * FROM storage";
$query = mysql_query($sql);
while ($store = mysql_fetch_array($query)) {
unset($exists);
$i = 0;
while ($i < count($storage_exists) && !$exists) {
$thisstore = $store['host_id'] . " " . $store['hrStorageIndex'];
if ($storage_exists[$i] == $thisstore) { $exists = 1; echo("Match!"); }
$i++;
echo("$storage_exists[$i] == $thisstore \n");
}
if(!$exists) {
echo("Deleting...\n");
# mysql_query("DELETE FROM storage WHERE storage_id = '" . $store['storage_id'] . "'");
}
}
?>