user4832609
user4832609

Reputation:

PHP Script for Windows Server Information

I have created below script which works just fine and get me the uptime of the current server -

<?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>

In which uptime2.bat consist of following information -

@echo off

uptime.exe %1

I would like to know, how can I modify this code to pass multiple servers as input and get all the below servers details like -

RAM
HDD
CPU Usage
Uptime
Server Online/Offline

I hope I am able to convey my question here. Any pointers on this would be appreciated.

Thank you in advance.

Upvotes: 2

Views: 1176

Answers (1)

Jacob Calvert
Jacob Calvert

Reputation: 308

Check out PHPSysInfo. It does pretty much what you are wanting to do for single servers. Maybe you can take a look at the code and modify it to suit your use case.

Upvotes: 1

Related Questions