So i want to do a basic admin page for my servers to display information.
The information that has to display is this:
Operating System Name
IP address
Uptime
CPU Information and CPU Load
Total Memory and memory being used
Total HDD Space and HDD Used Space
They both have linux OS(don't know if it makes any difference from windows)
Any idea on how to have that information?(till know i only know $_SERVER['SERVER_ADDR'] to get the ip adress)
PHP Server info Script
Moderator: General Moderators
Re: PHP Server info Script
You will almost certainly need either exec() or system() which, on shared hosting, are unlikely to be enabled. I've listed the appropriate commands anyway.
- Operating System Name:
uname -o - Uptime:
uptime - CPU Information and CPU Load: not sure
- Total Memory and memory being used:
free - Total HDD Space and HDD Used Space:
df
Re: PHP Server info Script
To display the cpu usage load i found this ajax script http://www.obout.com/AJAXPage/ex_cpumon.aspx but i don't know how i can insert it in my php page. Anyone knows how i can add this script?
Re: PHP Server info Script
It appears to be written in C#, so I expect that will pose some problems.
Re: PHP Server info Script
hope i will fine another one that will work, as i don't know how to program in ajax
Re: PHP Server info Script
So for the cpu information i did this script.
but i'm getting these errors with the cpu information. Anyone can tell me how i can remove these errors?
Code: Select all
<?php
$cpuinfo = file("/proc/cpuinfo");
for ($i = 0; $i < count($cpuinfo); $i++)
{
list($item, $data) = split(":", $cpuinfo[$i], 2);
$item = chop($item);
$data = chop($data);
if ($item == "processor") {$total_cpu++; }
if ($item == "vendor_id") { $vendor_id = $data; }
if ($item == "model name") { $cpu_name = $data; }
if ($item == "cpu MHz") {$cpu_speed = " " . floor($data);}
}
$cpu_info = $total_cpu.'x '.$vendor_id.' '.$cpu_name.' '.$cpu_speed." MHz\n";
$cpu = "<p>CPU :".$cpu_info."</p>";
echo $cpu;
?>
Code: Select all
Notice: Undefined variable: total_cpu in /var/www/html/daniel/index.php on line 10 Notice: Undefined offset: 1 in /var/www/html/daniel/index.php on line 7 Notice: Undefined offset: 1 in /var/www/html/daniel/index.php on line 7 Notice: Undefined offset: 1 in /var/www/html/daniel/index.php on line 7 Notice: Undefined offset: 1 in /var/www/html/daniel/index.php on line 7
CPU :4x GenuineIntel Intel(R) Xeon(R) CPU X3360 @ 2.83GHz 2825 MHzRe: PHP Server info Script
Problem solved. Just made another script and instead of a loop i made the loop my self.