DPX-Infinity писал(а):не пашет в каком смысле? выдаёт ошибку, даёт неверные результаты, ничего не печатает? больше надо инфы, больше.
doliar писал(а)::shock:
А что разве не понятно что он не вытянул функцию: rfts
Поэтому у него и не работает
function rfts($strFileName, &$strRet, $intLines = 0, $intBytes = 4096, $booErrorRep = true) {
$strFile = "";
$intCurLine = 1;
if (file_exists($strFileName)) {
if ($fd = fopen($strFileName, 'r')) {
while (!feof($fd)) {
$strFile.= fgets($fd, $intBytes);
if ($intLines <= $intCurLine && $intLines != 0) {
break;
} else {
$intCurLine++;
}
}
fclose($fd);
$strRet = $strFile;
} else {
if ($booErrorRep) {
die('fopen(' . $strFileName . ') file can not read by phpsysinfo');
}
return false;
}
} else {
if ($booErrorRep) {
die('file_exists(' . $strFileName . ') the file does not exist on your machine');
}
return false;
}
return true;
}
function computer_load($avgs = false) {
if ($avgs) {
if (rfts('/proc/loadavg', $buf)) { // Изменения здесь
$result = preg_split("/\s/", $buf, 4);
// don't need the extra values, only first three
unset($result[3]);
} else {
$result = array('N.A.', 'N.A.', 'N.A.');
}
} else {
if (rfts('/proc/stat', $buf, 1)) {
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
// Find out the CPU load
// user + sys = load
// total = total
$load = $ab+$ac+$ad; // cpu.user + cpu.sys
$total = $ab+$ac+$ad+$ae; // cpu.total
// we need a second value, wait 1 second befor getting (< 1 second no good value will occour)
sleep(1);
rfts('/proc/stat', $buf, 1);
sscanf($buf, "%*s %Ld %Ld %Ld %Ld", $ab, $ac, $ad, $ae);
$load2 = $ab+$ac+$ad;
$total2 = $ab+$ac+$ad+$ae;
$result = (100*($load2-$load)) /($total2-$total); // И здесь
}
}
return $result;
}
error_reporting(E_ALL & ~E_NOTICE);
echo computer_load();
Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 22