当前位置: 首页>>代码示例>>PHP>>正文


PHP unix::TOTAL_MEMORY_MB方法代码示例

本文整理汇总了PHP中unix::TOTAL_MEMORY_MB方法的典型用法代码示例。如果您正苦于以下问题:PHP unix::TOTAL_MEMORY_MB方法的具体用法?PHP unix::TOTAL_MEMORY_MB怎么用?PHP unix::TOTAL_MEMORY_MB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unix的用法示例。


在下文中一共展示了unix::TOTAL_MEMORY_MB方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: total_memory

function total_memory()
{
    $unix = new unix();
    $mem = $unix->TOTAL_MEMORY_MB();
    writelogs_framework("TOTAL_MEMORY_MB: {$mem}", __FUNCTION__, __FILE__, __LINE__);
    echo "<articadatascgi>{$mem}</articadatascgi>";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:7,代码来源:services.php

示例2: Watch

function Watch()
{
    $unix = new unix();
    //
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "Time: {$pidTime}\n";
    }
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid}\n";
        }
        return;
    }
    $sock = new sockets();
    $SwapOffOn = unserialize(base64_decode($sock->GET_INFO("SwapOffOn")));
    if (!is_numeric($SwapOffOn["AutoMemWatchdog"])) {
        $SwapOffOn["AutoMemWatchdog"] = 1;
    }
    if (!is_numeric($SwapOffOn["AutoMemPerc"])) {
        $SwapOffOn["AutoMemPerc"] = 90;
    }
    if (!is_numeric($SwapOffOn["AutoMemInterval"])) {
        $SwapOffOn["AutoMemInterval"] = 180;
    }
    if ($SwapOffOn["AutoMemWatchdog"] == 0) {
        return;
    }
    if (!$GLOBALS["VERBOSE"]) {
        $timefile = $unix->file_time_min($pidTime);
        if ($timefile < $SwapOffOn["AutoMemInterval"]) {
            return;
        }
    }
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    $TOTAL_MEMORY_MB_FREE = $unix->TOTAL_MEMORY_MB_FREE();
    $TOTAL_MEM_POURCENT_USED = $unix->TOTAL_MEM_POURCENT_USED();
    $TOTAL_MEMORY = $unix->TOTAL_MEMORY_MB();
    $SwapOffOn["CURRENT"] = "Before operation: Server memory {$TOTAL_MEMORY}MB {$TOTAL_MEMORY_MB_FREE}Mb Free used {$TOTAL_MEM_POURCENT_USED}%";
    if ($GLOBALS["VERBOSE"]) {
        echo "TOTAL_MEM_POURCENT_USED = {$TOTAL_MEM_POURCENT_USED} / {$SwapOffOn["AutoMemPerc"]}% FREE: {$TOTAL_MEMORY_MB_FREE}MB\n";
    }
    if ($TOTAL_MEM_POURCENT_USED > $SwapOffOn["AutoMemPerc"]) {
        FreeMem(true, $SwapOffOn);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:49,代码来源:exec.swap-monitor.php

示例3: date

    echo "Starting......: " . date("H:i:s") . " artica-background Already executed pid {$pid}\n";
    die;
}
if ($argv[1] == "--manual") {
    FillMemory();
    die;
}
$sock = new sockets();
$EnableArticaBackground = $sock->GET_INFO("EnableArticaBackground");
if (!is_numeric($EnableArticaBackground)) {
    $EnableArticaBackground = 1;
}
if ($EnableArticaBackground == 0) {
    die;
}
$GLOBALS["TOTAL_MEMORY_MB"] = $unix->TOTAL_MEMORY_MB();
if ($GLOBALS["TOTAL_MEMORY_MB"] < 400) {
    $pid = @file_get_contents($GLOBALS["EXEC_PID_FILE"]);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        events("Process Already exist pid {$pid}");
        die;
    }
    $childpid = posix_getpid();
    echo "Starting......: " . date("H:i:s") . " artica-background lower config, remove fork\n";
    @file_put_contents($GLOBALS["EXEC_PID_FILE"], $childpid);
    FillMemory();
    $renice_bin = $GLOBALS["CLASS_UNIX"]->find_program("renice");
    events("{$renice_bin} 19 {$childpid}", __FUNCTION__, __LINE__);
    shell_exec('export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11 &');
    shell_exec("{$renice_bin} 19 {$childpid} &");
    events("Started pid {$childpid}", __FUNCTION__, __LINE__);
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.parse-orders.php

