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


PHP unix::EXEC_NICE方法代码示例

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


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

示例1: compile_rule

function compile_rule($ID)
{
    $unix = new unix();
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nice = $unix->EXEC_NICE();
    $f[] = "MAILTO=\"\"";
    $f[] = "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
    $f[] = "0,15,30,45 * * * * root {$nice}{$php5} " . __FILE__ . " --export >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.d/iptaccount", @implode("\n", $f));
    shell_exec("/bin/chmod 640 /etc/cron.d/iptaccount >/dev/null 2>&1");
    iptables_delete_rule($ID);
    $q = new mysql();
    $sql = "SELECT * FROM tcp_account_rules WHERE ID='{$ID}'";
    $ligne = @mysql_fetch_array($q->QUERY_SQL($sql, 'artica_backup'));
    if ($ligne["ipaddr"] == null) {
        return;
    }
    if ($ligne["mode"] == null) {
        return;
    }
    $unix = new unix();
    $iptables = $unix->find_program("iptables");
    $cmd = "{$iptables} -A {$ligne["mode"]} -j ACCOUNT --addr {$ligne["ipaddr"]} --tname rule_{$ID} -m comment --comment \"ArticaIptAccountRule_{$ID}\"";
    if ($GLOBALS["VERBOSE"]) {
        echo $cmd . "\n";
    }
    shell_exec($cmd);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.iptaccount.php

示例2: restore

