PHP
  Home arrow PHP arrow Page 4 - Retrieving System Information With patSysinfo
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
PHP

Retrieving System Information With patSysinfo
By: icarus, (c) Melonfire
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 19
    2004-02-16


    Table of Contents:
  • Retrieving System Information With patSysinfo
  • Plug and Play
  • What's in a Name?
  • Up and at 'Em
  • Carrying the Load
  • A Nifty Device
  • Running Out of RAM
  • Mounting Up
  • Link Zone

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    Retrieving System Information With patSysinfo - Up and at 'Em
    ( Page 4 of 9 )

    How about finding out how long it's been since the system's last reboot? Well, patSysinfo allows you to duplicate the "uptime" command with its getUptime() function. Take a look:


    <?php
    // include class
    include("patSysinfo.php"); 
    // instantiate object
    $sys = new patSysinfo();
     
    // get uptime
    $uptime = $sys->getUptime(); 
     
    // output values 
    echo "Last reboot was " . $uptime['days'] . " days, " . $uptime['hours'] .
    " hours and " . $uptime['mins'] . " minutes ago";
     
    ? >

    The getUptime() method returns the time since the system's last reboot as an associative array with keys "days", "mins" and "hours". This can then easily be formatted into a readable string, as above. Here's the output:

    Last reboot was 0 days, 1 hours and 43 minutes ago

    Want to know a little bit more about the hardware and software running on the system? Take a look at the getKernelVersion() and getCpu() functions, which return the current kernel version and processor details respectively.


    <?php 
     
    // include class
    include("patSysinfo.php");
     
    // instantiate object
    $sys = new patSysinfo(); 
     
    // get kernel version
    $kv = $sys->getKernelVersion(); 
     
    // get processor information
    $cpuArray = $sys->getCpu(); 
     
    // extract model, speed, cache etc
    $model = $cpuArray[0]['model'];
    $speed = $cpuArray[0]['mhz'];
    $cache = $cpuArray[0]['cache'];
    $mips = $cpuArray[0]['bogomips']; 
     
    // output values 
    echo "Kernel $kv running on a $model at $speed MhZ ($cache cache, $mips bogomips)"; 
     
    ? >

    The getCpu() function, in particular, deserves closer attention. This function returns an array, each element of which is itself an associative array representing one of the processors in the CPU (most often, you will have a single-processor CPU and therefore only one element in this array). The associative array for each processor itself contains information on the processor name, clock speed, cache size and other relevant values.

    Here's the output:

    Kernel 2.4.20 running on a Pentium III (Katmai) at 451.03 MhZ (512 KB cache, 897.84 bogomips)



     
     
    >>> More PHP Articles          >>> More By icarus, (c) Melonfire
     

       

    PHP ARTICLES

    - Merging a File Split for FTP Upload using PHP
    - Getting Data from Yahoo Site Explorer Inboun...
    - Method Chaining: Adding More Selecting Metho...
    - How to Split a File During an FTP Upload Usi...
    - Expanding a Custom CodeIgniter Library with ...
    - Using the Yahoo Site Explorer Inbound Links ...
    - Building a CodeIgniter Custom Library with M...
    - Building an E-mini Trading System Using PHP ...
    - Completing the MySQL Class with Method Chain...
    - Building Dynamic Queries with Chainable Meth...
    - PHP Encryption and Decryption Methods
    - Building a MySQL Abstraction Class with Meth...
    - Completing a Sample String Processor with Me...
    - Mastering WHILE Loops for PHP and MySQL
    - Method Chaining: Adding More Methods to the ...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek