我创建了下面的脚本,它工作得很好,让我知道当前服务器的正常运行时间 -
<?php
$server = $_POST['server'];
// only digits
$pattern = '/[^0-9]/';
?>
<html>
<head>
<title>Uptime</title>
</head>
<body>
<?php
$uptime = `c:\windows\system32\uptime2.bat $server`;
$uptime = explode(": ", $uptime);
$uptime = explode(", ", $uptime[1]);
$uptime_days = preg_replace($pattern, '', $uptime[0]);
$uptime_hours = preg_replace($pattern, '', $uptime[1]);
$uptime_minutes = preg_replace($pattern, '', $uptime[2]);
$uptime_seconds = preg_replace($pattern, '', $uptime[3]);
echo '<b>Uptime:</b><br><br>';
echo 'Days: '.$uptime_days.'<br>';
echo 'Hours: '.$uptime_hours.'<br>';
echo 'Minutes: '.$uptime_minutes.'<br>';
echo 'Seconds: '.$uptime_seconds.'<br>';
?>
</body>
</html>
其中 uptime2.bat 包含以下信息 -
@echo off
uptime.exe %1
我想知道,如何修改此代码以将多个服务器作为输入传递并获取以下所有服务器详细信息,例如 -
RAM
HDD
CPU Usage
Uptime
Server Online/Offline
我希望我能够在这里传达我的问题。对此的任何指示将不胜感激。
先感谢您。