Dear all
I would like to check the agent status of a VM using a PHP script. I have created this as follows:
Unfortunately, it is not clear to me how to get the return value. If the agent is running nothing is output, if it is not running the message "VM XXX is not running" appears.
Can someone help me?
Thank you and happy new year!
I would like to check the agent status of a VM using a PHP script. I have created this as follows:
PHP:
$connection = ssh2_connect($row['Ip'], $row['Port']);
ssh2_auth_password($connection, $row['User'], $row['Password']);
$stream = ssh2_exec($connection, "qm agent ".$row["VmID"]." ping");
stream_set_blocking($stream, true);
$stream_out = ssh2_fetch_stream($stream, SSH2_STREAM_STDIO);
$sshReturn = trim(stream_get_contents($stream_out));
print strlen($sshReturn) == 0 ? 'OK' : 'NOK';
Unfortunately, it is not clear to me how to get the return value. If the agent is running nothing is output, if it is not running the message "VM XXX is not running" appears.
Can someone help me?
Thank you and happy new year!