What I’d change in your code
– a php file that runs as a service and polls the data from the OS and saves it to memcache
– the webinterface polls the memcache information
– save a serialized object in memcache and just deserialize it when you read the data
This way a laggy network connections or other issues won’t trigger errors.
All the exchanges happen in ram – fast ui updates.