Page 1 of 1

PHP [Linux Servers] Operating System and Processor Installed

Posted: Fri Jul 29, 2011 9:56 am
by Hustle
Hi,

Below are a few lines of PHP code I've used before on linux servers and thought I should share on here :D , a small contribution to the BetterPHP Community but every contribution however big or small helps :D.

How to find out the processor that's installed in a linux server.
<?php
$proc = (explode(":",shell_exec("cat /proc/cpuinfo | grep \"model name\"")));
echo "<b>Processor:</b>$proc[1]";
?>
Result on my local linux server:
Processor: AMD Athlon(tm) II P320 Dual-Core Processor
How to find out the operating system that's installed on a linux server.
<?php
$serveros = (explode(":",shell_exec("lsb_release -d")));
echo "<b>Operating System:</b>$serveros[1]";
?>
Result on my local linux server:
Operating System: Ubuntu 10.04.3 LTS
Enjoy :D , I hope this will be useful to others.

Re: PHP [Linux Servers] Operating System and Processor Insta

Posted: Fri Jul 29, 2011 2:10 pm
by jacek
lsb_release -d
Didn't know about that !

Thanks for sharing :)

P.S. I think that the smaller contributions in the code section will be more useful ;)

Re: PHP [Linux Servers] Operating System and Processor Insta

Posted: Fri Jul 29, 2011 2:16 pm
by Hustle
jacek wrote:Thanks for sharing :)
Your welcome, it's great to share :D .
jacek wrote:P.S. I think that the smaller contributions in the code section will be more useful ;)
:)

Re: PHP [Linux Servers] Operating System and Processor Insta

Posted: Wed Jun 06, 2012 2:23 am
by josmeldiaz21
thx man... little scripts are simple but useful... greetings from Venezuela

Re: PHP [Linux Servers] Operating System and Processor Insta

Posted: Wed Jun 06, 2012 7:33 am
by bowersbros
Worth noting:
cat /proc/meminfo | grep "MemTotal"
shows the memory info
time command
shows how long a command takes :)