make poller more fair. from lenwe.

git-svn-id: http://www.observium.org/svn/observer/trunk@2219 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2011-05-03 11:24:50 +00:00
parent f2890e2de0
commit f2eb8f0f24

View File

@ -41,7 +41,15 @@ elseif ($options['h'])
if (isset($options['i']) && $options['i'] && isset($options['n']))
{
$where = "AND MOD(device_id,".$options['i'].") = '" . $options['n'] . "'";
$where = true; // FIXME
$query = 'SELECT `device_id` FROM (SELECT @rownum :=0) r,
(
SELECT @rownum := @rownum +1 AS rownum, `device_id`
FROM `devices`
WHERE `disabled` = 0
ORDER BY `device_id` ASC
) temp
WHERE MOD(temp.rownum, '.$options['i'].') = '.$options['n'].';';
$doing = $options['n'] ."/".$options['i'];
}
@ -79,7 +87,11 @@ if (isset($options['d']))
echo("Starting polling run:\n\n");
$polled_devices = 0;
$device_query = mysql_query("SELECT `device_id` FROM `devices` WHERE `disabled` = 0 $where ORDER BY `device_id` ASC");
if(!isset($query))
$device_query = mysql_query("SELECT `device_id` FROM `devices` WHERE `disabled` = 0 $where ORDER BY `device_id` ASC");
else
$device_query = mysql_query($query);
print mysql_error();
while ($device = mysql_fetch_assoc($device_query))
{