fix voltages discovery if no voltages in database

git-svn-id: http://www.observium.org/svn/observer/trunk@817 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-02-11 11:45:28 +00:00
parent 0fd8f6ab18
commit 9530d66be7

View File

@@ -95,23 +95,25 @@ if ($device['os'] == "linux")
## Delete removed sensors
$sql = "SELECT * FROM voltage AS V, devices AS D WHERE V.volt_host = D.device_id AND D.device_id = '".$device['device_id']."'";
$query = mysql_query($sql);
while ($sensor = mysql_fetch_array($query))
if ($query = mysql_query($sql))
{
unset($exists);
$i = 0;
while ($i < count($volt_exists) && !$exists)
while ($sensor = mysql_fetch_array($query))
{
$thisvolt = $sensor['volt_host'] . " " . $sensor['volt_oid'];
if ($volt_exists[$i] == $thisvolt) { $exists = 1; }
$i++;
}
unset($exists);
$i = 0;
while ($i < count($volt_exists) && !$exists)
{
$thisvolt = $sensor['volt_host'] . " " . $sensor['volt_oid'];
if ($volt_exists[$i] == $thisvolt) { $exists = 1; }
$i++;
}
if (!$exists)
{
echo("-");
mysql_query("DELETE FROM voltage WHERE volt_id = '" . $sensor['volt_id'] . "'");
if (!$exists)
{
echo("-");
mysql_query("DELETE FROM voltage WHERE volt_id = '" . $sensor['volt_id'] . "'");
}
}
}