Ejemplo n.º 1
0
function perfs()
{
    include_once "ressources/class.os.system.tools.inc";
    $os = new os_system();
    $page = CurrentPageName();
    $sock = new sockets();
    $mem = $os->memory();
    $squid = new squidbee();
    $mem = $mem["ram"]["total"];
    $memory = $mem / 1000;
    $mem_cached = round($memory * 0.2);
    $cache_mem = $squid->global_conf_array["cache_mem"];
    $fqdncache_size = $squid->global_conf_array["fqdncache_size"];
    $ipcache_size = $squid->global_conf_array["ipcache_size"];
    $ipcache_low = $squid->global_conf_array["ipcache_low"];
    $ipcache_high = $squid->global_conf_array["ipcache_high"];
    if (preg_match("#([0-9]+)\\s+#", $cache_mem, $re)) {
        $cache_mem = $re[1];
    }
    $swappiness = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.swappiness"));
    //15
    $vfs_cache_pressure = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.vfs_cache_pressure"));
    //50
    $overcommit_memory = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.overcommit_memory"));
    //2
    if (preg_match("#([0-9]+)#", $overcommit_memory, $re)) {
        $overcommit_memory = $re[1];
    }
    /*
     * echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter echo 1024 65535 > /proc/sys/net/ipv4/ip_local_port_range echo 102400 > /proc/sys/net/ipv4/tcp_max_syn_backlog echo 1000000 > /proc/sys/net/ipv4/ip_conntrack_max echo 1000000 > /proc/sys/fs/file-max echo 60 > /proc/sys/kernel/msgmni echo 32768 > /proc/sys/kernel/msgmax echo 65536 > /proc/sys/kernel/msgmnb :: Maximizing Kernel configuration 
     */
    $html = "\n\t<input type='hidden' id='cache_mem' value='{$mem_cached}'>\n\t<input type='hidden' id='swappiness' value='15'>\n\t<input type='hidden' id='vfs_cache_pressure' value='50'>\n\t<input type='hidden' id='overcommit_memory' value='2'>\n\t<input type='hidden' id='fqdncache_size' value='51200'>\n\t<input type='hidden' id='ipcache_size' value='51200'>\n\t\n\t<input type='hidden' id='ipcache_low' value='90'>\n\t<input type='hidden' id='ipcache_high' value='95'>\n\t\n\t\n\t<table cellspacing='0' cellpadding='0' border='0' class='tableView'>\n\n<thead class='thead'>\n\t<tr>\n\t\t<th>&nbsp;</th>\n\t\t<th>{current_value}</th>\n\t\t<th>&nbsp;</th>\n\t\t<th>{proposal}</th>\n\t</tr>\n\n\t\t<tr class=oddRow>\n\t\t<td align='right' class=legend nowrap>squid:{cache_mem}:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$cache_mem}MB</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$mem_cached}MB</strong></td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td align='right' class=legend nowrap>{fqdncache_size}:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$fqdncache_size}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>51200</strong></td>\n\t\t</tr>\t\t\n\t\t\n\t\t\n\t\t<tr class=oddRow>\n\t\t<td align='right' class=legend nowrap>{ipcache_size}:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$ipcache_size}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>51200</strong></td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t<td align='right' class=legend nowrap>{ipcache_low}:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$ipcache_low}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>90</strong></td>\n\t\t</tr>\n\n\t\t<tr class=oddRow>\n\t\t<td align='right' class=legend nowrap>{ipcache_high}:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$ipcache_high}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>95</strong></td>\n\t\t</tr>\t\t\n\n\t\t\n\t\t<tr>\n\t\t<td align='right' class=legend nowrap>Kernel:vm.swappiness:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$swappiness}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>15</strong></td>\n\t\t</tr>\t\t\t\t\n\t\t\n\t\t<tr class=oddRow>\n\t\t<td align='right' class=legend nowrap>Kernel:vm.vfs_cache_pressure:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$vfs_cache_pressure}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>50</strong></td>\n\t\t</tr>\t\t\t\n\t\t\n\t\t\n\t\t<tr>\n\t\t<td align='right' class=legend nowrap>Kernel:vm.overcommit_memory:</strong></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>{$overcommit_memory}</td>\n\t\t<td width=1% valign='middle'><img src='img/fw_bold.gif'></td>\n\t\t<td valign='middle'><strong style='font-size:13px'>2</strong></td>\n\t\t</tr>\n\t\t\t\t\t\n\t\t</table>\n\t\t<hr>\n\t\t<div style='text-align:right'>" . button("{apply}", "SaveSquidPerfs()") . "</div>\n\t\t\n\t\t\n\t\t<script>\n\tvar x_SaveSquidPerfs=function (obj) {\n\t\tvar tempvalue=obj.responseText;\n\t\trefreshPerfs();\n\t}\t\n\t\n\tfunction SaveSquidPerfs(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('cache_mem',document.getElementById('cache_mem').value);\n\t\tXHR.appendData('swappiness',document.getElementById('swappiness').value);\n\t\tXHR.appendData('vfs_cache_pressure',document.getElementById('vfs_cache_pressure').value);\n\t\tXHR.appendData('overcommit_memory',document.getElementById('overcommit_memory').value);\n\t\t\n\t\tXHR.appendData('fqdncache_size',document.getElementById('fqdncache_size').value);\n\t\tXHR.appendData('ipcache_size',document.getElementById('ipcache_size').value);\n\t\tXHR.appendData('ipcache_low',document.getElementById('ipcache_low').value);\n\t\tXHR.appendData('ipcache_high',document.getElementById('ipcache_high').value);\n\t\t\n\t\tdocument.getElementById('squidperfs').innerHTML='<center style=\"width:100%\"><img src=img/wait_verybig.gif></center>'; \n\t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveSquidPerfs);\t\n\t}\t\t\n\t\t\n\t\t\n\t\t</script>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Ejemplo n.º 2
0
function GetSwap()
{
    $swap = new os_system();
    $swapar = $swap->swap();
    $mem = $swap->memory();
    $swap_percent = $mem["swap"]["percent"];
    $swap_used = $mem["swap"]["used"];
    $ram_free = $mem["ram"]["free"];
    $ram_total = $mem["ram"]["total"];
    $operation_disponible = $ram_free - $swap_used;
    if ($operation_disponible < 0) {
        $operation_disponible = $swap_used - $ram_free;
        $operation_disponible = "{no_memory_free_to_empty_cache} ({need}: " . FormatBytes(intval($operation_disponible)) . ")";
    }
    $maxswap = FormatBytes($swapar[2]);
    $cureswap = FormatBytes($swapar[1]);
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<div style='width:100%;text-align:right;margin-top:10px;color:#640000'>\n\t<span style='font-size:16px;font-weight:bold'>\n\tswap:&nbsp;{$cureswap}/{$maxswap} ({$swapar[0]}%) </span><hr><span style='color:red'>{$operation_disponible}</span></div>");
}
Ejemplo n.º 3
0
function perfs()
{
    include_once "ressources/class.os.system.tools.inc";
    $os = new os_system();
    $page = CurrentPageName();
    $sock = new sockets();
    $mem = $os->memory();
    $squid = new squidbee();
    $mem = $mem["ram"]["total"];
    $memory = $mem / 1000;
    $mem_cached = round($memory * 0.2);
    $cache_mem = $squid->global_conf_array["cache_mem"];
    $fqdncache_size = $squid->global_conf_array["fqdncache_size"];
    $ipcache_size = $squid->global_conf_array["ipcache_size"];
    $ipcache_low = $squid->global_conf_array["ipcache_low"];
    $ipcache_high = $squid->global_conf_array["ipcache_high"];
    if (preg_match("#([0-9]+)\\s+#", $cache_mem, $re)) {
        $cache_mem = $re[1];
    }
    $swappiness = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.swappiness"));
    //2
    //$vfs_cache_pressure=$sock->getFrameWork("cmd.php?sysctl-value=yes&key=".base64_encode("vm.vfs_cache_pressure")); //50
    $overcommit_memory = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("vm.overcommit_memory"));
    //1
    $tcp_max_syn_backlog = $sock->getFrameWork("cmd.php?sysctl-value=yes&key=" . base64_encode("net.ipv4.tcp_max_syn_backlog"));
    //4096
    if (preg_match("#([0-9]+)#", $overcommit_memory, $re)) {
        $overcommit_memory = $re[1];
    }
    /*
     * echo 1 > /proc/sys/net/ipv4/ip_forward echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter echo 1024 65535 > /proc/sys/net/ipv4/ip_local_port_range echo 102400 > /proc/sys/net/ipv4/tcp_max_syn_backlog echo 1000000 > /proc/sys/net/ipv4/ip_conntrack_max echo 1000000 > /proc/sys/fs/file-max echo 60 > /proc/sys/kernel/msgmni echo 32768 > /proc/sys/kernel/msgmax echo 65536 > /proc/sys/kernel/msgmnb :: Maximizing Kernel configuration 
     */
    $removecachepressure = "\t\t<tr >\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>Kernel:vm.vfs_cache_pressure:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$vfs_cache_pressure}</td>\n\t\t\t<td valign='middle'>" . Field_text("vfs_cache_pressure", 50, "font-size:18px;width:40px") . "</strong></td>\n\t\t</tr>";
    $html = "\n\t<input type='hidden' id='cache_mem' value='{$mem_cached}'>\n\t\n\t<input type='hidden' id='vfs_cache_pressure' value='50'>\n\t\n\t<table style='width:99%' class=form>\n\n\n\t<tr>\n\t\t<th>&nbsp;</th>\n\t\t<th>{current_value}</th>\n\t\t<th>{proposal}</th>\n\t</tr>\n\n\t\t<tr >\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>squid:{cache_mem}:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$cache_mem}MB</td>\n\t\t\t<td valign='left' style='font-size:18px'>" . Field_text("cache_mem", $mem_cached, "font-size:18px;width:70px") . "&nbsp;MB</strong></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>{fqdncache_size}:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$fqdncache_size}</td>\n\t\t\t<td valign='middle' style='font-size:18px'>" . Field_text("fqdncache_size", 51200, "font-size:18px;width:70px") . "&nbsp;{items}</strong></td>\n\t\t</tr>\t\t\n\t\t\n\t\t\n\t\t<tr >\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>{ipcache_size}:</strong></td>\n\t\t\t<td valign='middle'  align='right' style='font-size:18px;padding-right:5px'>{$ipcache_size}</td>\n\t\t\t<td valign='middle' style='font-size:18px'>" . Field_text("ipcache_size", 51200, "font-size:18px;width:70px") . "&nbsp;{items}</td>\n\t\t</tr>\n\t\t\n\t\t<tr>\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>{ipcache_low}:</strong></td>\n\t\t\t<td valign='middle'  align='right' style='font-size:18px;padding-right:5px'>{$ipcache_low}&nbsp;%</td>\n\t\t\t<td valign='middle' style='font-size:18px'>" . Field_text("ipcache_low", 90, "font-size:18px;width:60px") . "&nbsp;%</strong></td>\n\t\t</tr>\n\n\t\t<tr >\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>{ipcache_high}:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$ipcache_high}&nbsp;%</td>\n\t\t\t<td valign='middle' style='font-size:18px'>" . Field_text("ipcache_high", 95, "font-size:18px;width:40px") . "&nbsp;%</strong></td>\n\t\t</tr>\t\t\n\n\t\t\n\t\t<tr>\n\t\t<td align='right' class=legend nowrap style='font-size:16px'>Kernel:vm.swappiness:</strong></td>\n\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$swappiness}&nbsp;%</td>\n\t\t<td valign='middle' style='font-size:18px'>" . Field_text("swappiness", 5, "font-size:18px;width:40px") . "&nbsp;%</td>\n\t\t</tr>\t\t\t\t\n\t\t\n\t\t\t\n\t\t\n\t\t\n\t\t<tr>\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>Kernel:vm.overcommit_memory:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$overcommit_memory}</td>\n\t\t\t<td valign='middle'>" . Field_text("overcommit_memory", 1, "font-size:18px;width:40px") . "</strong></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' class=legend nowrap style='font-size:16px'>Kernel:net.ipv4.tcp_max_syn_backlog:</strong></td>\n\t\t\t<td valign='middle' align='right' style='font-size:18px;padding-right:5px'>{$tcp_max_syn_backlog}</td>\t\t\n\t\t\t<td valign='middle'>" . Field_text("tcp_max_syn_backlog", 4096, "font-size:18px;width:60px") . "</strong></td>\n\n\t\t</tr>\t\t\n\t\t\n\t\t\t\t\t\n\t\t</table>\n\t\t<hr>\n\t\t<div style='text-align:right'>" . button("{apply}", "SaveSquidPerfs()", 16) . "</div>\n\t\t\n\t\t\n\t\t<script>\n\tvar x_SaveSquidPerfs=function (obj) {\n\t\tvar tempvalue=obj.responseText;\n\t\trefreshPerfs();\n\t\tLoadAjax('squid-services','squid.main.quicklinks.php?squid-services=yes');\n\t}\t\n\t\n\tfunction SaveSquidPerfs(){\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('cache_mem',document.getElementById('cache_mem').value);\n\t\tXHR.appendData('swappiness',document.getElementById('swappiness').value);\n\t\t//XHR.appendData('vfs_cache_pressure',document.getElementById('vfs_cache_pressure').value);\n\t\t//XHR.appendData('overcommit_memory',document.getElementById('overcommit_memory').value);\n\t\tXHR.appendData('tcp_max_syn_backlog',document.getElementById('tcp_max_syn_backlog').value);\n\t\t\n\t\tXHR.appendData('fqdncache_size',document.getElementById('fqdncache_size').value);\n\t\tXHR.appendData('ipcache_size',document.getElementById('ipcache_size').value);\n\t\tXHR.appendData('ipcache_low',document.getElementById('ipcache_low').value);\n\t\tXHR.appendData('ipcache_high',document.getElementById('ipcache_high').value);\n\t\t\n\t\tAnimateDiv('squidperfs'); \n\t\tXHR.sendAndLoad('{$page}', 'GET',x_SaveSquidPerfs);\t\n\t}\t\t\n\t\t\n\t\t\n\t\t</script>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Ejemplo n.º 4
0
    FreeSync();
}
if ($argv[1] == '--freemem') {
    FreeMem();
}
if ($argv[1] == '--watchdog') {
    Watch();
}
include_once dirname(__FILE__) . '/framework/class.unix.inc';
if (!Build_pid_func(__FILE__, "MAIN")) {
    writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__);
    die;
}
include_once dirname(__FILE__) . "/ressources/class.os.system.tools.inc";
$os = new os_system();
$mem = $os->memory();
$swap_percent = $mem["swap"]["percent"];
$swap_used = $mem["swap"]["used"];
$ram_free = $mem["ram"]["free"];
$ram_total = $mem["ram"]["total"];
$operation_disponible = $ram_free - $swap_used;
$max = str_replace("&nbsp;", " ", FormatBytes(round($ram_total / 2)));
$swap_used = $mem["swap"]["used"];
$swap_used_mo = str_replace("&nbsp;", " ", FormatBytes($swap_used));
$ram_free_mo = FormatBytes($ram_free);
$log = "swap used: {$swap_percent}% ({$swap_used_mo}) , Max {$max} ; free memory={$ram_free_mo}, cache fore back={$operation_disponible}";
echo $log . "\n";
print_r($mem);
function events($text)
{
    $d = new debuglogs();
Ejemplo n.º 5
0
function MYSQL_AUDIT()
{
    $q = new mysql();
    include_once "ressources/class.os.system.tools.inc";
    $os = new os_system();
    $mem = $os->memory();
    $phy = round($mem["ram"]["total"] / 1000);
    $swap = round($mem["swap"]["total"] / 1000);
    $html = "<H1>{mysql_audit}</H1>\n\t<table style='width:100%' class=table_form>\n\t\t<tr>\n\t\t\t<td class=legend>{server}:</td>\n\t\t\t<td><strong>{$q->mysql_server}:{$q->mysql_port}</td>\n\t\t</tR>\n\t\t<tr>\n\t\t<td class=legend>{server_memory}:</td>\n\t\t<td> <strong>" . Field_text('server_memory', $phy, 'width:60px;font-size:14px;padding:3px') . "Mb</tD>\n\t\t</tr>\n\t\t<td class=legend>{server_swap}:</td>\n\t\t<td> <strong>" . Field_text('server_swap', $swap, 'width:60px;font-size:14px;padding:3px') . "Mb</tD>\n\t\t</tr>\t\n\t\t<tr>\n\t\t<td colspan=2 align='right'><hr>" . button("{go}", "CheckMysqlAudit()") . "\n\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t<div style='width:100%;height:300px;overflow:auto' id='mysqlaudit'></div>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html, 'mysql.index.php');
}
Ejemplo n.º 6
0
function getmem(){
		include_once("ressources/class.os.system.tools.inc");
		$os=new os_system();
		$GLOBALS["MEMORY_INSTALLED"]=$os->memory();
		$os=null;
		print_r($GLOBALS["MEMORY_INSTALLED"]);
	
}