本文整理汇总了PHP中sys_linux函数的典型用法代码示例。如果您正苦于以下问题:PHP sys_linux函数的具体用法?PHP sys_linux怎么用?PHP sys_linux使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sys_linux函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: sys_linux
<a href="index.php">首页</a><font style='display: inline-block; width: 40px;'> </font>
<a href="rank.php">排名</a><font style='display: inline-block; width: 40px;'> </font>
<a href="status.php">状态</a><font style='display: inline-block; width: 40px;'> </font>
<?php
require_once "api.php";
if ($app->user->isLogin()) {
echo '<font style="display: inline-block; padding: 5px; border-radius: 5px;">' . $app->user->getUser() . '</font> => <a href="admin/status.php?action=logout&url=../index.php">登出</a>';
} else {
echo '<a href="admin/status.php?action=login&url=../index.php">登陆</a>';
}
?>
</div>
<?php
if (!strstr($_SERVER['SCRIPT_NAME'], 'index.php')) {
require_once 'linux.php';
$sys = sys_linux();
?>
<style>
.bar {
width: 500px;
height: 3px;
background-color: #00A;
border: 1px #0A0 solid;
border-radius: 1px;
}
.bar div {
width: <?php
echo $sys['memUsed'] * 500 / $sys['memTotal'] . 'px;';
?>
height: 3px;
background-color: #A00;
示例2: base64_encode
$url .= $data['iowait'] . '%25';
$url .= '&chtt=Core+' . $title;
return $api . base64_encode($url);
}
if ($_GET['act'] == "cpu_percentage") {
echo "<center><b><font face='Microsoft YaHei' color='#666666' size='3'>图片加载慢,请耐心等待!</font></b><br /><br />";
foreach ($data as $k => $v) {
echo '<img src="' . makeImageUrl($k, $v) . '" style="width:360px;height:240px;border: #CCCCCC 1px solid;background: #FFFFFF;margin:5px;padding:5px;" />';
}
echo "</center>";
exit;
}
// 根据不同系统取得CPU相关信息
switch (PHP_OS) {
case "Linux":
$sysReShow = false !== ($sysInfo = sys_linux()) ? "show" : "none";
break;
case "FreeBSD":
$sysReShow = false !== ($sysInfo = sys_freebsd()) ? "show" : "none";
break;
/*
case "WINNT":
$sysReShow = (false !== ($sysInfo = sys_windows()))?"show":"none";
break;
*/
/*
case "WINNT":
示例3: test_io
function test_io()
{
$fp = @fopen(PHPSELF, "r");
$timeStart = gettimeofday();
for ($i = 0; $i < 10000; $i++) {
@fread($fp, 10240);
@rewind($fp);
}
$timeEnd = gettimeofday();
@fclose($fp);
$time = ($timeEnd["usec"] - $timeStart["usec"]) / 1000000 + $timeEnd["sec"] - $timeStart["sec"];
$time = round($time, 3) . "秒";
return $time;
}
//linux系统探测
$sysInfo = sys_linux();
function sys_linux()
{
// CPU
if (false === ($str = @file("/proc/cpuinfo"))) {
return false;
}
$str = implode("", $str);
@preg_match_all("/processor\\s{0,}\\:+\\s{0,}([\\w\\s\\)\\(\\@.-]+)([\r\n]+)/s", $str, $processor);
@preg_match_all("/model\\s+name\\s{0,}\\:+\\s{0,}([\\w\\s\\)\\(\\@.-]+)([\r\n]+)/s", $str, $model);
if (count($model[0]) == 0) {
@preg_match_all("/Hardware\\s{0,}\\:+\\s{0,}([\\w\\s\\)\\(\\@.-]+)([\r\n]+)/s", $str, $model);
}
@preg_match_all("/cpu\\s+MHz\\s{0,}\\:+\\s{0,}([\\d\\.]+)[\r\n]+/", $str, $mhz);
if (count($mhz[0]) == 0) {
$values = @file("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq");