Chinaunix首页 | 论坛 | 博客
  • 博客访问: 371578
  • 博文数量: 89
  • 博客积分: 3178
  • 博客等级: 中校
  • 技术积分: 965
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-09 15:31
文章分类

全部博文(89)

文章存档

2013年(10)

2012年(33)

2011年(41)

2008年(5)

分类: LINUX

2012-04-06 10:44:47

脚本程序:

点击(此处)折叠或打开

  1. <?php
  2. /*
  3.     +--------------------------------------------------------------------------
  4.     | iProber v0.024
  5.     | ========================================
  6.     | by Tahiti
  7.     | dEpoch Studio
  8.     |
  9.     | ========================================
  10.     | Web:
  11.     | Last Updated: 29th April 2006
  12.     | Email: depoch@gmail.com
  13.     +---------------------------------------------------------------------------
  14.     |
  15.     | > PHP PROBER
  16.     | > Script written by Tahiti
  17.     | > Date started: 27th June 2004
  18.     |
  19.     +--------------------------------------------------------------------------

  20.     
  21. /* Functions in this file */
  22. /**************************/

  23.     // bar($percent)
  24.     // find_command($commandName)
  25.     // getcon($varName)
  26.     // get_key($keyName)
  27.     // isfun($funName)
  28.     // sys_freebsd()
  29.     // sys_linux()
  30.     // test_float()
  31.     // test_int()
  32.     // test_io()
  33.     // do_command($commandName, $args)

  34.     header("content-Type: text/html; charset=utf-8");
  35.     error_reporting(E_ERROR | E_WARNING | E_PARSE);
  36.     ob_start();
  37.      
  38.     $valInt = (false == empty($_POST['pInt']))?$_POST['pInt']:"未测试";
  39.     $valFloat = (false == empty($_POST['pFloat']))?$_POST['pFloat']:"未测试";
  40.     $valIo = (false == empty($_POST['pIo']))?$_POST['pIo']:"未测试";
  41.     $mysqlReShow = "none";
  42.     $mailReShow = "none";
  43.     $funReShow = "none";
  44.     $opReShow = "none";
  45.     $sysReShow = "none";
  46.      
  47.     define("YES", "YES");
  48.     define("NO", "NO");
  49.     define("ICON", "2 ");
  50.     $phpSelf = $_SERVER[PHP_SELF] ? $_SERVER[PHP_SELF] : $_SERVER[SCRIPT_NAME];
  51.     define("PHPSELF", preg_replace("/(.{0,}?\/+)/", "", $phpSelf));
  52.      
  53.     if ($_GET['act'] == "phpinfo")
  54.     {
  55.         phpinfo();
  56.         exit();
  57.     }
  58.     elseif($_POST['act'] == "TEST_1")
  59.     {
  60.         $valInt = test_int();
  61.     }
  62.     elseif($_POST['act'] == "TEST_2")
  63.     {
  64.         $valFloat = test_float();
  65.     }
  66.     elseif($_POST['act'] == "TEST_3")
  67.     {
  68.         $valIo = test_io();
  69.     }
  70.     elseif($_POST['act'] == "CONNECT")
  71.     {
  72.         $mysqlReShow = "show";
  73.         $mysqlRe = "MYSQL连接测试结果:";
  74.         $mysqlRe .= (false !== @mysql_connect($_POST['mysqlHost'], $_POST['mysqlUser'], $_POST['mysqlPassword']))?"MYSQL服务器连接正常, ":
  75.         "MYSQL服务器连接失败, ";
  76.         $mysqlRe .= "数据库 ".$_POST['mysqlDb']." ";
  77.         $mysqlRe .= (false != @mysql_select_db($_POST['mysqlDb']))?"连接正常":
  78.         "连接失败";
  79.     }
  80.     elseif($_POST['act'] == "SENDMAIL")
  81.     {
  82.         $mailReShow = "show";
  83.         $mailRe = "MAIL邮件发送测试结果:发送";
  84.         $mailRe .= (false !== @mail($_POST["mailReceiver"], "MAIL SERVER TEST", "This email is sent by iProber.\r\n\r\ndEpoch Studio\r\n"))?"完成":"失败";
  85.     }
  86.     elseif($_POST['act'] == "FUNCTION_CHECK")
  87.     {
  88.         $funReShow = "show";
  89.         $funRe = "函数 ".$_POST['funName']." 支持状况检测结果:".isfun($_POST['funName']);
  90.     }
  91.     elseif($_POST['act'] == "CONFIGURATION_CHECK")
  92.     {
  93.         $opReShow = "show";
  94.         $opRe = "配置参数 ".$_POST['opName']." 检测结果:".getcon($_POST['opName']);
  95.     }
  96.      
  97.      
  98.     // 系统参数
  99.      
  100.      
  101.     switch (PHP_OS)
  102.     {
  103.         case "Linux":
  104.         $sysReShow = (false !== ($sysInfo = sys_linux()))?"show":"none";
  105.         break;
  106.         case "FreeBSD":
  107.         $sysReShow = (false !== ($sysInfo = sys_freebsd()))?"show":"none";
  108.         break;
  109.         default:
  110.         break;
  111.     }
  112.      
  113. /*========================================================================*/
  114. ?>
  115. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
  116. <html xmlns="">
  117. <head>
  118. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  119. <title>PHP探针</title>
  120. <meta name="keywords" content="php探针,探针程序,php探针程序,探针" />
  121. <style type="text/css">

  122. </style>
  123. </head>
  124. <body>
  125. <form method="post" action=">" id="main_form">
  126.     
    ">
  127.         

    TrueVue免费空间测试 PHP探针


  128.     

    更多免费空间 请访问://www.TrueVue.org/">

  129.         ">
  130.         
    ">
  131.             
  132.         

  •     

  •     
    ">

  •         

  •         服务器特性" id="sec1">
  •         

    ">#top" class="arrow">5

  •             #bottom" class="arrow">6


  •         %" cellpadding="0" cellspacing="0" border="0">
  •             "==$sysReShow){?>
  •             

  •                 

  •                 

  •             

  •             
  •             

  •                 

  •                 

  •             

  •             "==$sysReShow){?>
  •             

  •                 

  •                 

  •             

  •             
  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             "==$sysReShow){?>
  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             
  •         
  • 服务器处理器 CPUCPU个数:
  •                     
  •                     

  •                     
  • 服务器时间:i:s")?>
  •  北京时间:
  •                     :i:s",time()+8*3600)?>
  • 服务器运行时间
    服务器域名/IP地址
  •                     (
  •                     
  •                     )
  • 服务器操作系统
  •                     ", php_uname());?>

  •  内核版本:
  •                     
  • 主机名称
    服务器解译引擎
    Web服务端口
    服务器管理员:<?=$_SERVER['SERVER_ADMIN']?>">
  •                     
  •                     
  • 本文件路径
    目前还有空余空间 diskfreespace.")/(1024*1024)),2)?>
  •                     M
  • 内存使用状况 物理内存:共
  •                     M, 已使用
  •                     M, 空闲
  •                     M, 使用率
  •                     %
  •                     
  •                     SWAP区:共
  •                     M, 已使用
  •                     M, 空闲
  •                     M, 使用率
  •                     %
  •                     
  •                 
  • 系统平均负载

  •         

  •         

  •         PHP基本特性" id="sec2">
  •         

    ">#top" class="arrow">5

  •             #bottom" class="arrow">6


  •         %" cellpadding="0" cellspacing="0" border="0">
  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •         
  • %">PHP运行方式%">
    PHP版本
    运行于安全模式")?>
    支持ZEND编译运行.optimization_level")||get_cfg_var("zend_extension_manager.optimizer_ts")||get_cfg_var("zend_extension_ts")) ?YES:NO?>
    允许使用URL打开文件 allow_url_fopen")?>
    允许动态加载链接库 enable_dl")?>
    显示错误信息 display_errors")?>
    自动定义全局变量 register_globals")?>
    程序最多允许使用内存量 memory_limit")?>
    POST最大字节数 post_max_size")?>
    允许最大上传文件 upload_max_filesize")?>
    程序最长运行时间 max_execution_time")?>
  •                     秒
  • magic_quotes_gpc
    magic_quotes_runtime
    被禁用的函数 disable_functions"==($disFuns=get_cfg_var("disable_functions")))?"":str_replace(",","<br />",$disFuns)?>
    PHP信息 PHPINFOphpinfo",$disFuns))?NO:"<a href='$phpSelf?act=phpinfo' target='_blank' class='static'>PHPINFO</a>"?>

  •         

  •         

  •         PHP组件支持" id="sec3">
  •         

    ">#top" class="arrow">5

  •             #bottom" class="arrow">6


  •         %" cellpadding="0" cellspacing="0" border="0">
  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •         
  • %">拼写检查 ASpell Library%">aspell_check_raw")?>%">高精度数学运算 BCMath%">bcadd")?>
    历法运算 Calendarcal_days_in_month")?>DBA数据库dba_close")?>
    dBase数据库dbase_close")?>DBM数据库dbmclose")?>
    FDF表单资料格式fdf_get_ap")?>FilePro数据库filepro_fieldcount")?>
    Hyperwave数据库hw_close")?>图形处理 GD Librarygd_info")?>
    IMAP电子邮件系统imap_close")?>Informix数据库ifx_close")?>
    LDAP目录协议ldap_close")?>MCrypt加密处理mcrypt_cbc")?>
    哈稀计算 MHashmhash_count")?>mSQL数据库msql_close")?>
    SQL Server数据库mssql_close")?>MySQL数据库mysql_close")?>
    SyBase数据库sybase_close")?>Yellow Page系统yp_match")?>
    Oracle数据库ora_close")?>Oracle 8 数据库OCILogOff")?>
    PREL相容语法 PCREpreg_match")?>PDF文档支持pdf_close")?>
    Postgre SQL数据库pg_close")?>SNMP网络管理协议snmpget")?>
    VMailMgr邮件处理")?>WDDX支持wddx_add_vars")?>
    压缩文件支持(Zlib)gzclose")?>XML解析xml_set_object")?>
    FTPftp_login")?>ODBC数据库连接odbc_close")?>
    Session支持session_start")?>Socket支持socket_accept")?>

  •         

  •         

  •         服务器性能检测" id="sec4">
  •         

    ">#top" class="arrow">5

  •             #bottom" class="arrow">6


  •         %" cellpadding="0" cellspacing="1" border="0" id="m4">
  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •         
  • 检测对象整数运算能力测试

  •                     (1+1运算300万次)
  • 浮点运算能力测试

  •                     (开平方300万次)
  • 数据I/O能力测试

  •                     (读取10K文件10000次)
  • Tahiti 的电脑(P4 1.7G 256M WinXP) 1.421秒 1.358秒 0.177秒
    PIPNI免费空间(2004/06/28 02:08) 2.545秒 2.545秒0.171秒
    神话科技风CGI型(2004/06/28 02:03) 0.797秒 0.729秒0.156秒
    您正在使用的这台服务器
  •                     
  •                     

  •                     " value="TEST_1" class="myButton" name="act" />

  •                     
  •                     

  •                     " value="TEST_2" class="myButton" name="act" />

  •                     
  •                     

  •                     " value="TEST_3" class="myButton" name="act" />

  •         

  •         
  •     $isMysql = (false !== function_exists("mysql_query"))?"":" disabled";
  •     $isMail = (false !== function_exists("mail"))?"":" disabled";
  • ?>
  •         

  •         自定义检测" id="sec5">
  •         

    ">#top" class="arrow">5

  •             #bottom" class="arrow">6


  •         %" border="0" cellspacing="0" cellpadding="0">
  •             

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             

  •                 

  •                 

  •                 

  •                 

  •             

  •             "==$mysqlReShow){?>
  •             

  •                 

  •             

  •             
  •             

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             "==$mailReShow){?>
  •             

  •                 

  •             

  •             
  •             

  •                 

  •             

  •             

  •                 

  •                 

  •                 "==$funReShow){?>
  •             

  •                 

  •             

  •             
  •             
  •             
  •             

  •                 

  •             

  •             

  •                 

  •                 

  •             

  •             "==$opReShow){?>
  •             

  •                 

  •             

  •             
  •         
  • ">MYSQL连接测试
    MYSQL服务器text" name="mysqlHost" value="localhost" /> MYSQL用户名 text" name="mysqlUser" />
    MYSQL用户密码 text" name="mysqlPassword" /> MYSQL数据库名称 text" name="mysqlDb" />
  •  " class="myButton" value="CONNECT" name="act" />
  • ">
    ">MAIL邮件发送测试
    收信地址">text" name="mailReceiver" size="50" />
  •  " class="myButton" value="SENDMAIL" name="act" />
  • ">
    ">函数支持状况
    函数名称">text" name="funName" size="50" />
  •  " class="myButton" value="FUNCTION_CHECK" name="act" />
  • ">
    ">PHP配置参数状况
    参数名称">text" name="opName" size="40" />
  •  " class="myButton" value="CONFIGURATION_CHECK" name="act" />
  • ">

  •         
  •     


  •     
    ">
  •         

    ">">#top" class="arrow">55


  •     

    更多免费空间 请访问://www.TrueVue.org/">

  •     

  •     " name="pInt" value="<?=$valInt?>" />
  •     " name="pFloat" value="<?=$valFloat?>" />
  •     " name="pIo" value="<?=$valIo?>" />



  • /*=============================================================
  •     函数库
  • =============================================================*/
  • /*-------------------------------------------------------------------------------------------------------------
  •     检测函数支持
  • --------------------------------------------------------------------------------------------------------------*/
  •     function isfun($funName)
  •     {
  •         return (false !== function_exists($funName))?YES:NO;
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     检测PHP设置参数
  • --------------------------------------------------------------------------------------------------------------*/
  •     function getcon($varName)
  •     {
  •         switch($res = get_cfg_var($varName))
  •         {
  •             case 0:
  •             return NO;
  •             break;
  •             case 1:
  •             return YES;
  •             break;
  •             default:
  •             return $res;
  •             break;
  •         }
  •          
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     整数运算能力测试
  • --------------------------------------------------------------------------------------------------------------*/
  •     function test_int()
  •     {
  •         $timeStart = gettimeofday();
  •         for($i = 0; $i < 3000000; $i++);
  •         {
  •             $t = 1+1;
  •         }
  •         $timeEnd = gettimeofday();
  •         $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
  •         $time = round($time, 3)."秒";
  •         return $time;
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     浮点运算能力测试
  • --------------------------------------------------------------------------------------------------------------*/
  •     function test_float()
  •     {
  •         $t = pi();
  •         $timeStart = gettimeofday();
  •         for($i = 0; $i < 3000000; $i++);
  •         {
  •             sqrt($t);
  •         }
  •         $timeEnd = gettimeofday();
  •         $time = ($timeEnd["usec"]-$timeStart["usec"])/1000000+$timeEnd["sec"]-$timeStart["sec"];
  •         $time = round($time, 3)."秒";
  •         return $time;
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     数据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);
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     比例条
  • --------------------------------------------------------------------------------------------------------------*/
  •     function bar($percent)
  •     {
  •     ?>
    • ">
    •     
    • width:<?=$percent?>%"> 


  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     系统参数探测 LINUX
  • --------------------------------------------------------------------------------------------------------------*/
  •     function sys_linux()
  •     {
  •         // CPU
  •         if (false === ($str = @file("/proc/cpuinfo"))) return false;
  •         $str = implode("", $str);
  •         @preg_match_all("/model\s+name\s{0,}\:+\s{0,}([\w\s\)\(.]+)[\r\n]+/", $str, $model);
  •         //@preg_match_all("/cpu\s+MHz\s{0,}\:+\s{0,}([\d\.]+)[\r\n]+/", $str, $mhz);
  •         @preg_match_all("/cache\s+size\s{0,}\:+\s{0,}([\d\.]+\s{0,}[A-Z]+[\r\n]+)/", $str, $cache);
  •         if (false !== is_array($model[1]))
  •             {
  •             $res['cpu']['num'] = sizeof($model[1]);
  •             for($i = 0; $i < $res['cpu']['num']; $i++)
  •             {
  •                 $res['cpu']['detail'][] = "类型:".$model[1][$i]." 缓存:".$cache[1][$i];
  •             }
  •             if (false !== is_array($res['cpu']['detail'])) $res['cpu']['detail'] = implode("<br />", $res['cpu']['detail']);
  •             }
  •          
  •          
  •         // UPTIME
  •         if (false === ($str = @file("/proc/uptime"))) return false;
  •         $str = explode(" ", implode("", $str));
  •         $str = trim($str[0]);
  •         $min = $str / 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 === ($str = @file("/proc/meminfo"))) return false;
  •         $str = implode("", $str);
  •         preg_match_all("/MemTotal\s{0,}\:+\s{0,}([\d\.]+).+?MemFree\s{0,}\:+\s{0,}([\d\.]+).+?SwapTotal\s{0,}\:+\s{0,}([\d\.]+).+?SwapFree\s{0,}\:+\s{0,}([\d\.]+)/s", $str, $buf);
  •          
  •         $res['memTotal'] = round($buf[1][0]/1024, 2);
  •         $res['memFree'] = round($buf[2][0]/1024, 2);
  •         $res['memUsed'] = ($res['memTotal']-$res['memFree']);
  •         $res['memPercent'] = (floatval($res['memTotal'])!=0)?round($res['memUsed']/$res['memTotal']*100,2):0;
  •          
  •         $res['swapTotal'] = round($buf[3][0]/1024, 2);
  •         $res['swapFree'] = round($buf[4][0]/1024, 2);
  •         $res['swapUsed'] = ($res['swapTotal']-$res['swapFree']);
  •         $res['swapPercent'] = (floatval($res['swapTotal'])!=0)?round($res['swapUsed']/$res['swapTotal']*100,2):0;
  •          
  •         // LOAD AVG
  •         if (false === ($str = @file("/proc/loadavg"))) return false;
  •         $str = explode(" ", implode("", $str));
  •         $str = array_chunk($str, 3);
  •         $res['loadAvg'] = implode(" ", $str[0]);
  •          
  •         return $res;
  •     }
  • /*-------------------------------------------------------------------------------------------------------------
  •     系统参数探测 FreeBSD
  • --------------------------------------------------------------------------------------------------------------*/
  •     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;
  •     }
  •      
  • /*-------------------------------------------------------------------------------------------------------------
  •     取得参数值 FreeBSD
  • --------------------------------------------------------------------------------------------------------------*/
  • function get_key($keyName)
  •     {
  •         return do_command('sysctl', "-n $keyName");
  •     }
  •      
  • /*-------------------------------------------------------------------------------------------------------------
  •     确定执行文件位置 FreeBSD
  • --------------------------------------------------------------------------------------------------------------*/
  •     function find_command($commandName)
  •     {
  •         $path = array('/bin', '/sbin', '/usr/bin', '/usr/sbin', '/usr/local/bin', '/usr/local/sbin');
  •         foreach($path as $p)
  •         {
  •             if (@is_executable("$p/$commandName")) return "$p/$commandName";
  •         }
  •         return false;
  •     }
  •      
  • /*-------------------------------------------------------------------------------------------------------------
  •     执行系统命令 FreeBSD
  • --------------------------------------------------------------------------------------------------------------*/
  •     function do_command($commandName, $args)
  •     {
  •         $buffer = "";
  •         if (false === ($command = find_command($commandName))) return false;
  •         if ($fp = @popen("$command $args

  • 阅读(1471) | 评论(0) | 转发(0) |
    0

    上一篇:Snort and Suricata

    下一篇:PHP Zend-guard-decode

    给主人留下些什么吧!~~