Home >Backend Development >PHP Tutorial >PHP needle control (view server details)_PHP tutorial

PHP needle control (view server details)_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:08:411298browse

php tutorial needle control (view server details)

/

* 1. This program is based on the div+css tutorial new architecture php probe , free and open source free software, with powerful functions, clear structure and easy to use.
1. Support windows, linux, unix, freebsd, sun solar system
2. Support ie6, ie7, firefox, google chrome and other browsers.

2. Main uses and applicable objects:
1. Amateurs and professional developers who are familiar with PHP programming.
2. The computer room manager configures the linux (windows) + php + mysql tutorial + zend system environment and checks whether the system is configured successfully.
3. For users who purchase virtual hosts, it is used to test server performance.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
*/
////////////////////The following two variables can be modified and configured
//If you are using this probe for verification, you can Enter relevant information in the variables below (will be displayed at the bottom of the page
header("content-type: text/html; charset=utf-8");
error_reporting(e_error | e_warning | e_parse);
ob_start ();

$valint = (false == empty($_post['pint']))?$_post['pint']:"Not tested";
$valfloat = (false = = empty($_post['pfloat']))?$_post['pfloat']:"Not tested";
$valio = (false == empty($_post['pio']))?$_post ['pio']:"Not tested";
$mysqlreshow = "none";
$mailreshow = "none";
$funreshow = "none";
$opreshow = "none" ;
$sysreshow = "none";
//============ Define constants to replace template output variables ============== =========
//define("yes", "yes");
//define("no", "no");
define("yes", "");
define("no", "×");

//================================================ ====================
define("icon", "2 ");
$phps tutorial elf = $_server[php_self] ? $_server[php_self] : $_server[script_name];
define("phpself", preg_replace("/(.{0,}?/+)/ ", "", $phpself));

if ($_get['act'] == "phpinfo")
{
phpinfo();
exit();
}
elseif($_post['act'] == "integer test")
{
$valint = test_int();
}
elseif($_post[' act'] == "Floating point test")
{
$valfloat = test_float();
}
elseif($_post['act'] == "io test")
 {
          $valio = test_io(); > $ Mysqlre = "MySQL connection test results:";
$ mysqlre. = (False! == @mysql_connect ($ _ post ['mysqlhost'], $ _post ['mysqluser'], $ _post ['mysqlpas sword '] ; ;
       $mysqlre .= (false != @mysql_select_db($_post['mysqldb']))?"Connection OK": "Connection failed";
    }
  elseif($_post['act' ] == "sendmail")
                                                               $mailreshow =                                          mail($_post["mailreceiver"], "uenuprobe mail server test.", "this email is sent by uenuprobe.rnrnrnrnrncopyright uenucomrnhttp://www.uenu.com"))?"Complete":"Failed";
}
elseif($_post['act'] == "function_check")
{
$funreshow = "show";
$funre = "function".$_post ['funname']." Support status detection results: ".isfun($_post['funname']);
}
elseif($_post['act'] == "configuration_check ")
{
$opreshow = "show";
$opre = "Configuration parameters".$_post['opname']." Detection result: ". getcon($_post['opname']);
}

//=========================== =============================================

//================================================ =========================
switch (php_os)
{
case "linux":
$sysreshow = (false != ($sysinfo = sys_linux()))?"show":"none";
break;
case "freebsd":
$sysreshow = (false != ($sysinfo = sys_freebsd ()))?"show":"none";

break;

case "windows":
//$sysreshow = (false != ($sysinfo = sys_windows()))?"show ":"none";
$sysinfo['uptime'] ="Sorry, windows system does not support";
break;
default:
break;
}

//================================================ ========================

?>







服务器信息




服务器信息


