0
我想查找連接全部時間的服務器的負載平均值,我使用了下面的代碼,但是顯示正常運行時間時出現錯誤。請有人幫我解決這個問題...在php中使用ssh查找服務器的負載平均值
下面是代碼
<?php
$ip = '192.168.71.56';
$user = 'viju';
$pass = 'viju';
$connection = ssh2_connect($ip);
if($connection)
{
echo "connection successful";
}
else
{
echo "connection failed";
}
if(!(ssh2_auth_password($connection,$user,$pass)))
{
echo "Authentication Failed";
}
else
{
echo "Authentication Successful";
$shell = ssh2_exec($connection,"uptime");
if($shell)
{
$loadAvgString=explode('average:',$shell); //error occurs here
print_r($loadAvgString);
$loadAvgInAnArray=explode(',',$loadAvgString);
print_r($loadAvgInAnArray);
}
else
{
echo "No data fetched";
}
}
?>
不然我和警告以下輸出
連接成功驗證成功的警告:爆炸()預計參數2是字符串,資源在/var/www/extra/dis.php 26行Array([0] =>)
'system'和'server'有什麼區別? –