The solution to this issue can easily be solved with an app called Pusher, which is a hosted publish/subscribe API. In a nut shell, Pusher provides two libraries, one for the client (the subscriber) and one for the server (the publisher).
The publisher can be a single script on your server (there are quite a few languages available) set to run at whatever interval you desire. Each time it runs it will connect to a channel and publish to it whatever data it generates. The client is created via a bit of JavaScript in your web app, and whenever a user navigates to your page, the client subscribes to the same channel your server script is publishing to and receives the data as soon as it becomes available and then can manipulate it however you see fit.
The server:
#!/usr/bin/php
<?php
require('Pusher.php');
$dbh = new PDO("mysql:host=$db_host;dbname=$db_name", $db_user, $db_pass);
foreach($dbh->query('SELECT hostname FROM systems WHERE status = 0') as $row) {
$systems[] = $row['hostname'];
}
$pusher = new Pusher($pusher_key, $pusher_secret, $pusher_app_id);
$pusher->trigger(
'my-channel',
'my-event',
array('message' => implode('<br />', $systems))
);
The client:
<!DOCTYPE html>
<html>
<head>
<title>Pusher Test</title>
<script src="http://code.jquery.com/jquery.min.js" type="text/javascript"></script>
<script src="http://js.pusher.com/1.12/pusher.min.js" type="text/javascript"></script>
<script type="text/javascript">
var pusher = new Pusher(key);
var channel = pusher.subscribe('my-channel');
channel.bind('my-event', function(data) {
$('#systems').html(data.message);
});
</script>
</head>
<body>
<div id="systems"></div>
</body
</html>
So, in this case regardless of how many clients access the page there is only one database query running, and at each interval all the subscribed clients will be updated with the new data.
There is also an open source server implementation of the Pusher protocol written in Ruby called Slanger.