PHP Classes

PHP Check Resource Usage: Retrieve the usage of machine resources

Recommend this page to a friend!
  Info   Example   Demos   Screenshots   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStarStar 73%Total: 948 All time: 3,795 This week: 45Up
Version License PHP version Categories
resource-usage 1.0GNU General Publi...5.0PHP 5, System information
Description 

Author

This package can retrieve the usage of machine resources.

It provides a collection of classes that can retrieve and show details of the current usage of several types of resources.

Currently it can check the usage of CPU, hard disk, RAM, OS, running processes, etc...

It works with several types of operating systems including Linux, Windows and several other UNIX flavors.

Innovation Award
PHP Programming Innovation award winner
October 2014
Winner


Prize: PhpStorm IDE personal permanent license
Monitoring the usage of server machine resources is an useful activity that server administrators often perform to check if the servers are running smoothly.

This class provides a nice visual solution that shows a dashboard of system usage resources like CPU, memory, disk space, etc..

The dashboard is refreshed continuously using AJAX requests to update the information being displayed.

Manuel Lemos
Picture of pooya sabramooz
  Performance   Level  
Name: pooya sabramooz is available for providing paid consulting. Contact pooya sabramooz .
Classes: 4 packages by
Country: Iran Iran
Age: 34
All time rank: 150319 in Iran Iran
Week rank: 215 Up2 in Iran Iran Up
Innovation award
Innovation award
Nominee: 2x

Winner: 2x

Example

<?php


####### Generated by POOYA SABRAMOOZ 2014/25/09 ################
############ Email: pooya_alen1990@yahoo.com ####################


include 'libs/class.serverInfo.php';
error_reporting(E_ALL);
ini_set('display_errors','1');
$info = new serverInfo();
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Ajax Show Resource Usage</title>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<style>

/* Tables style */

table {
    background-color: transparent;
    border: 1px solid #DDD;
    margin-bottom: 20px;
}
table > tbody > tr:nth-child(2n+1) > td, table > tbody > tr:nth-child(2n+1) > th {
    background-color: #F9F9F9;
}
table tr td , table tr th{
    border: 1px solid #DDD;
    line-height: 1.42857;
    vertical-align: top;
    border-top: 1px solid #DDD;
}
td {
    text-align: center;
}
hr{
    color:red;
    }
/* Progress Bar style */
.progress {
    height: 20px;
    overflow: hidden;
    background-color: #F5F5F5;
    border-radius: 4px;
    box-shadow: 0px 1px 2px rgba(0, 0, 0, 0.1) inset;
}

.ram,.cpu{
    color: #FFF;
    text-align: center;
    transition: width 2.0s ease 0s;
}
.ram{
    background-color: #428BCA;
}
.cpu{
    background-color: #FF6633;
}
</style>
</head>

<body>
        <table border="1">
            <tr>
                <th>OS</th>
                <td><?php echo $info->os; ?></td>
            </tr>
            <tr>
                <th>Kernel</th>
                <td><?php echo $info->kernel; ?></td>
            </tr>
            <tr>
                <th>CPU Architecture</th>
                <td><?php echo $info->CPUArchitecture; ?></td>
            </tr>
            <tr>
                <th>Thread</th>
                <td><?php echo $info->proccess['threads'];?></td>
            </tr>
            <tr>
                <th>IP</th>
                <td><?php echo $info->ip; ?></td>
            </tr>
        </table>
        <hr>
        <h4>CPU Information : </h4>
        <?php
            $i
= 1;
            echo
'<table border="1">
                    <tr>
                    <th>No.</th>
                    <th>Model</th>
                    <th>Vendor</th>
                    <th>Speed (MHz)</th>
                </tr>
            '
;
            foreach(
$info->cpu as $core){
                echo
"<tr>
                    <td>
$i</td>
                    <td>
$core[Model]</td>
                    <td>
$core[Vendor]</td>
                    <td>
$core[MHz]</td>
                </tr>"
;
               
$i++;
            }
            echo
'</table>';
       