function restore($filename)
{
    $unix = new unix();
    $sock = new sockets();
    $TMP = $unix->FILE_TEMP();
    $filenameBase = basename($filename);
    if (!is_file($filename)) {
        echo "{$filename} no such file\n";
        build_progress("{failed}", 110);
    }
    $tmpf = $unix->FILE_TEMP();
    build_progress("{uncompress} {$filenameBase}", 10);
    if (!$unix->uncompress($filename, $tmpf)) {
        @unlink($filename);
        build_progress("{uncompress} {$filenameBase} {failed}", 110);
        return;
    }
    @unlink($filename);
    build_progress("{importing} {$tmpf}", 50);
    $q = new mysql_squid_builder();
    $nice = $unix->EXEC_NICE();
    $mysql = $unix->find_program("mysql");
    $gzip = $unix->find_program("gzip");
    $nohup = $unix->find_program("nohup");
    $echo = $unix->find_program("echo");
    $rm = $unix->find_program("rm");
    $php = $unix->LOCATE_PHP5_BIN();
    $sh[] = "#!/bin/sh";
    $sh[] = "{$echo} \"{$mysql} -> {$filenameBase}\"";
    $sh[] = "{$nice} {$mysql} {$q->MYSQL_CMDLINES} -f squidlogs < {$tmpf}";
    $sh[] = "{$rm} {$TMP}.sh";
    $sh[] = "\n";
    @file_put_contents("{$TMP}.sh", @implode("\n", $sh));
    @chmod("{$TMP}.sh", 0755);
    build_progress(10, "Starting restore {$filenameBase} - " . basename("{$TMP}.sh") . " ");
    system("{$nohup} {$TMP}.sh >{$TMP}.txt 2>&1 &");
    sleep(1);
    $PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
    echo "Running PID {$PID}\n";
    while ($unix->process_exists($PID)) {
        build_progress(50, "Starting restoring {$filenameBase}");
        sleep(3);
        $PID = $unix->PIDOF_PATTERN("{$TMP}.sh");
        echo "Running PID {$PID}\n";
    }
    echo @file_get_contents("{$TMP}.txt") . "\n";
    @unlink("{$TMP}.sh");
    @unlink("{$TMP}.txt");
    build_progress(50, "{restore} {done} {$filenameBase}");
    build_progress(50, "{restore} Analyze Hourly tables");
    system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --force --verbose");
    build_progress(60, "{restore} Repair Hourly tables");
    system("{$php} /usr/share/artica-postfix/exec.squid.stats.hours.php --repair --force --verbose");
    build_progress(70, "{restore} Repair Table days");
    system("{$php} /usr/share/artica-postfix/exec.squid.stats.repair.php --tables-day --repair --force --verbose");
    build_progress(80, "{restore} Repair sums");
    system("{$php} /usr/share/artica-postfix/exec.squid.stats.totals.php --repair --force --verbose");
    build_progress(100, "{restore} Done");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:59,代码来源:exec.articadb.restore.php

示例3: create_cron_task

function create_cron_task(){
	
	$unix=new unix();
	$php5=$unix->LOCATE_PHP5_BIN();
	$nice=$unix->EXEC_NICE();
	$f[]="MAILTO=\"\"";
	$f[]="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/X11R6/bin:/usr/share/artica-postfix/bin";
	$f[]="0,10,20,30,40,50 * * * * root $nice$php5 ".__FILE__." --resolv >/dev/null 2>&1";
	$f[]="";
	
	@file_put_contents("/etc/cron.d/iptaccount", @implode("\n", $f));
	shell_exec("/bin/chmod 640 /etc/cron.d/freeweb_resolv >/dev/null 2>&1");	
	
}
开发者ID:rsd,项目名称:artica-1.5,代码行数:14,代码来源:exec.freeweb.php

示例4: chock_status

function chock_status()
{
    $unix = new unix();
    $nohup = $unix->find_program("nohup");
    writelogs_framework("nohup = {$nohup}", __FUNCTION__, __FILE__, __LINE__);
    $nice = $unix->EXEC_NICE();
    writelogs_framework("nice = {$nice}", __FUNCTION__, __FILE__, __LINE__);
    $php5 = $unix->LOCATE_PHP5_BIN();
    $cache_file = "/usr/share/artica-postfix/ressources/logs/web/monit.status.all";
    if (is_file($cache_file)) {
        writelogs_framework("{$cache_file} exists", __FUNCTION__, __FILE__, __LINE__);
        @chmod($cache_file, 0755);
    } else {
        writelogs_framework("{$cache_file} does not exists", __FUNCTION__, __FILE__, __LINE__);
    }
    $cmd = "{$nohup} {$nice} {$php5} /usr/share/artica-postfix/exec.monit.php --status >/dev/null 2>&1 &";
    writelogs_framework($cmd, __FUNCTION__, __FILE__, __LINE__);
    shell_exec($cmd);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:19,代码来源:monit.php

示例5: directory_backup

function directory_backup($WordpressBackupParams, $servername)
{
    $unix = new unix();
    $tar = $unix->find_program("tar");
    $q = new mysql();
    $free = new freeweb($servername);
    $gzip = $unix->find_program("gzip");
    $WORKDIR = $free->www_dir;
    echo "Backup directory {$WORKDIR}";
    if (!is_dir($WORKDIR)) {
        apache_admin_mysql(0, "{$servername} cannot backup a non-existent directory {$WORKDIR}", null, __FILE__, __LINE__);
        return false;
    }
    $BaseWorkDir = $WordpressBackupParams["DEST"] . "/{$servername}/" . date("Y-m-d-H") . "h";
    @mkdir("{$BaseWorkDir}", 0755, true);
    $nice = $unix->EXEC_NICE();
    $t = time();
    chdir($WORKDIR);
    if ($GLOBALS["OUTPUT"]) {
        echo "Compressing {$BaseWorkDir}/wordpress.tar.gz\n";
    }
    shell_exec("{$nice} {$tar} cfz {$BaseWorkDir}/wordpress.tar.gz *");
    $took = $unix->distanceOfTimeInWords($t, time());
    $size = FormatBytes(@filesize("{$BaseWorkDir}/wordpress.tar.gz") / 1024);
    if ($GLOBALS["OUTPUT"]) {
        echo "Compressing wordpress.tar.gz took {$took} size= {$size}";
    }
    apache_admin_mysql(2, "{$servername} directory backuped {$size} (took {$took})", null, __FILE__, __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.wordpress-backup.php

示例6: parse_memory

function parse_memory()
{
    $unix = new unix();
    $nginx = $unix->find_program("nginx");
    $sock = new sockets();
    $nginx = $unix->find_program("nginx");
    if (!is_file($nginx)) {
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: Nginx, not installed\n";
        }
        return;
    }
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $pidStampReload = $GLOBALS["pidStampReload"];
    if (!$GLOBALS["VERBOSE"]) {
        echo "{$pidtime}\n";
        $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]: Nginx Already Artica task running PID {$pid} since {$time}mn\n";
            }
            return;
        }
        $TimExec = $unix->file_time_min($pidtime);
        if ($TimExec < 5) {
            return;
        }
    }
    @file_put_contents($pidfile, getmypid());
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $python = $unix->find_program("python");
    $nice = $unix->EXEC_NICE();
    exec("{$nice}{$python} /usr/share/artica-postfix/bin/ps_mem.py 2>&1", $results);
    $FOUND = false;
    while (list($index, $line) = each($results)) {
        $line = trim($line);
        if ($line == null) {
            continue;
        }
        if (!preg_match("#^[0-9\\.]+.*?=\\s+([0-9\\.]+)\\s+(.+?)\\s+nginx#", $line, $re)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "Not found \"{$line}\"\n";
            }
            continue;
        }
        $memoryValue = $re[1];
        $unit = trim(strtolower($re[2]));
        echo "Found {$memoryValue} {$unit}\n";
        if ($unit == "kib") {
            $memoryValue = $memoryValue / 1048.576;
        }
        if ($unit == "mib") {
            $memoryValue = $memoryValue * 1.048576;
        }
        if ($unit == "gib") {
            $memoryValue = $memoryValue * 1048.576;
        }
        $FOUND = true;
        break;
    }
    if (!$FOUND) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Not found...\n";
        }
        return;
    }
    $memoryValue = round($memoryValue, 2);
    $MaxMemory = max_memory();
    $MaxMemoryReload = $MaxMemory / 2;
    $memoryValueInt = intval($memoryValue);
    echo "Nginx = {$memoryValue} MB  INT({$memoryValueInt}) Reload on:{$MaxMemoryReload}MB; Restart on:{$MaxMemory}MB\n";
    $ACTION_DONE = false;
    if ($MaxMemory > 0) {
        if ($memoryValueInt > 0) {
            if ($memoryValueInt > $MaxMemoryReload) {
                $StampTime = $unix->file_time_min($pidStampReload);
                if ($StampTime > 20) {
                    squid_admin_mysql(1, "Reverse proxy reach medium memory {$memoryValueInt}MB Reload:{$MaxMemoryReload}MB [action=reload]", "The service will be restarted");
                    reload(true);
                    @unlink($pidStampReload);
                    @file_put_contents($pidStampReload, time());
                    $ACTION_DONE = true;
                }
            }
            if (!$ACTION_DONE) {
                if ($memoryValueInt > $MaxMemory) {
                    squid_admin_mysql(0, "Reverse proxy reach max memory allowed {$memoryValueInt}MB MAX:{$MaxMemory}MB [action=restart]", "The service will be restarted");
                    stop(true);
                    start(true);
                    @unlink($pidStampReload);
                }
            }
        }
    }
    add_memory_value($memoryValue);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:99,代码来源:exec.nginx.php

