当前位置: 首页>>代码示例>>PHP>>正文


PHP do_command函数代码示例

本文整理汇总了PHP中do_command函数的典型用法代码示例。如果您正苦于以下问题:PHP do_command函数的具体用法?PHP do_command怎么用?PHP do_command使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了do_command函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: sys_freebsd

 public static function sys_freebsd()
 {
     //CPU
     if (false === ($res['cpu']['num'] = get_key("hw.ncpu"))) {
         return false;
     }
     $res['cpu']['detail'] = get_key("hw.model");
     //LOAD AVG
     if (false === ($res['loadAvg'] = get_key("vm.loadavg"))) {
         return false;
     }
     $res['loadAvg'] = str_replace("{", "", $res['loadAvg']);
     $res['loadAvg'] = str_replace("}", "", $res['loadAvg']);
     //UPTIME
     if (false === ($buf = get_key("kern.boottime"))) {
         return false;
     }
     $buf = explode(' ', $buf);
     $sys_ticks = time() - intval($buf[3]);
     $min = $sys_ticks / 60;
     $hours = $min / 60;
     $days = floor($hours / 24);
     $hours = floor($hours - $days * 24);
     $min = floor($min - $days * 60 * 24 - $hours * 60);
     if ($days !== 0) {
         $res['uptime'] = $days . "天";
     }
     if ($hours !== 0) {
         $res['uptime'] .= $hours . "小时";
     }
     $res['uptime'] .= $min . "分钟";
     //MEMORY
     if (false === ($buf = get_key("hw.physmem"))) {
         return false;
     }
     $res['memTotal'] = round($buf / 1024 / 1024, 2);
     $buf = explode("\n", do_command("vmstat", ""));
     $buf = explode(" ", trim($buf[2]));
     $res['memFree'] = round($buf[5] / 1024, 2);
     $res['memUsed'] = $res['memTotal'] - $res['memFree'];
     $res['memPercent'] = floatval($res['memTotal']) != 0 ? round($res['memUsed'] / $res['memTotal'] * 100, 2) : 0;
     $buf = explode("\n", do_command("swapinfo", "-k"));
     $buf = $buf[1];
     preg_match_all("/([0-9]+)\\s+([0-9]+)\\s+([0-9]+)/", $buf, $bufArr);
     $res['swapTotal'] = round($bufArr[1][0] / 1024, 2);
     $res['swapUsed'] = round($bufArr[2][0] / 1024, 2);
     $res['swapFree'] = round($bufArr[3][0] / 1024, 2);
     $res['swapPercent'] = floatval($res['swapTotal']) != 0 ? round($res['swapUsed'] / $res['swapTotal'] * 100, 2) : 0;
     return $res;
 }
开发者ID:Zniel,项目名称:fl_crtlpanel_self_dev,代码行数:50,代码来源:mod_login.php

示例2: array_slice

if ($argcount > $cmdidx) {
    // The command is the first thing after the options
    $args = array_slice($argv, $cmdidx);
    do_command($args);
}
/*
 * Start running the commands if we are in interactive mode
 -------------------------------------------------------------------- */
if ($interactive) {
    $cmd = '';
    while ($cmd != 'exit') {
        $args = do_readline();
        if ($args === null) {
            continue;
        }
        do_command($args);
    }
}
/*
 * Start reading lines from the command line and adding them to
 * our history 
 * -------------------------------------------------------------------- */
function do_readline($prompt = 'command > ')
{
    if (function_exists('readline')) {
        $cmd = readline($prompt);
        if ($cmd === '') {
            return null;
        }
        readline_add_history($cmd);
    } else {
开发者ID:rustyeddy,项目名称:sandbox,代码行数:31,代码来源:mwp.php

示例3: get_key

function get_key($keyName)
{
    return do_command('sysctl', "-n {$keyName}");
}
开发者ID:php360,项目名称:ltnmp,代码行数:4,代码来源:p.php

示例4: sys_freebsd

 public function sys_freebsd()
 {
     //freeBSD系统探测
     $res['cpu']['num'] = do_command('sysctl', 'hw.ncpu');
     //CPU
     $res['cpu']['model'] = do_command('sysctl', 'hw.model');
     $res['loadAvg'] = do_command('sysctl', 'vm.loadavg');
     //Load AVG  系统负载
     //uptime
     $buf = do_command('sysctl', 'kern.boottime');
     $buf = explode(' ', $buf);
     $sys_ticks = time() - intval($buf[3]);
     $min = $sys_ticks / 60;
     $hours = $min / 60;
     $days = floor($hours / 24);
     $hours = floor($hours - $days * 24);
     $min = floor($min - $days * 60 * 24 - $hours * 60);
     $res['uptime'] = $days . '天' . $hours . '小时' . $min . '分钟';
     //内存
     $buf = do_command('sysctl', 'hw.physmem');
     $resmem['memTotal'] = round($buf / 1024 / 1024, 2);
     $str = do_command('sysctl', 'vm.vmtotal');
     preg_match_all("/\nVirtual Memory[\\:\\s]*\\(Total[\\:\\s]*([\\d]+)K[\\,\\s]*Active[\\:\\s]*([\\d]+)K\\)\n/i", $str, $buff, PREG_SET_ORDER);
     preg_match_all("/\nReal Memory[\\:\\s]*\\(Total[\\:\\s]*([\\d]+)K[\\,\\s]*Active[\\:\\s]*([\\d]+)K\\)\n/i", $str, $buf, PREG_SET_ORDER);
     $resmem['memRealUsed'] = round($buf[0][2] / 1024, 2);
     $resmem['memCached'] = round($buff[0][2] / 1024, 2);
     $resmem['memUsed'] = round($buf[0][1] / 1024, 2) + $resmem['memCached'];
     $resmem['memFree'] = $resmem['memTotal'] - $resmem['memUsed'];
     $resmem['memPercent'] = floatval($resmem['memTotal']) != 0 ? round($resmem['memUsed'] / $resmem['memTotal'] * 100, 2) : 0;
     $resmem['memRealPercent'] = floatval($resmem['memTotal']) != 0 ? round($resmem['memRealUsed'] / $resmem['memTotal'] * 100, 2) : 0;
     $resmem = $this->formatmem($resmem);
     $res = array_merge($res, $resmem);
     return $res;
 }
开发者ID:sunxfancy,项目名称:Questionnaire,代码行数:34,代码来源:check.php


注:本文中的do_command函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。