..a different index page for the suite. It's very easy because the only thing you need to do is change the content of default.php. I don't want to create something like hello world..
<?php
/* Displays processor usage in percents
Author: Remco Kouw
Site: http://www.hacksuite.com
Last Edit: 26-11-2014
*/
session_cache_limiter('nocache');
header('Expires: '.gmdate('r',0));
header('Content-type: application/json');
$_DYNAMIC_ROOT = "..";
include_once("../header.php");
$aDataR = array();
/* Linux and Windows CPU measurer */
function win_sys_current_cpu_usage() {
$cmd = 'typeperf -sc 1 "\Processor(_Total)\% Processor Time"';
exec($cmd, $lines, $retval);
if($retval == 0) {
$values = str_getcsv($lines[2]);
return floatval($values[1]);
} else {
return false;
}
}
function onRequestStart() {
$dat = getrusage();
define('PHP_TUSAGE', microtime(true));
define('PHP_RUSAGE', $dat["ru_utime.tv_sec"]*1e6+$dat["ru_utime.tv_usec"]);
}
function nix_sys_current_cpu_usage() {
$dat = getrusage();
$dat["ru_utime.tv_usec"] = ($dat["ru_utime.tv_sec"]*1e6 + $dat["ru_utime.tv_usec"]) - PHP_RUSAGE;
$time = (microtime(true) - PHP_TUSAGE) * 1000000;
// cpu per request
if($time > 0) {
$cpu = sprintf("%01.2f", ($dat["ru_utime.tv_usec"] / $time) * 100);
} else {
$cpu = '0.00';
}
return $cpu;
}
$aDataR['jdata'] = "CPU: ";
$aDataR['jmemory'] = "MEM: ";
if(strtoupper(substr(PHP_OS,0,3))==="WIN"){
$aDataR['jdata'] .= win_sys_current_cpu_usage();
$aOutput = array();
if(false===($sResult = @exec('tasklist /fi "PID eq '.getmypid().'"',$aOutput))){
$aDataR['jmemory'] .= "???";
}
else{
$aResult = explode(" ",$sResult);
$sMemKB = $aResult[count($aResult)-2];
$aDataR['jmemory'] .= round((intval(str_replace(".","",$sMemKB))/1024),2);
}
}
else{
onRequestStart();
$aDataR['jdata'] .= nix_sys_current_cpu_usage();
$aDataR['jmemory'] .= round(((memory_get_usage()/1024)/1024),2);
}
$aDataR['jdata'] .= "%";
$aDataR['jmemory'] .= "MB";
$aDataR['jresult'] = false;
echo json_encode($aDataR);
?>