示例7: basename

if ($GLOBALS["DEBUG_INCLUDES"]) {
    echo basename(__FILE__) . "::class.squid.inc\n";
}
include_once dirname(__FILE__) . '/ressources/class.squid.inc';
if ($GLOBALS["DEBUG_INCLUDES"]) {
    echo basename(__FILE__) . "::framework/class.unix.inc\n";
}
include_once dirname(__FILE__) . '/framework/class.unix.inc';
if ($GLOBALS["DEBUG_INCLUDES"]) {
    echo basename(__FILE__) . "::frame.class.inc\n";
}
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/ressources/class.mysql.inc';
include_once dirname(__FILE__) . '/ressources/class.squid.acls.inc';
$unix = new unix();
$NICE = $unix->EXEC_NICE();
$GetCachesInsquidConf = $unix->SQUID_CACHE_FROM_SQUIDCONF();
$chown = $unix->find_program("chown");
$chmod = $unix->find_program("chmod");
$t = time();
$c = 0;
while (list($CacheDirectory, $type) = each($GetCachesInsquidConf)) {
    if (trim($CacheDirectory) == null) {
        continue;
    }
    if (!is_dir($CacheDirectory)) {
        continue;
    }
    $c++;
    $F[] = $CacheDirectory;
    shell_exec("{$NICE} {$chown} -R squid:squid {$CacheDirectory}");
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.squid.chown.caches.php

示例8: backup


//.........这里部分代码省略.........
                }
                continue;
            }
            if (preg_match("#WEBGET:(.+)#", $WhatToBackup, $re)) {
                if (!isset($BACKUP_WEBGET_ALREADY_DONE[$re[1]])) {
                    $arr = unserialize(base64_decode($re[1]));
                    if (!is_array($arr)) {
                        backup_events($ID, "initialization", "ERROR, WEBGET `{$re[1]}` is not an array...", __LINE__);
                        continue;
                    }
                    backup_events($ID, "initialization", "INFO, Backup remote Artica FreeWebs Website {$arr["RemoteArticaSite"]} from source {$arr["RemoteArticaServer"]}", __LINE__);
                    backup_webget($ID, $arr);
                }
                continue;
            }
            backup_events($ID, "initialization", "INFO, `{$WhatToBackup}` could not understood", __LINE__);
        }
    }
    $sql = "SELECT * FROM backup_folders WHERE taskid={$ID}";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        if (strpos($q->mysql_error, "gone away")) {
            backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error} Restarting MySQL server (Patch p.20130807)", __LINE__);
            mysql_admin_mysql(0, "Restarting mysql service.", $q->mysql_error, __FILE__, __LINE__);
            shell_exec("/etc/init.d/mysql restart");
            $q = new mysql();
            $results = $q->QUERY_SQL($sql, "artica_backup");
        }
    }
    if (!$q->ok) {
        backup_events($ID, "personal", "ERROR, mysql {$q->mysql_error}", __LINE__);
        return;
    }
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        $dd1 = time();
        if ($ligne["recursive"] == 1) {
            $recursive = " --recursive";
        } else {
            $recursive = null;
        }
        $path = trim(base64_decode($ligne["path"]));
        if (!is_dir($path)) {
            backup_events($ID, "personal", "ERROR, [{$path}] no such file or directory", __LINE__);
            continue;
        }
        backup_events($ID, "personal", "INFO, Backup starting for {$path}", __LINE__);
        send_email_events("Backup Task {$ID}:: Backup starting {$path}", "Backup is running for path {$path}", "backup");
        backup_mkdir($path);
        $results = backup_copy($path, $path, $ID);
        $calculate = distanceOfTimeInWords($dd1, time());
        backup_events($ID, "personal", "INFO, Backup finish for {$path}\n{$results} {$calculate}", __LINE__);
    }
    writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]: Calculate directory size on {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
    $du = $unix->find_program("du");
    $dut1 = time();
    $nice = $unix->EXEC_NICE();
    $cmd = "{$nice}{$du} -s {$mount_path_final}";
    exec($cmd, $du_results);
    $calculate = distanceOfTimeInWords($dut1, time());
    $BackupSize = 0;
    if (preg_match("#^([0-9]+)\\s+#", @implode("", $du_results), $re)) {
        $BackupSize = $re[1];
        backup_events($ID, "initialization", "INFO, backup size {$BackupSize} bytes time:{$calculate}", __LINE__);
    }
    if ($GLOBALS["CAN_CLEAN_CONTAINERS"]) {
        backup_events($ID, "initialization", "INFO, cleaning containers....", __LINE__);
        CleanContainers($ID, $mount_path_final);
    } else {
        backup_events($ID, "initialization", "INFO, cannot clean containers, check protocols....", __LINE__);
    }
    $GLOBAL["BACKUP_MEMORY_SQL"]["mount_path_final"] = $mount_path_final;
    $zmd5 = md5("{$GLOBAL["BACKUP_MEMORY_SQL"]["CONTAINER"]}{$GLOBALS["MYSERVERNAME"]}");
    $cnx_params = addslashes(base64_encode(serialize($GLOBAL["BACKUP_MEMORY_SQL"])));
    $sql = "INSERT IGNORE INTO backup_storages (`taskid`,`size`,`cnx_params`,`zmd5`) VALUES('{$ID}','{$BackupSize}','{$cnx_params}','{$zmd5}')";
    $q->QUERY_SQL($sql, "artica_backup");
    $sql = "UPDATE backup_storages SET `size`='{$BackupSize}' WHERE `zmd5`='{$zmd5}'";
    $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        backup_events($ID, "initialization", "ERROR, {$q->mysql_error}", __LINE__);
    }
    if (!$GLOBALS["NO_UMOUNT"]) {
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        if (preg_match("#^\\/opt\\/artica\\/mounts\\/backup\\/[0-9]+(.+)#", $mount_path_final, $re)) {
            $mount_path_final = str_replace($re[1], "", $mount_path_final);
            writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:translated to {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        }
        backup_events($ID, "initialization", "INFO, umount {$mount_path_final}", __LINE__);
        writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount {$mount_path_final}", __FUNCTION__, __FILE__, __LINE__);
        exec("umount -l {$mount_path_final} 2>&1", $resultsUmount);
        if (count($resultsUmount) > 0) {
            writelogs(date('m-d H:i:s') . " " . "[TASK {$ID}]:umount : ----- \n" . @implode("\n", $resultsUmount) . "\n", __FUNCTION__, __FILE__, __LINE__);
        }
    }
    $date_end = time();
    $calculate = distanceOfTimeInWords($date_start, $date_end);
    backup_events($ID, "TIME", "INFO, Time: {$calculate} ({$mount_path_final})", __LINE__);
    backup_events($ID, "initialization", "INFO, Backup task terminated", __LINE__);
    send_email_events("Backup Task {$ID}:: Backup stopping", "Backup is stopped", "backup");
    shell_exec(LOCATE_PHP5_BIN2() . " " . dirname(__FILE__) . "/exec.cleanfiles.php");
}
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.backup.php

