PHP Classes
elePHPant
Icontem

File: index.php

Recommend this page to a friend!
  Classes of pooya sabramooz  >  PHP Check Resource Usage  >  index.php  >  Download  
File: index.php
Role: Example script
Content type: text/plain
Description: just run this file and enjoy it
Class: PHP Check Resource Usage
Retrieve the usage of machine resources
Author: By
Last change:
Date: 5 years ago
Size: 3,883 bytes
 

 

Contents

Class file image Download
<?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>