climbjm Posted August 8, 2007 Share Posted August 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
flappy_warbucks Posted August 8, 2007 Share Posted August 8, 2007 echo "<pre>"; print_r($_SERVER); i dnt think you will be able to actully be able to get the specific hardware specs tho Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 8, 2007 Author Share Posted August 8, 2007 Thanks, but I am not looking for $_SERVER variables. That just displays User's Agent and Apache server information. I am looking specifically for hardware. Quote Link to comment Share on other sites More sharing options...
PC Nerd Posted August 8, 2007 Share Posted August 8, 2007 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 Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted August 8, 2007 Share Posted August 8, 2007 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. Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 9, 2007 Author Share Posted August 9, 2007 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! Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 9, 2007 Author Share Posted August 9, 2007 I would probably just create a cron job to run the script every 5 minutes. Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 10, 2007 Author Share Posted August 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted August 10, 2007 Share Posted August 10, 2007 Theres also alot more information available within the /proc file system. Quote Link to comment Share on other sites More sharing options...
climbjm Posted August 10, 2007 Author Share Posted August 10, 2007 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.