1)); try { $mongo->executeCommand('admin', $command); } catch (\MongoDB\Driver\Exception\ConnectionTimeoutException $e) { echo 'FAIL - ' . $e; exit(1); } // retrieve server list $servers = $mongo->getServers(); if (!isset($servers[0])) { echo 'FAIL - Failed to connect to MongoDB host on '.$MY_HOST.' (No host info available)'; exit(1); } if ($servers[0]->getHost() != $MY_HOST) { echo 'FAIL - Failed to connect to MongoDB host on '.$MY_HOST.' (servername does not match: '.$servers[0]->getHost().')'; exit(1); } echo 'OK';