?>

       <h5>CPU Usage Percent : </h5>
        <div class="progress" style="width:500px;">
          <div id="cpu" class="cpu" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
            <span>0</span>
          </div>
        </div>
       
        <hr>
        <h4>Physical Memory Information : </h4>
       <span>Total Ram : </span><span class="total"></span> GB<br>
       <span>Free Ram : </span><span class="free"></span> GB
       <h5>Ram Usage Percent : </h5>
        <div class="progress" style="width:500px;">
          <div id="ram" class="ram" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
            <span>0</span>%
          </div>
        </div>
                               
                               
<script>
$(document).ready(function() {
    setInterval(function(){
       
         $.post('libs/CPU.php', {CPU:'1'}, function(data){
            
                         $("#cpu").css("width",data)
                        $("#cpu span").html(data)
                                          
                    });
                   
         $.post('libs/RAM.php', {RAM:"1"}, function(response){
            
                        var responseArray = response.split('/');
            
                         $('span.total').html(responseArray[0])
                        $('span.free').html(responseArray[1])
                        $("#ram").css("width",responseArray[2]+'%')
                        $("#ram span").html(responseArray[2])
            
                    })
    }, 2000)
});
</script>
</body>
</html>


Details

To use of this package copy index.php and libs folder into server or system and run index.php , It works! enjoy It. This class can be used to retrieve the CPU load level and Memory usage and public information on a system running Linux Or Windows. This class use Linfo-1.9 and show/update information with ajax. (Runs on Linux, Windows, FreeBSD, OpenBSD, NetBSD, Darwin (Mac OS X), Solaris, Minix, Cygwin and more.)

  Scards siteExternal page  

Open in a separate window

Screenshots (2)  
  • Linux-Centos-Distro
  • Windows
  Files folder image Files (32)  
File Role Description
Files folder imagelibs (28 files)
Accessible without login Plain text file index.php Example just run this file and enjoy it
Accessible without login Plain text file readme.txt Doc. readme

  Files folder image Files (32)  /  libs  
File Role Description
  Plain text file class.CallExt.php Class libs of package
  Plain text file class.GetHddTemp.php Class base class
  Plain text file class.GetMbMon.php Class base class
  Plain text file class.GetSensord.php Class base class
  Plain text file class.HW_IDS.php Class base class
  Plain text file class.LinfoError.php Class base class
  Plain text file class.LinfoTimer.php Class base class
  Plain text file class.LinfoTimerStart.php Class base class
  Plain text file class.OS_BSD_Common.php Class base class
  Plain text file class.OS_CYGWIN.php Class base class
  Plain text file class.OS_Darwin.php Class base class
  Plain text file class.OS_DragonFly.php Class base class
  Plain text file class.OS_FreeBSD.php Class base class
  Plain text file class.OS_Linux.php Class base class
  Plain text file class.OS_Minix.php Class base class
  Plain text file class.OS_NetBSD.php Class base class
  Plain text file class.OS_OpenBSD.php Class base class
  Plain text file class.OS_SunOS.php Class base class
  Plain text file class.OS_Windows.php Class base class
  Plain text file class.out_ncurses.php Class base class
  Plain text file class.serverInfo.php Class base class
  Plain text file config.inc.php Class base class
  Plain text file CPU.php Class base class
  Accessible without login Plain text file functions.display.php Aux. base class
  Accessible without login Plain text file functions.init.php Aux. base function
  Accessible without login Plain text file functions.misc.php Aux. base function
  Plain text file interface.LinfoExtension.php Class base class
  Plain text file RAM.php Class base class

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 0%
Total:948
This week:0
All time:3,795
This week:45Up
User Ratings User Comments (1)
 All time
Utility:93%StarStarStarStarStar
Consistency:90%StarStarStarStarStar
Documentation:86%StarStarStarStarStar
Examples:90%StarStarStarStarStar
Tests:-
Videos:-
Overall:73%StarStarStarStar
Rank:123
 
very very awesome class ;)
10 years ago (Amir Mousavi)
80%StarStarStarStarStar