Server Status & Server Load

coolv1994

Member
Messages
508
Reaction score
0
Points
16
I got really bored and made a server status and server load script.
PHP:
<?php
// Server Info
$name = "";
$ip = "";
// Ports
$http = "80";
$mysql = "3306";
$exim = "25";
$cpanel = "2082";
$ftp = "21";
$dns = "53";
// Checks The Server
$chhttp = @fsockopen(server($ip), $http, $errno, $errstr, 20);
$chmysql = @fsockopen(server($ip), $mysql, $errno, $errstr, 20);
$chexim = @fsockopen(server($ip), $exim, $errno, $errstr, 20);
$chcpanel = @fsockopen(server($ip), $cpanel, $errno, $errstr, 20);
$chftp = @fsockopen(server($ip), $ftp, $errno, $errstr, 20);
$chdns = @fsockopen(server($ip), $dns, $errno, $errstr, 20);
// Online Or Offline
$on = "Online";
$off = "Offline";
//Server Load
$loadresult = @exec('uptime');
preg_match("/averages?: ([0-9\.]+),[\s]+([0-9\.]+),[\s]+([0-9\.]+)/",
$loadresult,$avgs);
$svrld=(($avgs[1]/8)*100);
?> 
Server Name: <?php echo $name; ?>
IP Address: <?php echo $ip; ?>
Server Load: <?php echo $svrld; ?>
HTTP: <?php if (!$chhttp){ echo $off; } else { echo $on; }; ?>
MySQL: <?php if (!$chmysql){ echo $off; } else { echo $on; }; ?>
Exim: <?php if (!$chexim){ echo $off; } else { echo $on; }; ?>
cPanel: <?php if (!$chcpanel){ echo $off; } else { echo $on; }; ?>
FTP: <?php if (!$chftp){ echo $off; } else { echo $on; }; ?>
DNS: <?php if (!$chdns){ echo $off; } else { echo $on; }; ?>
I made it for the x10Panel but it probally won't be used so if you want to use it go ahead.
For the server load you need to change the 8 to how many cores your processer has.
PHP:
$svrld=(($avgs[1]/change this)*100);
 
Top