I have a Linux Server and only having ftp access for it I want to check Server full detail like OS version, RAM, HDD, installed packages etc is it possible using php script file to get information for the server.?
I tried to get its details using phpinfo.php
<<?php
echo php_uname();
echo PHP_OS;
echo '<br />';
$bytes = disk_free_space(".");
$si_prefix = array( 'B', 'KB', 'MB', 'GB', 'TB', 'EB', 'ZB', 'YB' );
$base = 1024;
$class = min((int)log($bytes , $base) , count($si_prefix) - 1);
echo $bytes . '<br />';
echo sprintf('%1.2f' , $bytes / pow($base,$class)) . ' ' . $si_prefix[$class] . '<br />';
echo memory_get_usage() . "\n"; // 36640
$a = str_repeat("Hello", 4242);
echo memory_get_usage() . "\n"; // 57960
unset($a);
echo memory_get_usage() . "\n"; // 36744
?>It looks like.
Linux fileserver 3.16.0-30-generic #40~14.04.1-Ubuntu SMP Thu Jan 15 17:45:15 UTC 2015 i686
26575900672
24.75 GB
117168 138460 117168How we can make it more useful please give your suggestions.
12 Answers
You can login on server by putty with same detail (FTP login detail) and run following command:
uname -aOr, you can execute PHP shell command to get OS info.
You can use shell_exec which is a PHP function, which runs your shell command and returns the output of it.
See this page as reference: PHP: shell_exec - Manual
So by combining this function and uname, lscpu, free and do little text processing you can get what you want.