switch($_get['action']){
case '':
?>


 


 
   


   
   


 
   


 
   


 
   


 
   


 
   


 
   


 
   


 
   


 
   


 
   

服务器特征
服务器时间 (格林威治标准时间) (北京时间)
服务器域名$_server[server_name]"); ?>
服务器ip地址
服务器操作系统 if ($os[0] =="windows") {echo "主机名称:".$os[2];} else {echo "内核版本:".$os[2];}?>
服务器运行时间
服务器操作系统文字编码
服务器解译引擎
web服务端口
服务器管理员
本文件路径
服务端剩余空间
系统当前用户名





服务器处理器
cpu个数:





服务器处理器
cpu个数:



内存使用状况

m, 已使用
m, 空闲
m, 使用率
%

swap区

m, 已使用
m, 空闲
m, 使用率
%

系统平均负载



break;
case 'phpinfo':
?>


 


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   












< ;/tr>












php基本特征
php版本php运行方式
支持zend编译运行 ()运行于安全模式
自动定义全局变量 register_globals允许使用url打开文件allow_url_fopen
允许动态加载链接库enable_dl显示错误信息 display_errors
短标记<? ?>支持标记<% %>支持
cookie支持session支持
浮点运算有效数字显示位数强制y2k兼容
被禁用的函数disable_functionsif($disused =="1")
{echo '">'."more".'';}
else {echo "none";}?>
程序最长运行时间max_execution_time
The maximum amount of memory a program is allowed to use memory_limit Maximum number of bytes in post post_max_size
Maximum uploaded files allowed upload_max_filesize php information phpinfo phpinfo"?>
html error display Debugger address/port
smtp support smtp address

break;
case 'otherinfo':
?>










< tr>


< td>Graphics processing gd library







< /tr>












   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   

php component support status
Spell check aspell libraryHigh Precision mathematical operations bcmath
Calendar operation calendar
Class/Object Support String type detection support
iconv encoding support < ;/td>
mcrypt encryption processing support
Hash calculation mhash openssl support
prel compatible syntax pcre正则扩展(兼容perl)支持
socket支持流媒体支持
tokenizer支持url支持
wddx支持(web distributed data exchange)压缩文件支持(zlib)
xml解析ftp
目录存取协议(ldap)支持yellow page系统支持
php和java综合支持imap电子邮件系统支持
snmp网络管理协议支持vmailmgr邮件处理支持
pdf文档支持fdf表单资料格式支持

  break;
 case 'dbinfo': 
?>


 


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   


 
   
 
   

数据库支持状况
mysql数据库支持mysql数据库持续连接
mysql最大连接数odbc数据库连接
sql server数据库支持msql数据库支持
postgre sql数据库支持oracle数据库支持
oracle 8 数据库支持dbase数据库支持
sybase数据库支持dba数据库支持
dbm数据库支持dbx数据库支持
db++数据库支持frontbase数据库支持
filepro数据库支持informix数据库支持
lotus notes数据库支持interbase数据库支持
ingres数据库支持hyperwave数据库支持
ovrimos sql数据库连接支持sesam数据库连接支持
sqlite数据库连接支持adabas d数据库连接支持

break;
case 'testinfo':
?>
" method="post">





 
 
 
 


 
 
 
 


 
 
 
 


 
 
 
 


 
 
 
 


 
 
 
 

服务器性能检测
参照对象整数运算能力检测(1+1运算300万次)浮点运算能力检测(开平方300万次)数据i/o能力检测(读取10k文件1万次)
红色主机单线型(双核)0.33 秒0.95 秒0.03 秒
红色主机双线型(四核)0.25 秒0.79 秒0.03 秒
xeon(tm) 2.80*2+4g+centos 5.20.068秒0.086秒小于0.100秒
xeon(tm) 2.80ghz+2g+freebsd 4.00.501秒0.694秒小于0.100秒
本台服务器






$ismysql = (false !== function_exists("mysql_query"))?"":" disabled";
$ismail = (false !== function_exists("mail"))?"":" disabled";
?>


" method="post">







 
 


 
 


 
 


 
 


 
   

mysql数据库连接检测
mysql服务器:
mysql用户名:
mysql用户密码: size="80" class="text2" />
mysql数据库名称:
  name="act" />






" method="post">





   
   


   
   

php配置参数状况
请输入您要检测的参数名称:






" method="post">





 
 


 
   

函数检测
请输入您要检测的函数名称:






" method="post">





   
   


   
   

mail邮件发送测试
请输入您要检测的邮件地址: class="text2" />
  name="act" />


break;
}?>




/*==================== ===========================================
Function library
================================================== ============*/

