PHP [Linux Servers] Operating System and Processor Installed

Written something you are proud of, post it here.
Post Reply
User avatar
Hustle
Posts: 24
Joined: Wed Jul 27, 2011 1:30 pm
Location: United Kingdom

PHP [Linux Servers] Operating System and Processor Installed

Post 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.
User avatar
jacek
Site Admin
Posts: 3262
Joined: Thu May 05, 2011 1:45 pm
Location: UK
Contact:

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

Post 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 ;)
Image
User avatar
Hustle
Posts: 24
Joined: Wed Jul 27, 2011 1:30 pm
Location: United Kingdom

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

Post 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 ;)
:)
josmeldiaz21
Posts: 2
Joined: Wed Jun 06, 2012 2:20 am

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

Post by josmeldiaz21 »

thx man... little scripts are simple but useful... greetings from Venezuela
bowersbros
Posts: 534
Joined: Thu May 05, 2011 8:19 pm

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

Post by bowersbros »

Worth noting:
cat /proc/meminfo | grep "MemTotal"
shows the memory info
time command
shows how long a command takes :)
I don't like to brag, but I wasn't circumcised. I was circumnavigated. ;)

Want to learn something new? Or maybe reinforce what you already know? Or just help out? Please subscribe to my videos: http://goo.gl/58pN9
Post Reply