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


PHP systemMaxOverloaded函数代码示例

本文整理汇总了PHP中systemMaxOverloaded函数的典型用法代码示例。如果您正苦于以下问题:PHP systemMaxOverloaded函数的具体用法?PHP systemMaxOverloaded怎么用?PHP systemMaxOverloaded使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: status_all_mysql_engines

function status_all_mysql_engines()
{
    $unix = new unix();
    if (systemMaxOverloaded()) {
        return;
    }
    $cachefile = "/usr/share/artica-postfix/ressources/logs/web/MYSQLDB_STATUS";
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($cachefile);
        if ($time < 60) {
            return;
        }
    }
    $sock = new sockets();
    $datadir = $unix->MYSQL_DATA_DIR();
    $ArticaDBPath = $sock->GET_INFO("ArticaDBPath");
    if ($ArticaDBPath == null) {
        $ArticaDBPath = "/opt/articatech";
    }
    $SquidStatsDatabasePath = $sock->GET_INFO("SquidStatsDatabasePath");
    if ($SquidStatsDatabasePath == null) {
        $SquidStatsDatabasePath = "/opt/squidsql";
    }
    $array["APP_MYSQL_ARTICA"]["size"] = $unix->DIRSIZE_BYTES($datadir);
    $array["APP_MYSQL_ARTICA"]["INFO"] = $unix->DIRPART_INFO($datadir);
    if (is_dir("{$ArticaDBPath}/mysql")) {
        $array["APP_ARTICADB"]["size"] = $unix->DIRSIZE_BYTES("{$ArticaDBPath}");
        $array["APP_ARTICADB"]["INFO"] = $unix->DIRPART_INFO("{$ArticaDBPath}");
    }
    if (is_dir("{$SquidStatsDatabasePath}/data")) {
        $array["APP_SQUID_DB"]["size"] = $unix->DIRSIZE_BYTES("{$SquidStatsDatabasePath}");
        $array["APP_SQUID_DB"]["INFO"] = $unix->DIRPART_INFO("{$SquidStatsDatabasePath}");
    }
    $MySQLSyslogWorkDir = $sock->GET_INFO("MySQLSyslogWorkDir");
    if ($MySQLSyslogWorkDir == null) {
        $MySQLSyslogWorkDir = "/home/syslogsdb";
    }
    if (is_dir($MySQLSyslogWorkDir)) {
        $array["MYSQL_SYSLOG"]["size"] = $unix->DIRSIZE_BYTES($MySQLSyslogWorkDir);
        $array["MYSQL_SYSLOG"]["INFO"] = $unix->DIRPART_INFO($MySQLSyslogWorkDir);
    }
    if ($GLOBALS["VERBOSE"]) {
        print_r($array);
    }
    @unlink($cachefile);
    @file_put_contents($cachefile, base64_encode(serialize($array)));
    @chmod($cachefile, 0777);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:58,代码来源:exec.mysql.start.php

示例2: UsersSizeByHour

