您的位置 首页 php

php开发一个测试机静态网页数据监控的网页

1. php作为网页数据后端处理开发语言, 它类似于perl语言的语法,学习上手都是比较容易。下面可以简单的做一个monitor 测试机运行状态的php网页,帮助你更好的监控和了解测试机运行状态。

php源码:

php name : tester_info_monitor.php

<meta name=”Author” content=”JIM”>

<meta http-equiv=”pragma” content=”no-cache”>

<meta http-equiv=”content-type” content=”text/html; charset=UTF-8″>

<link rel=stylesheet href=”/css/common.css” type=”text/css”>

<title>Tester Status Monitor</title>

<br />

<meta charset=”utf-8″>

<head><font color=”blue” size=”6″ >All Linux Tester Disk And Tester Status Monitor</font></head>

<?php

echo “<br>”;

echo “今天是”.date(“Y-m-d”).”-“.date(“l”).”<br>”;

echo “<br>”;

echo “<hr>”;

echo “<p>”;

echo “<b>注意:</b><br>”;

echo “1.如果Tester Run Time(Power on time) > 30days ,请在不测试时重启tester,避免tester长时间待机导致正常测试出现异常。<br>”;

echo “2.如果Tester 硬盘分区使用率Use% > 90% ,请联系工程师清理tester 的磁盘分区。<br>”;

echo “</p>”;

$ file = fopen(“/var/www/html/upload/tester_disk_info.txt”,”rb”)or die (“the file not open”);

$i=1;

echo “<table align=’left’ width=’70%’ border=’1′ cellspacing=0 >

<tr bgcolor=orange>

<th >#</th>

<th >Filesystem</th>

<th >Total Size</th>

<th >Used</th>

<th >Available</th>

<th >Use%</th>

<th >Mounted on</th>

<th >Filesystem</th>

<th >Total Size</th>

<th >Used</th>

<th >Available</th>

<th >Use%</th>

<th >Mounted on</th>

<th >Use Slot</th>

<th >Idel Slot</th>

<th >Total slot</th>

<th >Tester Run Time(Power on time)</th>

<th >Hostname</th>

<th >Tester IP</th>

</tr>”;

while(!feof($file)){

$line = fgets ($file); //每读取一行

if (preg_match(“/\/dev\/sda1.*/”, $line,$match)){

$info= explode (“\t”,$line);

echo “<tr align=’center’ bgcolor=FFFFDF>”;

echo “< td >” . $i . “</td>”;

echo “<td>” . $info[0] . “</td>”;

echo “<td>” . $info[1] . “</td>”;

echo “<td>” . $info[2] . “</td>”;

echo “<td>” . $info[3] . “</td>”;

$use_per = trim ($info[4]);

$use_per1 = explode(“%” ,$use_per);

if (($use_per1[0] >= 60) and ($use_per1[0] <= 90)){

echo “<td bgcolor=yellow>”.$info[4].”</td>”;

}elseif(($use_per1[0] > 90)){

echo “<td bgcolor=red>”.$info[4].”</td>”;

}else{

echo “<td>”.$info[4].”</td>”;

}

echo “<td>” . $info[5] . “</td>”;

echo “<td>” . $info[6] . “</td>”;

echo “<td>” . $info[7] . “</td>”;

echo “<td>” . $info[8] . “</td>”;

echo “<td>” . $info[9] . “</td>”;

$use_per = trim($info[10]);

$use_per1 = explode(“%” ,$use_per);

if (($use_per1[0] >= 60) and ($use_per1[0] <= 90)){

echo “<td bgcolor=yellow>”.$info[10].”</td>”;

}elseif(($use_per1[0] > 90)){

echo “<td bgcolor=red>”.$info[10].”</td>”;

}else{

echo “<td>”.$info[10].”</td>”;

}

echo “<td>”.$info[11].”</td>”;

echo “<td>”.$info[12].”</td>”;

echo “<td>”.$info[13].”</td>”;

echo “<td>”.$info[14].”</td>”;

$run_time = trim($info[15]);

if (preg_match(“/(\d+)days/”, $info[15],$mat)){

if (($mat[1] > 30)){

echo “<td bgcolor=yellow>”.$info[15].”</td>”;

}else{

echo “<td>”.$info[15].”</td>”;

}

}else{

echo “<td>”.$info[15].”</td>”;

}

echo “<td>”.$info[16].”</td>”

echo “<td>”.”<a href=\”” target=’_blank’>” . $info[17] .”</a>”. “</td>”;

echo “</tr>”;

$i++;

}

}

fclose($file);

?>

2. tester information sample,仅为后面网页显示效果。

sample data name : tester_disk_info.txt

/dev/sda192G22G66G25%//dev/sda2367G25G324G8%/export08817dayscsst2ibmfct-0110.194.100.45 /dev/sda147G11G34G24%//dev/sda2870G27G800G4%/export26814dayscsst2ibmfct-0310.194.100.46 /dev/sda147G19G27G42%//dev/sda2870G12G815G2%/export088162dayscsst2ibmfct-0210.194.100.47 /dev/sda147G13G33G28%//dev/sda2870G25G802G3%/export26814dayscsst2ibmfct-0410.194.100.48 /dev/sda147G14G31G31%//dev/sda2870G28G799G4%/export44814dayscsst2ibmfct-0510.194.100.49 /dev/sda147G12G34G26%//dev/sda2870G27G800G4%/export62814dayscsst2ibmfct-0610.194.100.50 /dev/sda194G13G77G15%//dev/sda2823G19G763G3%/export0889dayscsst2ibmfct-0710.194.100.51 /dev/sda147G12G33G27%//dev/sda2870G23G803G3%/export53814dayscsst2ibmfct-0810.194.100.52 /dev/sda147G19G27G42%//dev/sda2870G23G803G3%/export08818dayscsst2ibmfct-0910.194.100.53 /dev/sda147G17G29G37%//dev/sda2870G18G808G3%/export80818dayscsst2ibmfct-1010.194.100.54 /dev/sda147G18G27G40%//dev/sda2870G16G810G2%/export08818dayscsst2ibmfct-1110.194.100.55

3. 网页显示的效果:

文章来源:智云一二三科技

文章标题:php开发一个测试机静态网页数据监控的网页

文章地址:https://www.zhihuclub.com/153821.shtml

关于作者: 智云科技

热门文章

网站地图