Jump to content

[SOLVED] How to echo a servers hardware?


climbjm

Recommended Posts

Is there a way to echo a machines hardware through PHP or pulling the information from Apache?

 

I am trying to figure out a script to display the machines memory, hd disk space, processor information, memory usage (used by programs and used by cache), etc.

 

Anyone have any good articles, links, other info I might look at?

 

Server: Apache/2.2.3 (Ubuntu) PHP/5.2.1 Server

Link to comment
Share on other sites

as far as i know, its not possible for php to access that.  however if thres anotehr way, like a different language ( manul cron sort of stuff), then you might be ablet o write a module or somethign that creates an array with that data in it.

 

gdlk

Link to comment
Share on other sites

as far as i know, its not possible for php to access that.  however if thres anotehr way, like a different language ( manul cron sort of stuff), then you might be ablet o write a module or somethign that creates an array with that data in it.

 

gdlk

 

You could use "lspci" for the hardware and "free -m" for the memory usage. What you have to do to get that info from bash into a file and then into PHP is beyond me.

Link to comment
Share on other sites

as far as i know, its not possible for php to access that.  however if thres anotehr way, like a different language ( manul cron sort of stuff), then you might be ablet o write a module or somethign that creates an array with that data in it.

 

gdlk

 

You could use "lspci" for the hardware and "free -m" for the memory usage. What you have to do to get that info from bash into a file and then into PHP is beyond me.

 

That is a great idea.

I could run a batch script that scrapes my hardware information.

Then redirect the output to a file to something like "hardware.info"

and then just include (not require) that file in my PHP script and convert new lines to breaks.

 

I cannot believe I didnt think of that myself.  Thanks for brain storming guys!

Link to comment
Share on other sites

Here is an example of what I did to show just some of my machines information using PHP.

 

status.php

<html>
<head>
<title>System Status</title>
</head>
<body>
<h1>Machine Information & System Status</h1>
<?
include("memory.php");
include("machine.php");
?>
</body>
</html>

 

memory.php

<h2>Memory - KB</h2>
<pre>
<? echo shell_exec('free -o'); ?>
</pre>

 

machine.php

<h2>Machine Details</h2>
<pre>
Hardware Type: <? echo shell_exec('uname -m'); ?>
Node Name: <? echo shell_exec('uname -n'); ?>
Processor: <? echo shell_exec('uname -p'); ?>
Release: <? echo shell_exec('uname -r'); ?>
OS System Name: <? echo shell_exec('uname -s'); ?>
OS Version: <? echo shell_exec('uname -v'); ?>
</pre>

 

Works Great on my Ubuntu PHP/Apache Server.

Note: This is for linux and doubt it will work on Windows.

Link to comment
Share on other sites

Thanks thorpe... great information!

Man, I am falling in love with the linux/php/apache combination everyday.

 

I found this article (site is down but I found a cached version of the site) http://72.14.253.104/search?q=cache:VLCvyCQMfXYJ:www.freeos.com/articles/2879/+/proc&hl=en&ct=clnk&cd=1&gl=us

 

/proc/cpuinfo

Information about the processor, such as its type, make, model, and

performance.

 

/proc/devices

List of device drivers configured into the currently running kernel.

 

/proc/dma

Shows which DMA channels are being used at the moment.

 

/proc/filesystems

Filesystems configured into the kernel.

 

/proc/interrupts

Shows which interrupts are in use, and how many of each there have been.

 

/proc/ioports

Which I/O ports are in use at the moment.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.