示例9: xupdate

function xupdate($aspid = false)
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/exec.suricata.updates.php.update.time";
    if (!$GLOBALS["FORCE"]) {
        if (system_is_overloaded()) {
            die;
        }
        if (!$aspid) {
            $pid = @file_get_contents($pidfile);
            if ($pid < 100) {
                $pid = null;
            }
            if ($unix->process_exists($pid, basename(__FILE__))) {
                echo "PID: {$pid} Already exists....\n";
                die;
            }
            @file_put_contents($pidfile, getmypid());
            $pidExec = $unix->file_time_min($pidtime);
            if ($pidExec < 1439) {
                return;
            }
            @unlink($pidtime);
            @file_put_contents($pidtime, time());
        }
    }
    echo "Starting....\n";
    $sock = new sockets();
    $CurrentEmergingRulesMD5 = $sock->GET_INFO("CurrentEmergingRulesMD5");
    $tmpdir = $unix->TEMP_DIR();
    echo "CurrentEmergingRulesMD5={$CurrentEmergingRulesMD5} TMPDIR:{$tmpdir}\n";
    $curl = new ccurl("https://rules.emergingthreatspro.com/open/suricata/emerging.rules.tar.gz.md5");
    $targetpath = "{$tmpdir}/emerging.rules.tar.gz.md5";
    if (!$curl->GetFile($targetpath)) {
        echo "{$targetpath} failed\n";
        artica_update_event(0, "Unable to download emerging.rules.tar.gz.md5", $curl->errors, __FILE__, __LINE__);
        return;
    }
    echo "Open {$targetpath}\n";
    $f = explode("\n", @file_get_contents($targetpath));
    echo "{$targetpath} " . count($f) . " lines\n";
    if (count($f) > 2) {
        artica_update_event(0, "Truncated emerging.rules.tar.gz.md5", $curl->errors, __FILE__, __LINE__);
        return;
    }
    @unlink($targetpath);
    $NewEmergingRulesMD5 = trim($f[0]);
    if ($NewEmergingRulesMD5 == $CurrentEmergingRulesMD5) {
        echo "No new updates...\n";
        die;
    }
    $curl = new ccurl("https://rules.emergingthreatspro.com/open/suricata/version.txt");
    $targetpath = "{$tmpdir}/version.txt";
    if (!$curl->GetFile($targetpath)) {
        echo "{$targetpath} failed\n";
        artica_update_event(0, "Unable to version.txt", $curl->errors, __FILE__, __LINE__);
        return;
    }
    $NextVersion = @file_get_contents($targetpath);
    @unlink($targetpath);
    $curl = new ccurl("https://rules.emergingthreatspro.com/open/suricata/emerging.rules.tar.gz");
    $targetpath = "{$tmpdir}/emerging.rules.tar.gz";
    if (!$curl->GetFile($targetpath)) {
        echo "{$targetpath} failed\n";
        artica_update_event(0, "Unable to download emerging.rules.tar.gz", $curl->errors, __FILE__, __LINE__);
        return;
    }
    $FileMD5 = md5_file($targetpath);
    if ($FileMD5 != $NewEmergingRulesMD5) {
        artica_update_event(0, "Corrupted emerging.rules.tar.gz file", "{$FileMD5}<>{$NewEmergingRulesMD5}", __FILE__, __LINE__);
        return;
    }
    echo "Extracting rules\n";
    $tar = $unix->find_program("tar");
    shell_exec("{$tar} xf {$targetpath} -C /etc/suricata/");
    @unlink($targetpath);
    $sock->SET_INFO("CurrentEmergingRulesMD5", $NewEmergingRulesMD5);
    $sock->SET_INFO("CurrentEmergingRulesVersion", $NextVersion);
    $curl = new ccurl("https://rules.emergingthreatspro.com/open/suricata/classification.config");
    $targetpath = "{$tmpdir}/classification.config";
    if (!$curl->GetFile($targetpath)) {
        echo "{$targetpath} failed\n";
        artica_update_event(0, "Unable to download classification.config", $curl->errors, __FILE__, __LINE__);
        return;
    }
    @unlink("/etc/suricata/classification.config");
    @copy($targetpath, "/etc/suricata/classification.config");
    @unlink($targetpath);
    $php = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    shell_exec("{$php} /usr/share/artica-postfix/exec.suricata.php --classifications");
    $q = new postgres_sql();
    $results = $q->QUERY_SQL("select signature FROM suricata_sig where enabled=0");
    $nice = $unix->EXEC_NICE();
    $SH[] = "#!/bin/sh";
    while ($ligne = @pg_fetch_assoc($results)) {
        $sig = $ligne["signature"];
        echo "Disable signature {$sig}\n";
        $SH[] = "{$nice} /usr/share/artica-postfix/bin/sidrule -d {$sig} || true";
//.........这里部分代码省略.........
开发者ID:articatech,项目名称:artica,代码行数:101,代码来源:exec.suricata.updates.php

示例10: debian_size

function debian_size()
{
    $sock = new sockets();
    $unix = new unix();
    $MirrorEnableDebian = $sock->GET_INFO("MirrorEnableDebian");
    $MirrorDebianDir = $sock->GET_INFO("MirrorDebianDir");
    $MirrorDebianBW = $sock->GET_INFO("MirrorDebianBW");
    if (!is_numeric($MirrorEnableDebian)) {
        $MirrorEnableDebian = 0;
    }
    if (!is_numeric($MirrorDebianBW)) {
        $MirrorDebianBW = 500;
    }
    if ($MirrorDebianDir == null) {
        $MirrorDebianDir = "/home/mirrors/Debian";
    }
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $extime = $unix->file_time_min($pidTime);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$extime}Mn\n";
    }
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        writelogs("Already process exists pid {$pid} running since {$time}mn", __FUNCTION__, __FILE__, __LINE__);
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (!$GLOBALS["VERBOSE"]) {
        $TIME = $unix->file_time_min($pidTime);
        if ($unix->file_time_min($pidTime) < 30) {
            writelogs("`{$pidTime}` {$TIME}mn, require 30mn, aborting", __FUNCTION__, __FILE__, __LINE__);
            ChecksLogs();
            return;
        }
    }
    @unlink($pidTime);
    @file_put_contents($pidTime, time());
    if (is_overloaded()) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Overloaded system...\n";
        }
        return;
    }
    $nice = $unix->EXEC_NICE();
    $du = $unix->find_program("du");
    if ($GLOBALS["VERBOSE"]) {
        echo "{$nice} {$du} -s -b {$MirrorDebianDir} 2>&1\n";
    }
    writelogs("{$nice} {$du} -s -b {$MirrorDebianDir} 2>&1", __FUNCTION__, __FILE__, __LINE__);
    exec("{$nice} {$du} -s -b {$MirrorDebianDir} 2>&1", $results);
    writelogs("Done...", __FUNCTION__, __FILE__, __LINE__);
    while (list($num, $val) = each($results)) {
        if (!preg_match("#^([0-9\\.]+)\\s+#", $val, $re)) {
            continue;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "{$re[1]} Bytes...\n";
        }
        $sock->SET_INFO("MirrorDebianDirSize", $re[1]);
    }
    ChecksLogs();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:65,代码来源:exec.debian.mirror.php