function UsersSizeByHour()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pid = @file_get_contents($pidfile);
    if (systemMaxOverloaded()) {
        events("UsersSizeByHour:: systemMaxOverloaded {$GLOBALS["SYSTEM_INTERNAL_LOAD"]} !!! -> DIE", __LINE__);
        return;
    }
    $unix = new unix();
    $mypid = getmypid();
    if ($unix->process_exists($pid, basename(__FILE__))) {
        if ($pid != $mypid) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            events("Already executed pid {$pid} since {$time}mn-> DIE");
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
    }
    events("Starting pid [{$mypid}]...");
    @file_put_contents($pidfile, $mypid);
    $timefile = $unix->file_time_min($pidtime);
    events("Timelock:{$timefile} Mn");
    if (!$GLOBALS["VERBOSE"]) {
        if ($timefile < 10) {
            events("Only each 10mn :current {$timefile}Mn");
            if ($GLOBALS["VERBOSE"]) {
                echo "Only each 10mn\n";
            }
            return;
        }
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    // VF /var/log/artica-postfix/squid/queues/RTTSize;
    $q = new mysql_squid_builder();
    $q->CreateUserSizeRTTTable();
    $RTTSIZEPATH = "/var/log/artica-postfix/squid-RTTSize/" . date("YmdH");
    if (!is_file($RTTSIZEPATH)) {
        events("{$RTTSIZEPATH} no such file...");
        events("UserSizeRTT_oldfiles()");
        UserSizeRTT_oldfiles();
        events("main_table()");
        main_table();
        return;
    }
    if (!$q->TABLE_EXISTS("UserSizeRTT")) {
        events("Fatal UserSizeRTT no such table, die()");
        ufdbguard_admin_events("Fatal UserSizeRTT no such table, die();", __FUNCTION__, __FILE__, __LINE__, "stats");
        return;
    }
    events("{$RTTSIZEPATH} = " . FormatBytes(@filesize($RTTSIZEPATH) / 1024));
    $RTTSIZEARRAY = unserialize(@file_get_contents($RTTSIZEPATH));
    RTTSizeArray($RTTSIZEARRAY);
    //$prefix="INSERT IGNORE INTO UserSizeRTT (`zMD5`,`uid`,`zdate`,`ipaddr`,`hostname`,`account`,`MAC`,`UserAgent`,`size`) VALUES";
    //if($mac==null){$mac=$this->GetMacFromIP($ip);}
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:exec.squid-users-rttsize.php

示例3: ParseLogsDir

function ParseLogsDir()
{
    $d = 0;
    $h = 0;
    $sock = new sockets();
    $workingDir = $sock->GET_INFO("SquidOldLogsDefaultDir");
    if (!($handle = opendir($workingDir))) {
        @mkdir($workingDir, 0755, true);
        return;
    }
    $squidtail = new squid_tail();
    while (false !== ($filename = readdir($handle))) {
        if ($filename == ".") {
            continue;
        }
        if ($filename == "..") {
            continue;
        }
        $targetFile = "{$workingDir}/{$filename}";
        if (!is_file($targetFile)) {
            continue;
        }
        $d++;
        $h++;
        $c = 0;
        if ($d > 300) {
            if (systemMaxOverloaded()) {
                $array_load = sys_getloadavg();
                $internal_load = $array_load[0];
                events("ParseSquidLogBrutProcess()::{$workingDir}:: Overloaded: {$internal_load} system, break loop...", __LINE__);
                break;
            }
            $d = 0;
        }
        $handle = @fopen($targetFile, "r");
        if (!$handle) {
            events("Failed to open file", __LINE__);
            continue;
        }
        while (!feof($handle)) {
            $c++;
            $buffer = trim(fgets($handle, 4096));
            if (!$squidtail->parse_tail($buffer, null)) {
                continue;
            }
        }
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:48,代码来源:exec.old.access.logs.php

示例4: ini_set

    ini_set('error_prepend_string', null);
    ini_set('error_append_string', null);
}
include_once dirname(__FILE__) . '/ressources/class.templates.inc';
include_once dirname(__FILE__) . '/ressources/class.ldap.inc';
include_once dirname(__FILE__) . '/ressources/class.amavis.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
if (posix_getuid() != 0) {
    die("Cannot be used in web server mode\n\n");
}
if ($argv[1] = "--spamass-milter") {
    CheckSpamassassinMilter();
    die;
}
if (systemMaxOverloaded()) {
    writelogs("This system is too many overloaded, die()", __FUNCTION__, __FILE__, __LINE__);
    die;
}
$sock = new sockets();
$EnablePolicydWeight = $sock->GET_INFO('EnablePolicydWeight');
if ($EnablePolicydWeight != 1) {
    RemovePolicydWeight();
} else {
    EnablePolicyd();
}
CheckSpamassassinMilter();
CheckCLamavMilter();
CheckAmavis();
die;
function EnablePolicyd()
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:31,代码来源:exec.policyd-weight.php

示例5: ParseSquidLogMain

function ParseSquidLogMain()
{
    if (systemMaxOverloaded()) {
        return;
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        events("ParseSquidLogBrutProcess:: Already executed pid {$pid} since {$time}mn-> DIE", __LINE__);
        if ($GLOBALS["VERBOSE"]) {
            echo "Already executed pid {$pid} since {$time}mn\n";
        }
        die;
    }
    $WORKDIR = "/var/log/artica-postfix/dansguardian-stats2";
    $dirs = $unix->dirdir($WORKDIR);
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nice = EXEC_NICE();
    $nohup = $unix->find_program("nohup");
    while (list($dir, $val) = each($dirs)) {
        $basename = basename($dir);
        if ($basename == "--verbose") {
            continue;
        }
        $pidfile = "/etc/artica-postfix/pids/squidMysqllogs.{$basename}.lock.pid";
        $pid = @file_get_contents($pidfile);
        $filesCount = $unix->COUNT_FILES($dir);
        events_brut("ParseSquidLogMain:: {$filesCount} files, {$basename}: {$pidfile} PID:{$pid} ");
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $MNS = $unix->PROCCESS_TIME_MIN($pid);
            events_brut("ParseSquidLogMain:: {$basename}: {$filesCount} files, Already process running pid: {$pid} since {$MNS}mn");
            continue;
        }
        $Procs = ParseSquidLogMainProcessCount("squid-sql-proc", $basename);
        if ($Procs > 0) {
            $MNS = $unix->PROCCESS_TIME_MIN($pid);
            events_brut("ParseSquidLogMain:: {$Procs} processe(s) already in memory");
            continue;
        }
        $cmd = "{$nohup} {$php5} " . __FILE__ . " --squid-sql-proc {$basename} >/dev/null 2>&1 &";
        events_brut("ParseSquidLogMain:: {$filesCount} files Fork for {$basename} sub-dir", __LINE__);
        shell_exec($cmd);
    }
    $filesCount = $unix->COUNT_FILES($WORKDIR);
    $pidfile = "/etc/artica-postfix/pids/squidMysqllogs.lock.pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $MNS = $unix->PROCCESS_TIME_MIN($pid);
        events_brut("ParseSquidLogMain:: NULL: {$filesCount} files Already process running pid: {$pid} since {$MNS}mn");
    } else {
        $cmd = "{$nohup} {$php5} " . __FILE__ . " --squid-sql-proc >/dev/null 2>&1 &";
        events_brut("ParseSquidLogMain:: {$filesCount} files, Fork for NULL DIR", __LINE__);
        shell_exec($cmd);
    }
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:60,代码来源:exec.squid-tail-injector.php

示例6: launch_all_status

function launch_all_status($force=false){
	
	xLoadAvg();
	
	$trace=debug_backtrace();if(isset($trace[1])){$called=" called by ". basename($trace[1]["file"])." {$trace[1]["function"]}() line {$trace[1]["line"]}";events("$called",__FUNCTION__,__LINE__);}	

	CheckCallable();
	if(!is_file("/usr/share/artica-postfix/ressources/logs/global.versions.conf")){
		events("-> artica-install --write-version",__FUNCTION__,__LINE__);
		$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --write-versions");
	}else{
		$filetime=file_time_min("/usr/share/artica-postfix/ressources/logs/global.versions.conf");
		events("global.versions.conf={$filetime}mn ",__FUNCTION__,__LINE__);
		if($filetime>60){
			events("global.versions.conf \"$filetime\"mn",__FUNCTION__,__LINE__);
			@unlink("/usr/share/artica-postfix/ressources/logs/global.versions.conf");
			$GLOBALS["CLASS_UNIX"]->THREAD_COMMAND_SET("/usr/share/artica-postfix/bin/artica-install --write-versions");
		}
	}
	
	@unlink($GLOBALS["MY-POINTER"]);
	@file_put_contents($GLOBALS["MY-POINTER"],time());
	
	$functions=array("squid_master_status","c_icap_master_status","kav4Proxy_status","dansguardian_master_status","wpa_supplicant","fetchmail","milter_greylist",
	"framework","pdns_server","pdns_recursor","cyrus_imap","mysql_server","mysql_mgmt","mysql_replica","openldap","saslauthd","syslogger","squid_tail","amavis",
	"amavis_milter","boa","lighttpd","fcron1","fcron2","clamd","clamscan","clammilter","freshclam","retranslator_httpd","spamassassin_milter","spamassassin",
	"postfix","postfix_logger","mailman","kas3_milter","kas3_ap","smbd","nmbd","winbindd","scanned_only","roundcube","cups","apache-groupware","apache_groupware",
	"gdm","console-kit","xfce","vmtools","hamachi","artica_notifier","dhcpd_server","pure_ftpd","mldonkey","policyd_weight","backuppc","kav4fs","kav4fsavs",
	"apache_ocsweb","web_download","ocs_agent","openssh","gluster","auditd","squidguardweb","opendkim","ufdbguardd","squidguard_logger","milter_dkim","dropbox",
	"artica_policy","virtualbox_webserv","tftpd","dhcpd_server","crossroads","artica_status","artica_executor","artica_background","bandwith",
	 "pptpd","pptp_clients","apt_mirror","squid_clamav_tail","ddclient","cluebringer","apachesrc","zarafa_web","zarafa_ical","zarafa_dagent","zarafa_indexer",
	"zarafa_monitor","zarafa_gateway","zarafa_spooler","zarafa_server","assp","openvpn","vboxguest","sabnzbdplus","SwapWatchdog","artica_meta_scheduler",
	"OpenVPNClientsStatus","stunnel","meta_checks","zarafa_licensed","CheckCurl","ufdbguardd_tail","vnstat","NetAdsWatchdog","munin","autofs","greyhole",
	"dnsmasq","iscsi","watchdog_yorel","postfwd2","vps_servers","smartd","crossroads_multiple","auth_tail","greyhole_watchdog","greensql"
	);
	$data1=$GLOBALS["TIME_CLASS"];
	$data2 = time();
	$difference = ($data2 - $data1); 	 
	$min=round($difference/60);	
	if($min>9){
		events("reloading classes...",__FUNCTION__,__LINE__);
		$GLOBALS["TIME_CLASS"]=time();
		$GLOBALS["CLASS_SOCKETS"]=new sockets();
		$GLOBALS["CLASS_USERS"]=new settings_inc();
		$GLOBALS["CLASS_UNIX"]=new unix();		
	} 
	
	
	
	while (list ($num, $func) = each ($functions) ){
		if(function_exists($func)){
			$mem=round(((memory_get_usage()/1024)/1000),2);
			events("running function \"$func\" {$mem}MB in memory",__FUNCTION__,__LINE__);
			if(!$force){
				if(system_is_overloaded()){
					events("System is overloaded: {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, pause 2 seconds",__FUNCTION__,__LINE__);
					AmavisWatchdog();
					greyhole_watchdog();
					sleep(2);
					return;
				}else{
					if(systemMaxOverloaded()){
					events("System is very overloaded {$GLOBALS["SYSTEM_INTERNAL_LOAD"]}, pause 5  seconds",__FUNCTION__,__LINE__);
					AmavisWatchdog();
					greyhole_watchdog();
					sleep(5);
					return;
					}
				}
			}
			
			try {
				$results=call_user_func($func);
			} catch (Exception $e) {
				writelogs("Fatal while running function $func ($e)",__FUNCTION__,__FILE__,__LINE__);
			}
			
			if(trim($results)<>null){$conf[]=$results;}
		}
	}
	
@unlink("/usr/share/artica-postfix/ressources/logs/global.status.ini");
file_put_contents("/usr/share/artica-postfix/ressources/logs/global.status.ini",@implode("\n",$conf));
@chmod(770,"/usr/share/artica-postfix/ressources/logs/global.status.ini");
@file_put_contents("/etc/artica-postfix/cache.global.status",@implode("\n",$conf));	
events("creating status done ". count($conf)." lines....",__FUNCTION__,__LINE__);
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:87,代码来源:exec.status.php

示例7: status

function status()
{
    if (systemMaxOverloaded()) {
        return;
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} Already Artica task running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($pidTime);
        if ($time < 60) {
            return;
        }
    }
    @unlink($pidTime);
    @file_get_contents($pidTime, time());
    $q = new mysql_squid_builder();
    $sql = "SELECT * FROM haarp_caches";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $directory = trim($ligne["directory"]);
        $ID = $ligne["ID"];
        @mkdir("{$directory}", 0755, true);
        if (substr($directory, strlen($directory) - 1, 1) != "/") {
            $directory = $directory . "/";
        }
        $dir[$ID] = $directory;
    }
    if (count($dir) == 0) {
        @mkdir("/home/haarp-1", 0755, true);
        $dir[1] = "/home/haarp-1";
    }
    while (list($ID, $directory) = each($dir)) {
        $size = $unix->dskspace_bytes($directory);
        $q->QUERY_SQL("UPDATE haarp_caches SET `size`='{$size}' WHERE ID={$ID}");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:49,代码来源:exec.haarp.php

示例8: squid_running_schedules

function squid_running_schedules()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.run.schedules.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.run.schedules.php.pid";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        _statussquid("{$pid} already executed since {$timepid}Mn");
        if ($timepid < 5) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($TimeFile);
        if ($time < 4) {
            _statussquid("Current {$time}Mn need 5Mn");
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $BASEDIR = "/usr/share/artica-postfix";
    $SQUIDEnable = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    if (function_exists("systemMaxOverloaded")) {
        if (systemMaxOverloaded()) {
            _statussquid("Overloaded system, aborting...");
            return;
        }
    }
    if ($SQUIDEnable == 0) {
        return;
    }
    _statussquid("squid_running_schedules");
    shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.logfile_daemon-parse.php --tables-primaires >/dev/null 2>&1 &");
    $filetimeF = "/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.time";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/ufdb.rules_toolbox_left.html";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/dansguardian2.mainrules.php rules-toolbox-left >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/squid_mem_status.html";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --mem-status >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/SQUID_MGR_INFO.DB";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 15) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --info >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/squid_stores_status.html";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 20) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --store-status >/dev/null 2>&1 &");
    }
    $filetimeF = '/etc/artica-postfix/pids/Winbindd_privileged_SQUID.time';
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        $GLOBALS["CLASS_UNIX"]->Winbindd_privileged_SQUID();
        @unlink($filetimeF);
        @file_put_contents($filetimeF, time());
    }
    $filetimeF = '/etc/artica-postfix/pids/EnableKerbAuth.time';
    $EnableKerbAuth = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableKerbAuth"));
    if ($EnableKerbAuth == 1) {
        $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
        _statussquid(basename($filetimeF) . ": {$filetime}Mn");
        if ($filetime > 5) {
            @unlink($filetimeF);
            shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.kerbauth.php --pinglic >/dev/null 2>&1 &");
            @file_put_contents($filetimeF, time());
        }
    }
    $filetimeF = '/etc/artica-postfix/pids/DisableGoogleSSL.time';
    $DisableGoogleSSL = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableGoogleSSL"));
    if ($DisableGoogleSSL == 1) {
        $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
        _statussquid(basename($filetimeF) . ": {$filetime}Mn");
        if ($GLOBALS["CLASS_UNIX"]->file_time_min($filetime) > 4320) {
            shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.nosslsearch.google.com.php --run >/dev/null 2>&1 &");
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.run.schedules.php

示例9: launch_all_status

function launch_all_status()
{
    $functions = array("group5", "group10", "group30s", "group10s", "group0", "group2", "group300", "group120", "group30", "group60mn", "group5h", "group24h", "watchdog_artica_status");
    $system_is_overloaded = system_is_overloaded();
    $systemMaxOverloaded = systemMaxOverloaded();
    FillMemory();
    while (list($num, $func) = each($functions)) {
        if ($system_is_overloaded) {
            events("System is overloaded: ({$GLOBALS["SYSTEM_INTERNAL_LOAD"]}}, pause 10 seconds", __FUNCTION__, __LINE__);
            sleep(10);
            continue;
        } else {
            if ($systemMaxOverloaded) {
                events("System is very overloaded, pause stop", __FUNCTION__, __LINE__);
                return;
                continue;
            }
        }
        sleep(1);
        call_user_func($func);
    }
    $already = array();
    $AlreadyTests = array();
    if (count($GLOBALS["CMDS"]) > 0) {
        events("scheduling " . count($GLOBALS["CMDS"]) . " commands", __FUNCTION__, __LINE__);
        $FileDataCommand = @file_get_contents('/etc/artica-postfix/background');
        $tbl = explode("\n", $FileDataCommand);
        while (list($num, $zcommands) = each($GLOBALS["CMDS"])) {
            if (trim($zcommands) == null) {
                continue;
            }
            if (preg_match("#^(.+?)\\s+#", $zcommands, $re)) {
                if (!$AlreadyTests[$fileTests]) {
                    $fileTests = trim("{$re[1]}");
                    if (!is_file($fileTests)) {
                        events("running {$fileTests} No such file", __FUNCTION__, __LINE__);
                        continue;
                    } else {
                        $AlreadyTests[$fileTests] = true;
                    }
                }
            }
            if (!$already[$zcommands]) {
                $tbl[] = $zcommands;
                $already[$zcommands] = true;
            }
        }
        @file_put_contents('/etc/artica-postfix/background', implode("\n", $tbl));
        unset($GLOBALS["CMDS"]);
        $mem = round(memory_get_usage() / 1024 / 1000, 2);
        if ($GLOBALS["EnableArticaBackground"]) {
            $EnableArticaBackground = "Has daemon mode...";
        } else {
            $EnableArticaBackground = "Has cmdline mode...";
        }
        events("Saving /etc/artica-postfix/background done... Memory of this computer={$GLOBALS["TOTAL_MEMORY_MB"]}M Process memory at the end={$mem} Mb EnableArticaBackground=`{$EnableArticaBackground}`", __FUNCTION__, __LINE__);
    }
    @file_put_contents("/etc/artica-postfix/pids/" . basename(__FILE__) . ".GLOBALS", serialize($GLOBALS["TIME"]));
}
开发者ID:articatech,项目名称:artica,代码行数:59,代码来源:exec.executor.php

示例10: squid_running_schedules

function squid_running_schedules()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.run.schedules.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.run.schedules.php.pid";
    $unix = new unix();
    $pid = @file_get_contents($pidfile);
    if ($pid < 100) {
        $pid = null;
    }
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        _statussquid("{$pid} already executed since {$timepid}Mn");
        if ($timepid < 5) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $time = $unix->file_time_min($TimeFile);
        if ($time < 4) {
            _statussquid("Current {$time}Mn need 5Mn");
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    $StatsApplianceReceivers = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/StatsApplianceReceivers"));
    $SquidPerformance = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/SquidPerformance"));
    $BASEDIR = "/usr/share/artica-postfix";
    $SQUIDEnable = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("SQUIDEnable");
    if (!is_numeric($SQUIDEnable)) {
        $SQUIDEnable = 1;
    }
    if (function_exists("systemMaxOverloaded")) {
        if (systemMaxOverloaded()) {
            squid_admin_mysql(1, "{$GLOBALS["SYSTEM_INTERNAL_LOAD"]}: System is overloaded, Artica tasks as been aborted", null, __FILE__, __LINE__);
            _statussquid("Overloaded system, aborting...");
            return;
        }
    }
    if ($SQUIDEnable == 0) {
        return;
    }
    $filetimeF = "/etc/artica-postfix/pids/exec.squid.watchdog.php.start_watchdog.time";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/squid_mem_status.html";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --mem-status >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/SQUID_MGR_INFO.DB";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 15) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --info >/dev/null 2>&1 &");
    }
    $filetimeF = "/usr/share/artica-postfix/ressources/logs/web/squid_stores_status.html";
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 20) {
        shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.squid.watchdog.php --store-status >/dev/null 2>&1 &");
    }
    $filetimeF = '/etc/artica-postfix/pids/Winbindd_privileged_SQUID.time';
    $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
    _statussquid(basename($filetimeF) . ": {$filetime}Mn");
    if ($filetime > 5) {
        $GLOBALS["CLASS_UNIX"]->Winbindd_privileged_SQUID();
        @unlink($filetimeF);
        @file_put_contents($filetimeF, time());
    }
    $filetimeF = '/etc/artica-postfix/pids/EnableKerbAuth.time';
    $EnableKerbAuth = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableKerbAuth"));
    if ($EnableKerbAuth == 1) {
        $filetime = $GLOBALS["CLASS_UNIX"]->file_time_min($filetimeF);
        _statussquid(basename($filetimeF) . ": {$filetime}Mn");
        if ($filetime > 5) {
            @unlink($filetimeF);
            shell_exec2("{$GLOBALS["nohup"]} {$GLOBALS["NICE"]} {$GLOBALS["PHP5"]} {$BASEDIR}/exec.kerbauth.php --pinglic >/dev/null 2>&1 &");
            @file_put_contents($filetimeF, time());
        }
    }
    $filetimeF = '/etc/artica-postfix/pids/DisableGoogleSSL.time';
    $EnableGoogleDNS = 1;
    $DisableGoogleSSL = intval($GLOBALS["CLASS_SOCKETS"]->GET_INFO("DisableGoogleSSL"));
    $EnableGoogleSafeSearch = $GLOBALS["CLASS_SOCKETS"]->GET_INFO("EnableGoogleSafeSearch");
    if (!is_numeric($EnableGoogleSafeSearch)) {
        $EnableGoogleSafeSearch = 1;
    }
    if ($DisableGoogleSSL == 0) {
        if ($EnableGoogleSafeSearch == 0) {
            $EnableGoogleDNS = 0;
        }
    }
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.run.schedules.php

