脚本宝典收集整理的这篇文章主要介绍了php – 通过SSH获取CPU使用率,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用CentOS 6.
我试过这段代码
@H_304_11@$connection = ssh2_connect("IP",PORT); ssh2_auth_password($connection,"root","PASS"); $stream = ssh2_exec($connection,"top"); $errorStream = ssh2_fetch_stream($stream,SSH2_STREAM_STDERR); // Enable blocking for both streams stream_set_blocking($errorStream,true); stream_set_blocking($stream,true); // whichever of the two below commands is listed First will receive ITs apPRopriate output. The second command receives nothing echo "Output: " . stream_get_contents($stream); echo "Error: " . stream_get_contents($errorStream); // Close the streams fclose($errorStream); fclose($stream);
但它每次都给我一个错误:输出:错误:未设置TERM环境变量.
我正在使用PHP.
以上是脚本宝典为你收集整理的php – 通过SSH获取CPU使用率全部内容,希望文章能够帮你解决php – 通过SSH获取CPU使用率所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。