PHP教學-抓取系統硬體資訊( linux )
雖然現在 php 有很多工具可以抓到相關資訊,但對於想要將該功能設計到自己的 web 系統中,或許相關範例也值得參考,不過該程式僅針對 linux 系統來抓取資料。
<?php
// Server Hardware Information v1.0.0
?>
<html>
<head>
<title><?php echo $SERVER_NAME; ?> - Server Information</title>
<STYLE type=text/css>
BODY { FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Verdana,arial, helvetica, serif; margin : 0 0 0 0;}
.style1 {
color: #999999;
font-weight: bold;
}
</STYLE>
</head>
<body>
<blockquote>
<pre><p></p>
<span class="style1">Uptime:</span>
<?php system("uptime"); ?>
<span class="style1">System Information:</span>
<?php system("uname -a"); ?>
<span class="style1">Memory Usage (MB):</span>
<?php system("free -m"); ?>
<span class="style1">Disk Usage:</span>
<?php system("df -h"); ?>
<span class="style1">CPU Information:</span>
<?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?>
</pre>
<p><br>
<br>
</p>
</blockquote>
</body>
</html>
<?php
// Server Hardware Information v1.0.0
?>
<html>
<head>
<title><?php echo $SERVER_NAME; ?> - Server Information</title>
<STYLE type=text/css>
BODY { FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Verdana,arial, helvetica, serif; margin : 0 0 0 0;}
.style1 {
color: #999999;
font-weight: bold;
}
</STYLE>
</head>
<body>
<blockquote>
<pre><p></p>
<span class="style1">Uptime:</span>
<?php system("uptime"); ?>
<span class="style1">System Information:</span>
<?php system("uname -a"); ?>
<span class="style1">Memory Usage (MB):</span>
<?php system("free -m"); ?>
<span class="style1">Disk Usage:</span>
<?php system("df -h"); ?>
<span class="style1">CPU Information:</span>
<?php system("cat /proc/cpuinfo | grep \"model name\\|processor\""); ?>
</pre>
<p><br>
<br>
</p>
</blockquote>
</body>
</html>
留言
張貼留言