示例11: nmap_scan

function nmap_scan()
{
    if (isset($GLOBALS["nmap_scan_executed"])) {
        return;
    }
    $unix = new unix();
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".time";
    $timeF = $unix->file_time_min($pidTime);
    if ($timeF < 10) {
        $GLOBALS["nmap_scan_executed"] = true;
        return;
    }
    $sock = new sockets();
    $SquidPerformance = intval($sock->GET_INFO("SquidPerformance"));
    if ($SquidPerformance > 2) {
        return;
    }
    $php5 = $unix->LOCATE_PHP5_BIN();
    $nohup = $unix->find_program("nohup");
    $exec_nice = $unix->EXEC_NICE();
    $cmdNmap = "{$exec_nice} {$nohup} {$php5} " . dirname(__FILE__) . "/exec.nmapscan.php --scan-squid >/dev/null 2>&1 &";
    @file_put_contents($pidTime, time());
    shell_exec($cmdNmap);
    $GLOBALS["nmap_scan_executed"] = true;
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:25,代码来源:exec.squid-tail-injector.php

示例12: xtsart

function xtsart()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidTime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    if ($GLOBALS["VERBOSE"]) {
        echo "TimeFile:{$pidTime}\n";
    }
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        if ($unix->file_time_min($pidTime) < 10) {
            die;
        }
        if ($unix->process_exists(@file_get_contents($pidfile, basename(__FILE__)))) {
            if ($GLOBALS["VERBOSE"]) {
                echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n";
            }
            writelogs(basename(__FILE__) . ":Already executed.. aborting the process", basename(__FILE__), __FILE__, __LINE__);
            die;
        }
        @file_put_contents($pidfile, getmypid());
        @unlink($pidTime);
        @file_put_contents($pidTime, time());
    }
    $array_load = sys_getloadavg();
    $internal_load = $array_load[0];
    $time = time();
    $BASEDIR = "/usr/share/artica-postfix";
    $hash_mem = array();
    @chmod("/usr/share/artica-postfix/ressources/mem.pl", 0755);
    $datas = shell_exec(dirname(__FILE__) . "/ressources/mem.pl");
    if (preg_match('#T=([0-9]+) U=([0-9]+)#', $datas, $re)) {
        $ram_used = $re[2];
    }
    $cpuUsage = null;
    $ps = $unix->find_program("ps");
    exec("{$ps} -aux 2>&1", $processes);
    foreach ($processes as $process) {
        $cols = explode(' ', preg_replace('# +#', ' ', $process));
        if (strpos($cols[2], '.') > -1) {
            $cpuUsage += floatval($cols[2]);
        }
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "CPU: {$cpuUsage}, LOAD: {$internal_load}, MEM: {$ram_used}\n";
    }
    $q = new postgres_sql();
    $q->CREATE_TABLES();
    $proxyname = $unix->hostname_g();
    $time = date("Y-m-d H:i:s");
    $sql = "INSERT INTO system (zdate,proxyname,load_avg,mem_stats,cpu_stats)\n\tVALUES('{$time}','{$proxyname}','{$internal_load}','" . intval($ram_used) . "','{$cpuUsage}')";
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . "\n";
    }
    $q->QUERY_SQL($sql);
    if (!$q->ok) {
        echo $q->mysql_error . "\n";
    }
    RXTX();
    if (system_is_overloaded(basename(__FILE__))) {
        $date = time();
        @mkdir("/var/log/artica-postfix/sys_alerts", 0755, true);
        if (!is_file("/var/log/artica-postfix/sys_alerts/{$date}")) {
            $ps = $unix->find_program("ps");
            $nohup = $unix->find_program($nohup);
            $nice = $unix->EXEC_NICE();
            $load = $GLOBALS["SYSTEM_INTERNAL_LOAD"];
            if (!$unix->process_exists($unix->PIDOF_PATTERN("{$ps}"))) {
                $cmd = trim("{$nohup} {$nice} {$ps} auxww >/var/log/artica-postfix/sys_alerts/{$date}-{$load} 2>&1");
                shell_exec($cmd);
            }
        }
    }
}
开发者ID:articatech,项目名称:artica,代码行数:74,代码来源:exec.sys-stats.php