示例4: ufdbdatabases_in_mem

function ufdbdatabases_in_mem()
{
    $sock = new sockets();
    $unix = new unix();
    $UfdbDatabasesInMemory = $sock->GET_INFO("UfdbDatabasesInMemory");
    if (!is_numeric($UfdbDatabasesInMemory)) {
        $UfdbDatabasesInMemory = 0;
    }
    if ($UfdbDatabasesInMemory == 0) {
        echo "Starting URLfilterDB Database in memory feature is disabled\n";
        $MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
        if ($MOUNTED_DIR_MEM > 0) {
            echo "Starting URLfilterDB Database unmounting...\n";
            $umount = $unix->find_program("umount");
            shell_exec("{$umount} -l /var/lib/ufdbguard-memory");
        }
        return;
    }
    $POSSIBLEDIRS[] = "/var/lib/ufdbartica";
    $POSSIBLEDIRS[] = "/var/lib/squidguard";
    $POSSIBLEDIRS[] = "/var/lib/ftpunivtlse1fr";
    $ufdbartica_size = $unix->DIRSIZE_BYTES("/var/lib/ufdbartica");
    $ufdbartica_size = round($ufdbartica_size / 1024 / 1000) + 5;
    $squidguard_size = $unix->DIRSIZE_BYTES("/var/lib/squidguard");
    $squidguard_size = round($squidguard_size / 1024 / 1000) + 5;
    $ftpunivtlse1fr_size = $unix->DIRSIZE_BYTES("/var/lib/ftpunivtlse1fr");
    $ftpunivtlse1fr_size = round($ftpunivtlse1fr_size / 1024 / 1000) + 5;
    echo "Starting URLfilterDB ufdbartica DB....: about {$ufdbartica_size}MB\n";
    echo "Starting URLfilterDB squidguard DB....: about {$squidguard_size}MB\n";
    echo "Starting URLfilterDB ftpunivtlse1fr DB: about {$ftpunivtlse1fr_size}MB\n";
    $total = $ufdbartica_size + $squidguard_size + $ftpunivtlse1fr_size + 10;
    echo "Starting URLfilterDB require {$total}MB\n";
    $mount = $unix->find_program("mount");
    $MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
    if ($MOUNTED_DIR_MEM == 0) {
        $system_mem = $unix->TOTAL_MEMORY_MB();
        echo "Starting URLfilterDB system memory {$system_mem}MB\n";
        if ($system_mem < $total) {
            $require = $total - $system_mem;
            echo "Starting URLfilterDB not engough memory require at least {$require}MB\n";
            return;
        }
        $system_free = $unix->TOTAL_MEMORY_MB_FREE();
        echo "Starting URLfilterDB system memory available {$system_free}MB\n";
        if ($system_free < $total) {
            $require = $total - $system_free;
            echo "Starting URLfilterDB not engough memory require at least {$require}MB\n";
            return;
        }
    }
    $idbin = $unix->find_program("id");
    $mount = $unix->find_program("mount");
    $umount = $unix->find_program("umount");
    $rm = $unix->find_program("rm");
    $cp = $unix->find_program("cp");
    $chown = $unix->find_program("chown");
    if ($MOUNTED_DIR_MEM > 0) {
        if ($MOUNTED_DIR_MEM < $total) {
            echo "Starting URLfilterDB: umounting from memory\n";
            shell_exec("{$umount} -l /var/lib/ufdbguard-memory");
            $MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
        }
    }
    if ($MOUNTED_DIR_MEM == 0) {
        if (strlen($idbin) < 3) {
            echo "Starting URLfilterDB: tmpfs `id` no such binary\n";
            return;
        }
        if (strlen($mount) < 3) {
            echo "Starting URLfilterDB: tmpfs `mount` no such binary\n";
            return;
        }
        exec("{$idbin} squid 2>&1", $results);
        if (!preg_match("#uid=([0-9]+).*?gid=([0-9]+)#", @implode("", $results), $re)) {
            echo "Starting......: " . date("H:i:s") . "MySQL mysql no such user...\n";
            return;
        }
        $uid = $re[1];
        $gid = $re[2];
        echo "Starting URLfilterDB: tmpfs uid/gid ={$uid}:{$gid} for {$total}M\n";
        @mkdir("/var/lib/ufdbguard-memory");
        $cmd = "{$mount} -t tmpfs -o rw,uid={$uid},gid={$gid},size={$total}M,nr_inodes=10k,mode=0700 tmpfs \"/var/lib/ufdbguard-memory\"";
        shell_exec($cmd);
        $MOUNTED_DIR_MEM = $unix->MOUNTED_TMPFS_MEM("/var/lib/ufdbguard-memory");
        if ($MOUNTED_DIR_MEM == 0) {
            echo "Starting URLfilterDB: tmpfs failed...\n";
            return;
        }
    }
    echo "Starting URLfilterDB: mounted as {$MOUNTED_DIR_MEM}MB\n";
    reset($POSSIBLEDIRS);
    while (list($index, $directory) = each($POSSIBLEDIRS)) {
        $directoryname = basename($directory);
        @mkdir("/var/lib/ufdbguard-memory/{$directoryname}", 0755, true);
        if (!is_dir("/var/lib/ufdbguard-memory/{$directoryname}")) {
            echo "Starting URLfilterDB: {$directoryname} permission denied\n";
            return;
        }
        @chown("/var/lib/ufdbguard-memory/{$directoryname}", "squid");
        echo "Starting URLfilterDB: replicating {$directoryname}\n";
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squidguard.php

示例5: xscan

function xscan()
{
    $ARRAY = array();
    $sock = new sockets();
    $unix = new unix();
    $Pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $PidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    // /etc/artica-postfix/pids/exec.clean.logs.php.squidClean.time
    if ($GLOBALS["VERBOSE"]) {
        echo "Pidfile: {$Pidfile}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "PidTime: {$PidTime}\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "Memory Free: " . $unix->TOTAL_MEMORY_MB_FREE() . "/" . $unix->TOTAL_MEMORY_MB() . "\n";
        echo "Memory Use: " . $unix->TOTAL_MEMORY_MB_USED() . " - " . $unix->TOTAL_MEM_POURCENT_USED() . "%\n";
    }
    $pid = $unix->get_pid_from_file($Pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Aborting Task already running pid {$pid} " . __FUNCTION__ . "()\n";
        }
        return;
    }
    if (!$GLOBALS["FORCE"]) {
        $TimeExec = $unix->file_time_min($PidTime);
        if ($TimeExec < 20) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Aborting Task {$TimeExec}mn, require 20mn " . __FUNCTION__ . "()\n";
            }
            return;
        }
    }
    @unlink($PidTime);
    @file_put_contents($PidTime, time());
    @file_put_contents($Pidfile, getmypid());
    xscan2();
    $q = new mysql_storelogs();
    $LogRotatePath = $sock->GET_INFO("LogRotatePath");
    $SystemLogsPath = $sock->GET_INFO("SystemLogsPath");
    $BackupMaxDays = intval($sock->GET_INFO("BackupMaxDays"));
    $BackupMaxDaysDir = $sock->GET_INFO("BackupMaxDaysDir");
    if ($BackupMaxDaysDir == null) {
        $BackupMaxDaysDir = "/home/logrotate_backup";
    }
    if (!is_dir("{$BackupMaxDaysDir}")) {
        @mkdir("{$BackupMaxDaysDir}", true);
    }
    if ($BackupMaxDays == 0) {
        $BackupMaxDays = 30;
    }
    $BackupLogsMaxStoragePercent = intval($sock->GET_INFO("BackupLogsMaxStoragePercent"));
    if ($BackupLogsMaxStoragePercent == 0) {
        $BackupLogsMaxStoragePercent = 50;
    }
    $BackupMaxDaysMins = $BackupMaxDays * 1440;
    echo "Max TTL : {$BackupMaxDaysMins} Minutes\n";
    $files = $unix->DirFiles($BackupMaxDaysDir);
    while (list($filepath, $none) = each($files)) {
        $filename = "{$BackupMaxDaysDir}/{$filepath}";
        $filetime = $unix->file_time_min($filename);
        echo "{$filepath} = {$filetime}/{$BackupMaxDaysMins}\n";
        if ($filetime > $BackupMaxDaysMins) {
            rotate_admin_events("Removed {$filepath} {$filetime}mn, exceed {$BackupMaxDays} days", __FUNCTION__, __FILE__, __LINE__);
            @unlink($filename);
            continue;
        }
        $filesecs = filemtime($filename);
        $ARRAY[$filesecs] = $filepath;
    }
    $DIRPART_INFO = $unix->DIRPART_INFO($BackupMaxDaysDir);
    $TOTAL_PART = $DIRPART_INFO["TOT"];
    $percent = $BackupLogsMaxStoragePercent / 100;
    $TOTAL_AVAILABLE = $TOTAL_PART * $percent;
    $DIRSIZE = $unix->DIRSIZE_BYTES($BackupMaxDaysDir);
    $TOTAL_PART = $DIRPART_INFO["TOT"] / 1024;
    $q->events("Directory size = {$DIRSIZE}/{$TOTAL_AVAILABLE} " . FormatBytes($DIRSIZE / 1024, true) . "/" . FormatBytes($TOTAL_AVAILABLE / 1024, true), __FUNCTION__, __LINE__);
    if ($DIRSIZE > $TOTAL_AVAILABLE) {
        CleanPercent($BackupMaxDaysDir, $TOTAL_AVAILABLE);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:82,代码来源:exec.clean-logs-backup.php

示例6: squid_frontend

function squid_frontend()
{
    $sock = new sockets();
    $page = CurrentPageName();
    $SQUIDEnable = $sock->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    $AsSeenPerformanceFeature = intval($sock->GET_INFO("AsSeenPerformanceFeature"));
    $SquidPerformanceRemoveNotice = intval($sock->GET_INFO("SquidPerformanceRemoveNotice"));
    if ($SQUIDEnable == 0) {
        return;
    }
    if ($SquidPerformance < 2) {
        $addon = "<div id='squid-rttrqs-status'></div>";
    }
    $addonUfdBcat = "OnMouseOver=\"this.style.cursor='pointer'\"  OnMouseOut=\"this.style.cursor='default';\" OnClick=\"javascript:AnimateDiv('BodyContent');LoadAjax('BodyContent','squid.global.performance.php')\"";
    if ($AsSeenPerformanceFeature == 0) {
        $tpl = new templates();
        echo $tpl->_ENGINE_parse_body("<div class='explain' style='padding:5px;font-size:18px;' {$addonUfdBcat} >{SquidAsSeenPerformanceFeature}</div>");
    }
    if ($SquidPerformance == 0) {
        if ($SquidPerformanceRemoveNotice == 0) {
            if ($GLOBALS["AS_ROOT"]) {
                $unix = new unix();
                $MEMORY = $unix->TOTAL_MEMORY_MB();
            } else {
                $MEMORY = intval($sock->getFrameWork("cmd.php?GetTotalMemMB=yes"));
            }
            if ($MEMORY > 5) {
                if ($MEMORY < 4500) {
                    echo "<div id='error-squid-memory-notice'>" . FATAL_ERROR_SHOW_128("\n\t\t\t\t<strong style='font-size:22px'>{$MEMORY}MB/5900MB</strong>\n\t\t\t\t<hr>\n\t\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:AnimateDiv('BodyContent');LoadAjax('BodyContent','squid.global.performance.php')\">{server_did_not_have_enough_memory_ufdbcat}</a>\n\t\t\t\t<div style='text-align:right;margin-top:10px'><a href=\"javascript:blur();\" OnClick=\"javascript:Loadjs('{$page}?remove-performance-alert=yes');\" style='text-decoration:underline'>{remove_this_notice}</a></div>\n\t\t\t\t") . "</div>";
                }
            }
        }
    }
    if ($GLOBALS["AS_ROOT"]) {
        $unix = new unix();
        $unix->SQUID_ACTIVE_REQUESTS();
    } else {
        $sock->getFrameWork("squid.php?active-requests=yes");
    }
    $page = CurrentPageName();
    echo "\n\t<div id='squid-front-end-status'></div>\n\t{$addon}\n\t\t<script>LoadAjaxTiny('squid-front-end-status','{$page}?squid-front-end-status=yes');\n\t</script>";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:46,代码来源:admin.index.loadvg.php

示例7: FillMemory

function FillMemory(){
	$unix=new unix();
	$GLOBALS["TIME"]=unserialize(@file_get_contents("/etc/artica-postfix/pids/".basename(__FILE__).".GLOBALS"));
	
	
	if(GET_INFO_DAEMON("cpuLimitEnabled")==1){$GLOBALS["cpuLimitEnabled"]=true;}else{$GLOBALS["cpuLimitEnabled"]=false;}
	$_GET["NICE"]=$unix->EXEC_NICE();
	$GLOBALS["PHP5"]=$unix->LOCATE_PHP5_BIN();
	$GLOBALS["SU"]=$unix->find_program("su");
	
	$users=new settings_inc();
	$sock=new sockets();
	$GLOBALS["SQUID_INSTALLED"]=$users->SQUID_INSTALLED;
	$GLOBALS["POSTFIX_INSTALLED"]=$users->POSTFIX_INSTALLED;
	$GLOBALS["SAMBA_INSTALLED"]=$users->SAMBA_INSTALLED;
	$GLOBALS["GREYHOLE_INSTALLED"]=$users->GREYHOLE_INSTALLED;
	$GLOBALS["MUNIN_CLIENT_INSTALLED"]=$users->SAMBA_INSTALLED;
	$GLOBALS["CYRUS_IMAP_INSTALLED"]=$users->cyrus_imapd_installed;
	$_GET["MIME_DEFANGINSTALLED"]=$users->MIMEDEFANG_INSTALLED;
	$GLOBALS["DANSGUARDIAN_INSTALLED"]=$users->DANSGUARDIAN_INSTALLED;
	$GLOBALS["OPENVPN_INSTALLED"]=$users->OPENVPN_INSTALLED;
	$GLOBALS["OCS_INSTALLED"]=$users->OCSI_INSTALLED;
	$GLOBALS["UFDBGUARD_INSTALLED"]=$users->APP_UFDBGUARD_INSTALLED;
	$GLOBALS["KAS_INSTALLED"]=$users->kas_installed;
	$GLOBALS["ZARAFA_INSTALLED"]=$users->ZARAFA_INSTALLED;
	$GLOBALS["XAPIAN_PHP_INSTALLED"]=$users->XAPIAN_PHP_INSTALLED;
	$GLOBALS["AUDITD_INSTALLED"]=$users->APP_AUDITD_INSTALLED;
	$GLOBALS["VIRTUALBOX_INSTALLED"]=$users->VIRTUALBOX_INSTALLED;
	if($GLOBALS["VERBOSE"]){writelogs("DANSGUARDIAN_INSTALLED={$GLOBALS["DANSGUARDIAN_INSTALLED"]}","MAIN",__FILE__,__LINE__);}
	$GLOBALS["EnableArticaWatchDog"]=GET_INFO_DAEMON("EnableArticaWatchDog");
	if($GLOBALS["VERBOSE"]){if($GLOBALS["POSTFIX_INSTALLED"]){events("Postfix is installed...");}}
	if($GLOBALS["VERBOSE"]){events("Nice=\"\", php5 {$GLOBALS["PHP5"]}");}	
	$GLOBALS["EnableInterfaceMailCampaigns"]=$sock->GET_INFO("EnableInterfaceMailCampaigns");
	$GLOBALS["CLASS_SOCKETS"]=$sock;
	$GLOBALS["TOTAL_MEMORY_MB"]=$unix->TOTAL_MEMORY_MB();
	$sock=null;
	$unix=null;
	$users=null;
	
	
	}
开发者ID:rsd,项目名称:artica-1.5,代码行数:41,代码来源:exec.executor.php


注:本文中的unix::TOTAL_MEMORY_MB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。