From 77d54687487e12e6aba4a86630be28f9169335b7 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Thu, 11 Feb 2010 11:46:52 +0000 Subject: [PATCH] fix temp discovery if no temps in database git-svn-id: http://www.observium.org/svn/observer/trunk@818 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/temperatures.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/includes/discovery/temperatures.php b/includes/discovery/temperatures.php index c3d5dff47..d1773d2d8 100755 --- a/includes/discovery/temperatures.php +++ b/includes/discovery/temperatures.php @@ -267,23 +267,25 @@ if ($device['os'] == "ios") ## Delete removed sensors $sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_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($temp_exists) && !$exists) + while ($sensor = mysql_fetch_array($query)) { - $thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid']; - if ($temp_exists[$i] == $thistemp) { $exists = 1; } - $i++; - } + unset($exists); + $i = 0; + while ($i < count($temp_exists) && !$exists) + { + $thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid']; + if ($temp_exists[$i] == $thistemp) { $exists = 1; } + $i++; + } - if (!$exists) - { - echo("-"); - mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); + if (!$exists) + { + echo("-"); + mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'"); + } } }