コード例 #1
0
ファイル: stats.php プロジェクト: BlackPearl01/quick-box
    return "in: " . addUnits($rbps) . ", out: " . addUnits($tbps) . "";
}
function get_server_mem_usage()
{
    $free = shell_exec('free -b');
    $free = (string) trim($free);
    $free_arr = explode("\n", $free);
    $mem = explode(" ", $free_arr[1]);
    $mem = array_filter($mem);
    $mem = array_merge($mem);
    $memory_usage = $mem[2] - $mem[5] / $mem[1] * 100;
    return $memory_usage;
}
function get_server_uptime()
{
    $data = shell_exec('uptime');
    $uptime = explode(' up ', $data);
    $uptime = explode(',', $uptime[1]);
    $uptime = $uptime[0] . ', ' . $uptime[1];
    return $uptime;
}
function get_server_cpu_usage()
{
    $load = sys_getloadavg();
    return $load[0];
}
$bw = get_bandwidth();
$hostname = shell_exec('hostname');
$output = '{"cpuload":"' . get_server_cpu_usage() . '","memory:"' . addUnits(get_server_mem_usage()) . '","bandwidth:"' . get_bandwidth() . '"}';
$data = "<tbody><tr><td>" . $hostname . "</td><td>" . get_server_cpu_usage() . "</td><td>" . addUnits(get_server_mem_usage()) . "</td><td>" . get_bandwidth() . "</td><td>" . get_server_uptime() . "</td></tr></tbody>";
echo $data;
コード例 #2
0
ファイル: api.php プロジェクト: JoaoReis98/cyber-panel
             $server = new Servidor($Servidor['Id'], $conn);
             $server->getFullStatus();
             // Fazer update aos Status
             $total += $server->getSlots();
         }
         $SlotsUsadosTotal = $total;
         $ServidoresOnline = count(getServidoresByIdUtilizadorAndStatus($User->getId(), 1));
         $ServidoresOffline = count(getServidoresByIdUtilizadorAndStatus($User->getId(), 0));
         echo json_encode(array("Status" => true, "ServidoresOnline" => $ServidoresOnline, "ServidoresOffline" => $ServidoresOffline, "SlotsUsadosTotal" => $SlotsUsadosTotal));
         die;
     } elseif ($Pedido == "GETPORTAS" && isset($_GET['Porta'])) {
         echo json_encode(array("Status" => true, "EmUso" => isPortaEmUso($_GET['Porta'])));
         die;
     } elseif ($Pedido == "INFOMAQUINA") {
         if ($User->getTipoUtilizador() == 1) {
             echo json_encode(array("Status" => true, "Ram" => number_format((double) get_server_memory_usage(), 2, '.', ''), "Cpu" => number_format((double) get_server_cpu_usage(), 2, '.', ''), "Disco" => number_format((double) get_server_disk_usage(), 2, '.', '')));
             die;
         } else {
             echo json_encode(array("Status" => false, "Mensagem" => $Lang['api_acessoNegado']));
             die;
         }
     }
 }
 if (isset($_GET['Action'])) {
     $Pedido = $_GET['Action'];
     if ($Pedido == "CriarServidor") {
         $User->getInfo();
         if ($User->getNumeroMaxServidores() > $User->getNumeroServidores()) {
             $TipoServer = array();
             if (tipoServidorExisteById($_GET['TipoServidor'])) {
                 $TipoServer = getTipoServidorById($_GET['TipoServidor']);
コード例 #3
0
ファイル: process.php プロジェクト: johnjohnsp1/dvws
                    <div class="col-lg-12">

    <h1>XML Bomb Denial-of-Service</h1>
    
    </html>
<?php 
$simple = $_POST['name'];
$p = xml_parser_create();
xml_parse_into_struct($p, $simple, $vals, $index);
xml_parser_free($p);
echo "<br><br>The following array was created from your XML data\n <br><br>";
print_r($index);
echo "\nVals array\n";
print_r($vals);
get_server_memory_usage();
get_server_cpu_usage();
function get_server_memory_usage()
{
    //shows server memory usage
    if (stristr(PHP_OS, 'Linux')) {
        $free = shell_exec('free');
        $free = (string) trim($free);
        $free_arr = explode("\n", $free);
        $mem = explode(" ", $free_arr[1]);
        $mem = array_filter($mem);
        $mem = array_merge($mem);
        $memory_usage = $mem[2] / $mem[1] * 100;
        print "<br><br><br> The server memory usage is " . $memory_usage;
    } else {
        $cmd = 'typeperf  -sc 1  "\\Processor(_Total)\\% Processor Time"';
        exec($cmd, $lines, $retval);
コード例 #4
0
     $items = array('eettafel', 'zithoek');
     foreach ($items as $item) {
         if (${'DT' . $item} < $uit - mt_rand(0, 600)) {
             Schakel(${'DI' . $item}, 'Off', $item . ' ' . $msg);
         }
     }
     $items = array('living', 'badkamer', 'kamer', 'tobi', 'julius');
     foreach ($items as $item) {
         ${'setpoint' . $item} = $mc->get('setpoint' . $item);
         if (${'setpoint' . $item} != 0 && ${'RT' . $item} < $uit) {
             $mc->set('setpoint' . $item, 0);
         }
     }
 }
 $rpimem = number_format(get_server_memory_usage(), 2);
 $rpicpu = number_format(get_server_cpu_usage(), 2);
 if (date('G') == 3) {
     if ($rpimem > 70) {
         telegram('PiDomoticz ' . $rpimem . '% memory usage, clearing');
         shell_exec('/var/www/secure/freememory.sh');
         sleep(5);
         $rpimem = number_format(get_server_memory_usage(), 2);
     }
     if ($rpimem > 70 || $rpicpu > 2 || $preverrors > 10) {
         telegram('Rebooting Domoticz: ' . $preverrors . ' errors, ' . $rpimem . ' memory, ' . $rpicpu . ' cpu');
         if ($rpimem > 90) {
             shell_exec('/var/www/secure/reboot');
         }
     }
 } else {
     if ($rpimem > 70) {
コード例 #5
0
<?php

function get_server_memory_usage()
{
    $free = shell_exec('free');
    $free = (string) trim($free);
    $free_arr = explode("\n", $free);
    $mem = explode(" ", $free_arr[1]);
    $mem = array_filter($mem);
    $mem = array_merge($mem);
    $memory_usage = $mem[2] / $mem[1] * 100;
    return $memory_usage;
}
function get_server_cpu_usage()
{
    $load = sys_getloadavg();
    return $load[0];
}
function get_server_cpu_temp()
{
    return 0;
}
function get_server_disk_space()
{
    return disk_total_space("/media/ssd");
}
$jarr = array('cpu_usage' => get_server_cpu_usage(), 'cpu_temp' => get_server_cpu_temp(), 'memory' => get_server_memory_usage(), 'disk_space' => get_server_disk_space());
echo json_encode($jarr);
?>

コード例 #6
0
ファイル: about.php プロジェクト: rudybrian/fpp
              >  <input type='button' value='Manual Update' onClick='location.href="manualUpdate.php";' class='buttons' id='ManualUpdate'></td></tr>
<!--
            <tr><td>Developer Mode:</td><td><input type='checkbox' id='developerMode' onChange='ToggleDeveloperMode();'
<?php 
if (file_exists($mediaDirectory . "/.developer_mode")) {
    ?>
            checked
<?php 
}
?>
              ></td></tr>
-->
            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
            <tr><td><b>System Utilization</b></td><td>&nbsp;</td></tr>
            <tr><td>CPU Usage:</td><td><?php 
printf("%.2f", get_server_cpu_usage());
?>
%</td></tr>
            <tr><td>Memory Usage:</td><td><?php 
printf("%.2f", get_server_memory_usage());
?>
%</td></tr>

            <tr><td>&nbsp;</td><td>&nbsp;</td></tr>
            <tr><td><b>Uptime</b></td><td>&nbsp;</td></tr>
            <tr><td colspan='2'><?php 
echo $uptime;
?>
</td></tr>

          </table>
コード例 #7
0
    $nginx = file_get_contents('http://address.com/nginx_status');
    // nginx_status?? -> http://www.cyberciti.biz/faq/nginx-enable-and-see-current-status-page/
    $nginx = trim(preg_replace('/\\s\\s+/', ' ', $nginx));
    $n_lines_analyse = 500;
    $output_first = shell_exec('tail -' . $n_lines_analyse . ' /var/log/nginx/access.log');
    $outputarray = explode("\n", $output_first);
    $last_line = $outputarray[$n_lines_analyse - 1];
    usleep(200000);
    $output_next = shell_exec('tail -' . $n_lines_analyse . ' /var/log/nginx/access.log');
    $outputarraycheck = explode("\n", $output_next);
    $klucz = array_search($last_line, $outputarraycheck);
    $real_qps = $n_lines_analyse - $klucz - 1;
    $real_qps = $real_qps * 5;
    $realDate = date('m/d/Y h:i:s a', time());
    $duration = microtime(true) - $starttime;
    echo '{"status":"success", "nginx":"' . $nginx . '", "debug":"' . $duration . '", "la":"' . get_server_cpu_usage() . '", "mem":"' . get_server_memory_usage() . '", "cpu":"' . $usage . '", "r/s":"' . $real_qps . '", "date":"' . $realDate . '"}';
} else {
    echo 'INVALID SIGNATURE';
}
function get_server_memory_usage()
{
    $free = shell_exec('free');
    $free = (string) trim($free);
    $free_arr = explode("\n", $free);
    $mem = explode(" ", $free_arr[1]);
    $mem = array_filter($mem);
    $mem = array_merge($mem);
    $memory_usage = $mem[2] / $mem[1] * 100;
    return $memory_usage;
}
function get_server_cpu_usage()
コード例 #8
0
ファイル: index.php プロジェクト: pest14/telecube-pbx

		<?php 
include $_SERVER["DOCUMENT_ROOT"] . "/includes/top-menu.php";
?>

		<div class="container">

			<h1><span class="glyphicon glyphicon-dashboard"></span> Telecube Cloud PBX</h1>
			
			<?php 
echo "<p>" . date("H:i:s") . "</p>";
?>

			<?php 
echo "<p>" . get_server_cpu_usage() . "</p>";
?>

			<?php 
echo "<p>" . round(get_server_memory_usage(), 2) . "</p>";
?>


			<div class="panel panel-default">
			  <div class="panel-heading">
			    <h3 class="panel-title">Dummy CPU Usage (Not Real Usage!)</h3>
			  </div>
			  <div class="panel-body">


		<span id="memoryGaugeContainer"></span>
コード例 #9
0
ファイル: column2.php プロジェクト: petrospe/frog
        $ActiveCustomers = Yii::app()->db->createCommand()->select(array('count(*)'))->from('almab_customers')->where('updateto > NOW()')->queryRow();
        return $ActiveCustomers;
    }
    //Inactive Customers
    function getInactiveCustomers()
    {
        $InactiveCustomers = Yii::app()->db->createCommand()->select(array('count(*)'))->from('almab_customers')->where('updateto < NOW()')->queryRow();
        return $InactiveCustomers;
    }
    //Users
    function getTotalUsers()
    {
        $TotalUsers = Yii::app()->db->createCommand()->select(array('sum(SUBSTRING_INDEX(SUBSTRING_INDEX(dbserial, "-", 2), "-", -1))'))->from('almab_customers')->where('descr IS NOT NULL')->queryRow();
        return $TotalUsers;
    }
    echo "<table class='table table-striped table-bordered'>\r\n                <tbody>\r\n                  <tr>\r\n                    <td width='50%'>Bandwith Usage</td>\r\n                    <td>\r\n                      <div class='progress progress-danger'>\r\n                        <div class='bar' style='width: " . $speed * 100 / 4 . "%'></div>\r\n                      </div>\r\n                    </td>\r\n                  </tr>\r\n                  <tr>\r\n                    <td>Disk Space</td>\r\n                    <td>\r\n                      <div class='progress progress-warning'>\r\n                        <div class='bar' style='width: " . $df * 100 / $ds . "%'></div>\r\n                      </div>\r\n                    </td>\r\n                  </tr>\r\n                  <tr>\r\n                    <td>Memory Usage</td>\r\n                    <td>\r\n                      <div class='progress progress-success'>\r\n                        <div class='bar' style='width: " . $memuse * 100 / 128 . "%'></div>\r\n                      </div>\r\n                    </td>\r\n                  </tr>\r\n                  <tr>\r\n                    <td>CPU load</td>\r\n                    <td>\r\n                      <div class='progress progress-info'>\r\n                        <div class='bar' style='width: " . get_server_cpu_usage() . "%'></div>\r\n                      </div>\r\n                    </td>\r\n                  </tr>\r\n                </tbody>\r\n              </table>     \r\n\t<div class='well'>\r\n                <dl class='dl-horizontal'>\r\n                  <dt>Total Customers</dt>\r\n                  <dd>" . implode("", getAllCustomers()) . "</dd>\r\n                  <dt>Ongoing Services</dt>\r\n                  <dd>" . implode("", getActiveCustomers()) . "</dd>\r\n                  <dt>Overdue Services</dt>\r\n                  <dd>" . implode("", getInactiveCustomers()) . "</dd>\r\n                  <dt>Total Users</dt>\r\n                  <dd>" . implode("", getTotalUsers()) . "</dd>\r\n                </dl>\r\n            </div>";
}
?>
    </div><!--/span-->
    <div <?php 
Yii::app()->user->isSuperuser ? print 'class="span9"' : (print '');
?>
>
    
    <?php 
if (isset($this->breadcrumbs)) {
    ?>
		<?php 
    $this->widget('zii.widgets.CBreadcrumbs', array('links' => $this->breadcrumbs, 'homeLink' => CHtml::link('Dashboard', Yii::app()->homeUrl), 'htmlOptions' => array('class' => 'breadcrumb')));
    ?>
<!-- breadcrumbs -->