more complete implementation of vm monitoring script