示例11: scanarp_mysql

function scanarp_mysql()
{
    $unix = new unix();
    $t = time();
    if (systemMaxOverloaded()) {
        return;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $me = basename(__FILE__);
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, $me)) {
        if ($GLOBALS["VERBOSE"]) {
            echo " --> Already executed.. {$pid} aborting the process\n";
        }
        system_admin_events("--> Already executed.. {$pid} aborting the process", __FUNCTION__, __FILE__, __LINE__, "network");
        die;
    }
    $sock = new sockets();
    $EnableArpDaemon = $sock->GET_INFO("EnableArpDaemon");
    $ArpdKernelLevel = $sock->GET_INFO("ArpdKernelLevel");
    if (!is_numeric($EnableArpDaemon)) {
        $EnableArpDaemon = 1;
    }
    $articastatus_pidfile = "/etc/artica-postfix/exec.status.php.pid";
    $pid = $unix->get_pid_from_file($articastatus_pidfile);
    if (!$unix->process_exists($pid)) {
        syslog_status("artica status doesn't run, start it, old pid was: {$pid}");
        shell_exec("/etc/init.d/artica-status start");
    }
    $list = $unix->PIDOF_PATTERN_ALL($me);
    if (count($list) > 2) {
        system_admin_events("--> Already executed.." . count($list) . " Processes executed");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $arpbin = $unix->find_program("arp");
    $arpdbin = $unix->find_program("arpd");
    if (!is_file($arpbin)) {
        echo "arp, no such binary...\n";
        return;
    }
    exec("{$arpbin} -a 2>&1", $results);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$arpbin} -a 2>&1\n";
    }
    $prefix = "INSERT INTO arpcache (`mac`,`ipaddr`,`hostname`,`HWtype`,`iface`) VALUES ";
    while (list($num, $ligne) = each($results)) {
        if (preg_match("#^(.+?)\\s+\\((.+?)\\)\\s+.+?\\s+(.+?)\\s+\\[(.+?)\\]\\s+.+?\\s+(.+)#", $ligne, $re)) {
            $mac = trim($re[3]);
            $hostname = trim($re[1]);
            $ipaddr = trim($re[2]);
            $HWtype = trim($re[4]);
            $iface = trim($re[5]);
            if ($GLOBALS["VERBOSE"]) {
                echo "MATCH `{$ligne}` '{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}'\n";
            }
            $f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
            continue;
        }
        if (preg_match("#^([a-z0-9\\.\\-\\_\\?]+)\\s+\\((.+?)\\).+?incomplete.+?[a-z]+\\s+(.+)\$#", $ligne, $re)) {
            $mac = null;
            $hostname = trim($re[1]);
            $ipaddr = trim($re[2]);
            $HWtype = null;
            $iface = trim($re[3]);
            if ($GLOBALS["VERBOSE"]) {
                echo "MATCH `{$ligne}` '{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}'\n";
            }
            $f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "No match `{$ligne}`\n";
        }
    }
    if (is_file($arpdbin)) {
        $results = array();
        exec("{$arpdbin} -l 2>&1", $results);
        while (list($num, $ligne) = each($results)) {
            if (preg_match("#^[0-9]+\\s+([0-9\\.]+)\\s+(.+)#", $ligne, $re)) {
                $mac = trim($re[2]);
                if (preg_match("#FAILED:#", $mac)) {
                    $mac = null;
                }
                $hostname = null;
                $ipaddr = trim($re[1]);
                $HWtype = null;
                $iface = "arpd";
                $f[] = "('{$mac}','{$ipaddr}','{$hostname}','{$HWtype}','{$iface}')";
                continue;
            }
        }
    }
    if (count($f) > 0) {
        $q = new mysql();
        $q->QUERY_SQL("TRUNCATE TABLE `arpcache`", "artica_backup");
        if ($GLOBALS["VERBOSE"]) {
            echo count($f) . " entries\n";
        }
//.........这里部分代码省略.........
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:101,代码来源:exec.arpscan.php

示例12: ParseLocalQueue

function ParseLocalQueue(){
	
$MemoryInstances=MemoryInstances();
if($MemoryInstances>4){events("Too much php processes in memory, aborting");return;}
if(!is_numeric($MemoryInstances)){$MemoryInstances=0;}

if(is_file("/etc/artica-postfix/orders.queue")){
		$size=@filesize("/etc/artica-postfix/orders.queue");
		if($size>0){
			events("Loading /etc/artica-postfix/orders.queue $size bytes");
			$orders_queue=explode("\n",@file_get_contents("/etc/artica-postfix/orders.queue"));
			if(is_array($orders_queue)){
				while (list ($num, $ligne) = each ($orders_queue) ){
					if(trim($ligne)==null){continue;}
					$orders[md5($ligne)]=$ligne;
				}	
			}
		}
		@unlink("/etc/artica-postfix/orders.queue");	
	}


if(is_file("/etc/artica-postfix/background")){
		$size=@filesize("/etc/artica-postfix/background");
		if($size>0){
			events("Loading /etc/artica-postfix/background $size bytes");
			$background=explode("\n",@file_get_contents("/etc/artica-postfix/background"));
			if(is_array($background)){
				while (list ($num, $ligne) = each ($background) ){
					if(trim($ligne)==null){continue;}
					$orders[md5($ligne)]=$ligne;
				}
			}
		}
		@unlink("/etc/artica-postfix/background");
		
}

	if(is_file("/var/log/artica-postfix/executor-daemon.log")){
		$time_exec=file_time_min("/var/log/artica-postfix/executor-daemon.log");
		events("executor-daemon.log $time_exec Min");
		if($time_exec>5){
			events("artica-executor is freeze ($time_exec minutes), restart it (see /tmp/watchdog.executor.log)");
			system(trim("/etc/init.d/artica-postfix restart artica-exec >/tmp/watchdog.executor.log 2>&1"));
			events("done...");
		}
	}
	
	
	if(is_file("/usr/share/artica-postfix/ressources/logs/global.status.ini")){
		$time_status=file_time_min("/usr/share/artica-postfix/ressources/logs/global.status.ini");
		events("global.status.ini $time_exec Min");
		if($time_status>5){
			events("artica-status is freeze ($time_status minutes), restart it (see /tmp/watchdog.status.log");
			system(trim("/etc/init.d/artica-postfix restart artica-status >/tmp/watchdog.status.log 2>&1"),$results);
			events("done...");
		}	
	}
	events("artica-executor: {$time_exec}mn; artica-status: {$time_status}mn ");

	
	if(count($orders)==0){
		events("artica-executor: queue is empty...");
		return null;
	}
	
	
	
	//events("[NORMAL]:: NICE={$GLOBALS["NICE"]}");
	$nice=$GLOBALS["NICE"];
	$orders_number=count($orders);
	$count_max=$orders_number;
	if($count_max>4){$count_max=4;}
	if($orders_number>10){if(!$GLOBALS["OVERLOAD"]){$count_max=10;}}
	$count=0;
	

	
	if($count_max+$MemoryInstances>10){$count_max=10-$MemoryInstances;}
	
	if($GLOBALS["TOTAL_MEMORY_MB"]<400){
		events("Lower config switch to 2 max processes...");
		$count_max=2;
	}	
	
	
	events("Orders:$orders_number Loaded instances:$MemoryInstances Max to order:$count_max");
	
	while (list ($num, $cmd) = each ($orders) ){
		if(trim($cmd)==null){continue;}
		if(systemMaxOverloaded()){events("[OVERLOAD]:: running in max overload mode, aborting queue");break;}
		$devnull=" >/dev/null 2>&1";
		if(strpos($cmd,">")>0){$devnull=null;}

		if(system_is_overloaded(__FILE__)){
			if($count>=$count_max){break;}
			unset($orders[$num]);
			events("[OVERLOAD]:: running in overload mode $nice$cmd$devnull");
			shell_exec("$nice$cmd$devnull");
			events("[OVERLOAD]:: $cmd was successfully executed, parse next");
//.........这里部分代码省略.........
开发者ID:rsd,项目名称:artica-1.5,代码行数:101,代码来源:exec.parse-orders.php


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