move poller.php (inc os/system) to db* (and others, but poller is biggest change)

git-svn-id: http://www.observium.org/svn/observer/trunk@2298 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-05-13 11:42:26 +00:00
parent f355e33b64
commit bc0cdd2415
9 changed files with 45 additions and 41 deletions

View File

@@ -4,10 +4,7 @@ include("includes/defaults.inc.php");
include("config.php");
include("includes/functions.php");
$sql = "SELECT * FROM devices AS D, services AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC";
$query = mysql_query($sql);
while ($service = mysql_fetch_assoc($query))
foreach (dbFetchRows("SELECT * FROM `devices` AS D, `services` AS S WHERE S.device_id = D.device_id ORDER by D.device_id DESC") as $service)
{
if ($service['status'] = "1")
{
@@ -27,9 +24,12 @@ while ($service = mysql_fetch_assoc($query))
$check = "Error : Script not found ($checker_script)";
}
$update = array();
if ($service_status != $status)
{
$updated = ", `service_changed` = '" . time() . "' ";
$update['service_changed'] = time();
if ($service['sysContact']) { $email = $service['sysContact']; } else { $email = $config['email_default']; }
if ($status == "1")
{
@@ -45,8 +45,10 @@ while ($service = mysql_fetch_assoc($query))
}
} else { unset($updated); }
$update_sql = "UPDATE `services` SET `service_status` = '$status', `service_message` = '" . addslashes($check) . "', `service_checked` = '" . time() . "' $updated WHERE `service_id` = '" . $service['service_id']. "'";
mysql_query($update_sql);
$update = array_merge(array('service_status' => $status, 'service_message' => $check, 'service_checked' => time()), $update);
dbUpdate($update, 'services', '`service_id` = ?', array($service['service_id']));
unset($update);
} else {
$status = "0";
}
@@ -67,4 +69,4 @@ while ($service = mysql_fetch_assoc($query))
}
} # while
?>
?>