示例#1
0
             $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']);
示例#2
0
                <div class="row">
                    <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"';
     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) {
         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 > 90 || $rpicpu > 2 || $preverrors > 50) {
         telegram('Rebooting Domoticz: ' . $preverrors . ' errors, ' . $rpimem . ' memory, ' . $rpicpu . ' cpu');
         $rpimem = number_format(get_server_memory_usage(), 2);
         if ($rpimem > 90) {
             shell_exec('/var/www/secure/reboot');
         }
     }
 }
 $rains = file_get_contents('http://gps.buienradar.nl/getrr.php?lat=50.892880&lon=3.112568');
 $rains = str_split($rains, 11);
 $totalrain = 0;
 $aantal = 0;
 foreach ($rains as $rain) {
     $aantal = $aantal + 1;
     $totalrain = $totalrain + substr($rain, 0, 3);
     $averagerain = round($totalrain / $aantal, 0);
     if ($aantal == 12) {
         break;
<?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);
?>

示例#5
0
文件: about.php 项目: rudybrian/fpp
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>
        </div>
        <div class='aboutCenter'>
        </div>
        <div class='aboutRight'>
    $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()
示例#7
0
?>

		<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>
		<span id="cpuGaugeContainer"></span>
		<span id="networkGaugeContainer"></span>
		<span id="testGaugeContainer"></span>
示例#8
0
<?php

$load = sys_getloadavg();
$cpuUsage = $load[0];
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 substr($memory_usage, 0, 2);
}
$data = shell_exec('uptime');
$uptime = explode(' up ', $data);
$uptime = explode(',', $uptime[1]);
$uptime = $uptime[0];
$a = shell_exec('ifstat -q 3 1 | grep "\\." | awk \'BEGIN { FS=" " } { print $1","$2 }\'');
$a = explode(",", $a);
$net = $a[0] + $a[1];
$result = array('load' => $cpuUsage, 'mem' => (int) get_server_memory_usage(), 'uptime' => $uptime, 'net' => $net / 2.0 * 100);
echo json_encode($result);