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
https://forums.phpfreaks.com/topic/63945-solved-how-to-echo-a-servers-hardware/
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

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.

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!

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.