示例13: squidz

function squidz($aspid = false)
{
    $unix = new unix();
    if (!$aspid) {
        $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);
            system_admin_events("restart_squid::Already task running PID {$pid} since {$time}mn", __FUNCTION__, __FILE__, __LINE__, "proxy");
            return;
        }
        @file_put_contents($pidfile, getmypid());
    }
    echo date("Y/m/d H:i:s") . " Arti| Stopping Squid\n";
    echo date("Y/m/d H:i:s") . " Arti| Please wait....\n";
    stop_squid(true);
    $squidbin = $unix->LOCATE_SQUID_BIN();
    $su_bin = $unix->find_program("su");
    $t1 = time();
    exec("{$su_bin} squid -c \"{$squidbin} -z\" 2>&1", $results);
    echo date("Y/m/d H:i:s") . " Arti| Checking caches `{$squidbin}`....Please wait\n";
    while (list($index, $val) = each($results)) {
        echo $val . "\n";
    }
    $execnice = $unix->EXEC_NICE();
    $nohup = $unix->find_program("nohup");
    $chown = $unix->find_program("chown");
    $tail = $unix->find_program("tail");
    $GetCachesInsquidConf = $unix->SQUID_CACHE_FROM_SQUIDCONF();
    while (list($CacheDirectory, $type) = each($GetCachesInsquidConf)) {
        echo date("Y/m/d H:i:s") . " Arti| Lauching a chown task in background mode on `{$CacheDirectory}`... this could take a while....\n";
        $unix->chmod_alldirs(0755, $CacheDirectory);
        $cmd = "{$execnice}{$nohup} {$chown} -R squid:squid {$CacheDirectory} >/dev/null 2>&1 &";
        echo date("Y/m/d H:i:s") . " Arti| {$cmd}\n";
        shell_exec($cmd);
    }
    echo date("Y/m/d H:i:s") . " Arti| Starting squid....Please wait\n";
    start_squid(true);
    sleep(5);
    exec("{$tail} -n 100 /var/log/squid/cache.log 2>&1", $results2);
    while (list($index, $val) = each($results2)) {
        echo $val . "\n";
    }
    echo date("Y/m/d H:i:s") . " Arti| Done...\n";
    echo date("Y/m/d H:i:s") . " Arti| Took " . $unix->distanceOfTimeInWords($t1, time()) . "\n";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:46,代码来源:exec.squid.watchdog.php