/*------------------------------------------------ -------------------------------------------------- -------------
Detection function support
-------------------------- -------------------------------------------------- ----------------------------------*/
function isfun($funname)
{
Return (false !== function_exists($funname))?yes:no;
}
/*------------------------ -------------------------------------------------- ------------------------------------
Detect php setting parameters
---- -------------------------------------------------- -------------------------------------------------- ------*/
function getcon($varname)
{
switch($res = get_cfg_var($varname))
{
case 0:
return no ;
break;
case 1:
return yes;
break;
default:
return $res;
          break;
                                                                                                                                        }
/*-------------------------------------------------- -------------------------------------------------- ---------------
Integer arithmetic ability test
------------------------- -------------------------------------------------- ----------------------------------*/
function test_int()
{
         $timestart = gettimeofday(); $timeend = gettimeofday();
$time = ($timeend["usec"]-$timestart["usec"])/1000000+$timeend["sec"]-$timestart["sec"];
         $time = round($time, 6)."seconds"; -------------------------------------------------- ------------------------------------------
Floating point computing ability test
-------------------------------------------------- -------------------------------------------------- -------------*/
function test_float()
{
$t = pi();
$timestart = gettimeofday();
for ($i = 0; $i < 3000000; $i++);
sqrt($t);
}
$timeend = gettimeofday(); $timeend["usec"]-$timestart["usec"])/1000000+$timeend["sec"]-$timestart["sec"];
            $time = round($time, 6)." Seconds";
return $time;
}
/*---------------------------------- -------------------------------------------------- ----------------------------
Data io ability test
--------------------- -------------------------------------------------- ----------------------------------------*/
function test_io()
{
$fp = @fopen(phpself, "r");
$timestart = gettimeofday();
for($i = 0; $i < ; 10000; $i++)
                                                                                                                                                                                                                                                                          since}
$timeend = gettimeofday();
@fclose($fp);
$time = ($timeend["usec"]-$timestart["usec"])/1000000+$timeend[ "sec"]-$timestart["sec"];
        $time = round($time, 6)."seconds";
                                                                                                                                                   -------------------------------------------------- -------------------------------------------------- --------
Proportional bar
---------------------------------- -------------------------------------------------- --------------------------*/
function bar($percent)
{
echo '


  • ";
    echo ' 
';
}
/*--------------------------------- -------------------------------------------------- --------------------------
Obtain cpu related information according to different systems
-------- -------------------------------------------------- -------------------------------------------------- --*/
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;
default:
break;
}

/*-------------------------------------------------------------------------------------------------------------
    系统参数探测 linux
--------------------------------------------------------------------------------------------------------------*/
    function sys_linux()
    {
        // cpu
        if (false === ($str = @file("/proc/cpuinfo"))) return false;
        $str = implode("", $str);
        @preg_match_all("/models+names{0,}:+s{0,}([ws)(.]+)[rn]+/", $str, $model);
        //@preg_match_all("/cpus+mhzs{0,}:+s{0,}([d.]+)[rn]+/", $str, $mhz);
        @preg_match_all("/caches+sizes{0,}:+s{0,}([d.]+s{0,}[a-z]+[rn]+)/", $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("
", $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("/memtotals{0,}:+s{0,}([d.]+).+?memfrees{0,}:+s{0,}([d.]+).+?swaptotals{0,}:+s{0,}([d.]+).+?swapfrees{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");
}
 
/*--------------------------- -------------------------------------------------- ------------------------------------
Determine the location of the executable file 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;                                  -------------------------------------------------- ---------------------------------------------
Execution system Command freebsd
------------------------------------------------ -------------------------------------------------- ---------------*/
function do_command($commandname, $args)
{
$buffer = "";
if (false == = ($command = find_command($commandname))) return false;
if ($fp = @popen("$command $args", 'r'))
{
while (!@feof ($fp))
{
$buffer .= @fgets($fp, 4096);
}
return trim($buffer);
}
return false;
}

/*------------------------------------------ -------------------------------------------------- --------------------
System parameter detection windows

-------------------- -------------------------------------------------- ----------------------------------------*/

function sys_windows()
{
//$phpos=php_os;
$sysinfo['uptime'] ="Sorry, windows system does not support";

}
?>



http://www.bkjia.com/PHPjc/444855.html

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/444855.htmlTechArticlephp tutorial needle control (view server details) / *1. This program is based on the new architecture of div+css tutorial php Probe, free and open source free software, with powerful functions, clear structure and easy to use...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn