php文件actionscript计算机属性ram处理器信息

时间:2013-04-30 10:01:36

标签: php actionscript ip

我只是想知道在php中是否有办法可以检索服务器的属性,如计算机名称,内存,处理器信息。

这些信息将被加载到动作脚本中。

我已经用这种方式做了一个php文件来了解服务器的ip地址,就像在web上的教程文章中所说的那样:

<?php //Opening Tag, tell PHP server to interpret the following lines as php code 
$ip = $_SERVER['REMOTE_ADDR']; //Sets the ip variable, its value is a method that will get the user ip
echo $ip; //The echo keyword outputs the assigned string, in this case the ip variable 
?>

我已经成功地回显或向我的flash应用程序显示了ip地址的值。现在,我无法找到的是如何知道服务器的计算机名称,内存和处理器信息。

这里有没有人知道php中的代码来显示我需要的信息?

修改 谢谢你的快速回复。

这是答案。我们必须使用exec命令。 (考虑到没有安全功能已配置为php或被关闭)

了解计算机的电脑名称。

<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?> 

对于PC的cpu和内存:

<?php

function GetProgCpuUsage($program)
 {
     if(!$program) return -1;

    $c_pid = exec("ps aux | grep ".$program." | grep -v grep | grep -v su | awk {'print $3'}");
     return $c_pid;
 }

function GetProgMemUsage($program)
 {
     if(!$program) return -1;

    $c_pid = exec("ps aux | grep ".$program." | grep -v grep | grep -v su | awk {'print $4'}");
     return $c_pid;
 }



    echo "CPU use of Program: ".GetProgCpuUsage($randomprogram)."%";
     echo "Memuse of Program: ".GetProgMemUsage($randomprogram)."%";

?>

您可以参考此信息的来源。  资料来源:http://php.net/manual/en/function.exec.php

1 个答案:

答案 0 :(得分:1)

在服务器中创建一个脚本,该脚本将获取其硬件信息并将其显示给您。之后通过actionscript调用此脚本并显示信息。

要获取硬件信息,您需要系统命令。您必须使用exec函数来运行系统命令。

要获取Windows操作系统的系统信息,请使用此命令systeminfoSystem info for windowsOS

相关问题