示例14: ufdb_save_update_settings

function ufdb_save_update_settings()
{
    $unix = new unix();
    $CategoriesDatabasesByCron = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/CategoriesDatabasesByCron"));
    if ($CategoriesDatabasesByCron == 0) {
        if (is_file("/etc/cron.d/webfiltering-update")) {
            @unlink("/etc/cron.d/webfiltering-update");
            system("/etc/init.d/cron reload");
        }
        return;
    }
    $WebFUpdateH = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WebFUpdateH"));
    $WebFUpdateM = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/WebFUpdateM"));
    $NICE = $unix->EXEC_NICE();
    $php = $unix->LOCATE_PHP5_BIN();
    $f[] = "MAILTO=\"\"";
    $f[] = "{$WebFUpdateM} {$WebFUpdateH} * * * root {$NICE} {$php} /usr/share/artica-postfix/exec.squid.blacklists.php --update --bycron >/dev/null 2>&1";
    $f[] = "";
    @file_put_contents("/etc/cron.d/webfiltering-update", @implode("\n", $f));
    system("/etc/init.d/cron reload");
}
开发者ID:articatech,项目名称:artica,代码行数:21,代码来源:windowsupdate.php

示例15: rebuildcaches


//.........这里部分代码省略.........
    $squidbin = $unix->LOCATE_SQUID_BIN();
    if (!is_file($squidbin)) {
        ouputz("squid, no such binary file", __LINE__);
        @unlink("/etc/artica-postfix/squid.lock");
        return;
    }
    build_progress("{stopping_proxy_service}", 20);
    squid_admin_mysql(1, "Stopping Proxy service in order to rebuild caches", null, __FILE__, __LINE__);
    ouputz("Stopping squid, please wait...", __LINE__);
    if (function_exists("debug_backtrace")) {
        $trace = debug_backtrace();
        if (isset($trace[1])) {
            $sourcefunction = $trace[1]["function"];
            $sourceline = $trace[1]["line"];
            $executed = "Executed by {$sourcefunction}() line {$sourceline}\nusing argv:{$GLOBALS["ARGVS"]}\n";
        }
    }
    shell_exec("/etc/init.d/squid stop --force --script=" . basename(__FILE__));
    if ($GLOBALS["REPORT"]) {
        while (list($cache_dir, $ligne) = each($array)) {
            $DIRARRAY = $unix->DIR_STATUS($cache_dir);
            $size = $array["SIZE"];
            $used = $array["USED"];
            $pourc = $array["POURC"];
            $mounted = $array["MOUNTED"];
            $logs[] = "{$cache_dir} size: {$size}, used:{$used} {$pourc}% mounted on {$mounted}";
        }
        squid_admin_mysql(2, "Report on caches status", @implode("\n", $logs), __FILE__, __LINE__);
    }
    reset($array);
    while (list($cache_dir, $ligne) = each($array)) {
        build_progress("Checking {$cache_dir}", 30);
        if (preg_match("#MemBooster#", $cache_dir)) {
            squid_admin_mysql(1, "Removing cache {$cache_dir}", null, __FILE__, __LINE__);
            ouputz("Removing {$cache_dir} content...", __LINE__);
            squid_admin_mysql(2, "Removing cache {$cache_dir} done", null, __FILE__, __LINE__);
            shell_exec("{$rm} -rf {$cache_dir}/*");
            continue;
        }
        $DISK_STATUS = $unix->DF_SATUS_K($cache_dir);
        $DIRECTORY_SIZE = $unix->DIRSIZE_BYTES($cache_dir) / 1024 / 1024;
        $AIVA = $DISK_STATUS["AIVA"] * 1024;
        ouputz("Removing {$cache_dir} '{$DIRECTORY_SIZE}'M Available {$AIVA}M", __LINE__);
        shell_exec("{$rm} -rf {$cache_dir}");
        ouputz("re-create {$cache_dir}", __LINE__);
        squid_admin_mysql(2, "Re-create {$cache_dir}", null, __FILE__, __LINE__);
        @mkdir($cache_dir, 0755, true);
        @chown($cache_dir, "squid");
        @chgrp($cache_dir, "squid");
    }
    $su = $unix->find_program("su");
    $results = array();
    build_progress("Create {$cache_dir}", 30);
    ouputz("Building new caches {$su} -c \"{$squidbin} -z\" squid", __LINE__);
    exec("{$su} -c \"{$squidbin} -z\" squid 2>&1", $results);
    while (list($num, $ligne) = each($results)) {
        ouputz("{$ligne}", __LINE__);
    }
    ouputz("Remove lock file...", __LINE__);
    @unlink("/etc/artica-postfix/squid.lock");
    ouputz("Starting squid, please wait...", __LINE__);
    build_progress("{starting_proxy_service}", 35);
    if (function_exists("debug_backtrace")) {
        $trace = debug_backtrace();
        if (isset($trace[1])) {
            $sourcefunction = $trace[1]["function"];
            $sourceline = $trace[1]["line"];
            $executed = "Executed by {$sourcefunction}() line {$sourceline}\nusing argv:{$GLOBALS["ARGVS"]}\n";
        }
    }
    squid_admin_mysql(2, "Starting Proxy Service after rebuilding caches", null, __FILE__, __LINE__);
    shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.watchdog.php --start --script=" . basename(__FILE__));
    for ($i = 0; $i < 60; $i++) {
        $array = $unix->squid_get_cache_infos();
        if (count($array) > 0) {
            break;
        }
        ouputz("Waiting {$i}s/60 cache is not ready...", __LINE__);
        sleep(1);
    }
    ouputz("Done... Squid-cache seems to be ready...", __LINE__);
    $NICE = $unix->EXEC_NICE();
    $nohup = $unix->find_program("nohup");
    build_progress("Refresh caches infos...", 50);
    ouputz("Refresh caches information, please wait...", __LINE__);
    shell_exec("{$php5} /usr/share/artica-postfix/exec.squid.php --cache-infos --force");
    if (is_array($cachesRename)) {
        reset($cachesRename);
        while (list($index, $cache_dir) = each($cachesRename)) {
            build_progress("Removing old {$cache_dir}", 60);
            $cmd = "{$NICE} {$rm} -rf {$cache_dir} >/dev/null 2>&1 &";
            squid_admin_mysql(2, "Ask to delete old cache dir {$cache_dir} done", "{$called}", __FILE__, __LINE__);
            ouputz("Deleting  {$cache_dir} {$cmd}", __LINE__);
            shell_exec($cmd);
        }
    }
    build_progress("{done}", 100);
    $took = $unix->distanceOfTimeInWords($t, time());
    squid_admin_mysql(2, "All Proxy caches was rebuilded took: {$took}", "{$called}", __FILE__, __LINE__);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:101,代码来源:exec.squid.rebuild.caches.php


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