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


PHP unix::process_exists方法代码示例

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


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

示例1: start

function start()
{
    $unix = new unix();
    $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());
    $PID = GET_PID();
    if ($unix->process_exists($PID)) {
        squid_admin_mysql(1, "Watchdog says that rsyslog is off, but exists [action=stamp-pid]", null, __FILE__, __LINE__);
        $SrcPid = intval(@file_get_contents("/var/run/rsyslogd.pid"));
        if ($SrcPid != $PID) {
            squid_admin_mysql(2, "Watchdog says that rsyslog is off (PID:{$SrcPid}), but exists (PID:{$PID}) [action=stamp-pid]", null, __FILE__, __LINE__);
            @file_put_contents("/var/run/rsyslogd.pid", $PID);
        } else {
            squid_admin_mysql(2, "Watchdog says that rsyslog is off (PID:{$SrcPid}), but exists [action=nothing]", null, __FILE__, __LINE__);
        }
        @unlink($pidfile);
        die(1);
    }
    squid_admin_mysql(0, "Syslog daemon is down [action=start]", null, __FILE__, __LINE__);
    system("/etc/init.d/rsyslog start");
    $squid = $unix->LOCATE_SQUID_BIN();
    if (is_file($squid)) {
        sleep(3);
        squid_admin_mysql(1, "Reloading proxy service after starting syslog daemon", null, __FILE__, __LINE__);
        system("{$squid} -f /etc/squid3/squid.conf -k reconfigure");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:35,代码来源:exec.watchdog.rsyslogd.php

示例2: parse

function parse()
{
    $TimeFile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.time";
    $pidfile = "/etc/artica-postfix/pids/exec.squid.stats.mime.proto.php.pid";
    $GLOBALS["LogFileDeamonLogDir"] = @file_get_contents("/etc/artica-postfix/settings/Daemons/LogFileDeamonLogDir");
    if ($GLOBALS["LogFileDeamonLogDir"] == null) {
        $GLOBALS["LogFileDeamonLogDir"] = "/home/artica/squid/realtime-events";
    }
    $unix = new unix();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $timepid = $unix->PROCCESS_TIME_MIN($pid);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$pid} already executed since {$timepid}Mn\n";
        }
        if ($timepid < 14) {
            return;
        }
        $kill = $unix->find_program("kill");
        unix_system_kill_force($pid);
    }
    @file_put_contents($pidfile, getmypid());
    $TimeExec = $unix->file_time_min($TimeFile);
    if (!$GLOBALS["FORCE"]) {
        if ($TimeExec < 20) {
            return;
        }
    }
    @unlink($TimeFile);
    @file_put_contents($TimeFile, time());
    parsedb("/var/log/squid");
    parsedb($GLOBALS["LogFileDeamonLogDir"]);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:33,代码来源:exec.squid.stats.proto.parser.php

示例3: scan_connections

function scan_connections()
{
    $unix = new unix();
    $pidfile = "/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 "Artica Task Already running PID {$pid} since {$time}mn\n";
        }
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (system_is_overloaded()) {
        system_admin_events("Overloaded system, aborting task", __FUNCTION__, __FILE__, __LINE__);
        return false;
    }
    $q = new mysql();
    $sql = "SELECT * FROM texttoldap";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (mysql_num_rows($results) == 0) {
        return;
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        if (!connect($ligne)) {
            continue;
        }
        import($ligne);
        $ID = $ligne["ID"];
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.TextToLdap.php

示例4: start

function start()
{
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
        $pid = @file_get_contents($pidfile);
        if ($unix->process_exists($pid)) {
            writelogs("Already running pid {$pid}", __FUNCTION__, __FILE__, __LINE__);
            return;
        }
    }
    $ldap = new clladp();
    $pattern = "(&(objectclass=userAccount))";
    $attr = array();
    $sr = @ldap_search($ldap->ldap_connection, "dc=organizations,{$ldap->suffix}", $pattern, $attr);
    $hash = ldap_get_entries($ldap->ldap_connection, $sr);
    $unix = new unix();
    $users_array = array();
    if (!is_array($hash)) {
        blackwhite_admin_mysql(0, "Unable to obtain users from LDAP server", $ldap->ldap_last_error, __FILE__, __LINE__);
        return;
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $usersArray[$hash[$i]["uid"][0]] = true;
    }
    while (list($uid, $none) = each($usersArray)) {
        imapopen_White($uid);
        imapopen_black($uid);
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:30,代码来源:exec.imap.blacklists.php

示例5: xstart

function xstart()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pid = @file_get_contents($pidfile);
    if ($GLOBALS["VERBOSE"]) {
        echo "{$pidtime}\n";
    }
    $unix = new unix();
    $squid = $unix->LOCATE_SQUID_BIN();
    if (!$GLOBALS["FORCE"]) {
        if ($unix->process_exists($pid, basename(__FILE__))) {
            $time = $unix->PROCCESS_TIME_MIN($pid);
            if ($GLOBALS["VERBOSE"]) {
                echo "Already executed pid {$pid} since {$time}mn\n";
            }
            die;
        }
    }
    $mypid = getmypid();
    @file_put_contents($pidfile, $mypid);
    $timefile = $unix->file_time_min($pidtime);
    if ($GLOBALS["VERBOSE"]) {
        echo "Timelock:{$pidtime} {$timefile} Mn\n";
    }
    if (!$GLOBALS["FORCE"]) {
        if ($timefile < 5) {
            if ($GLOBALS["VERBOSE"]) {
                echo "{$timefile}mn require 5mn\n";
            }
            return;
        }
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    if (!is_file("/home/ufdb/smtp-events/ACCESS_LOG")) {
        if ($GLOBALS["VERBOSE"]) {
            echo "/home/ufdb/smtp-events/ACCESS_LOG no such file\n";
        }
    }
    $array = explode("\n", @file_get_contents("/home/ufdb/smtp-events/ACCESS_LOG"));
    @unlink("/home/ufdb/smtp-events/ACCESS_LOG");
    $body = array();
    $mmstp = new ufdb_msmtp();
    $Subject = count($array) . " Web filtering blocked event(s)";
    $body[] = "Return-Path: <{$mmstp->smtp_sender}>";
    $body[] = "Date: " . date("D, d M Y H:i:s") . " +0100 (CET)";
    $body[] = "From: {$mmstp->smtp_sender}";
    $body[] = "Subject: {$Subject}";
    $body[] = "To: {$mmstp->recipient}";
    $body[] = "";
    $body[] = "";
    $body[] = @implode("\r\n", $array);
    $body[] = "";
    $body[] = "";
    $finalbody = @implode("\r\n", $body);
    if (!$mmstp->Send($finalbody)) {
        squid_admin_mysql(0, "Unable to send notification {$Subject} to {$mmstp->recipient}", "{$Subject} to {$mmstp->recipient}\n------------------\n" . @implode("\n", $array) . "\n\t\tThe following error encountered\n" . $mmstp->logs . "\n", __FILE__, __LINE__);
    }
}
开发者ID:articatech,项目名称:artica,代码行数:60,代码来源:exec.ufdb.smtp.release.php

示例6: start

function start()
{
    $sock = new sockets();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $me = basename(__FILE__);
    if ($unix->process_exists(@file_get_contents($pidfile), $me)) {
        if ($GLOBALS["VERBOSE"]) {
            echo " --> Already executed.. " . @file_get_contents($pidfile) . " aborting the process\n";
        }
        system_admin_events("--> Already executed.. " . @file_get_contents($pidfile) . " aborting the process", __FUNCTION__, __FILE__, __LINE__, "zarafa");
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $WordpressBackupParams = unserialize(base64_decode($sock->GET_INFO("WordpressBackupParams")));
    if (!isset($WordpressBackupParams["FTP_ENABLE"])) {
        $WordpressBackupParams["FTP_ENABLE"] = 0;
    }
    if (!isset($WordpressBackupParams["DEST"])) {
        $WordpressBackupParams["DEST"] = "/home/wordpress-backup";
    }
    if ($WordpressBackupParams["DEST"] == null) {
        $WordpressBackupParams["DEST"] = "/home/wordpress-backup";
    }
    ScanFreeWebs($WordpressBackupParams);
    $t = time();
    build_progress_fullback("{backup} FTP ?", 95);
    ftp_backup($WordpressBackupParams);
    sizes_backup();
    build_progress_fullback("{done}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.wordpress-backup.php

示例7: applyAcls

function applyAcls()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    if ($unix->process_exists(@file_get_contents("{$pidfile}"))) {
        echo "Already process exists\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    $sql = "SELECT `directory` FROM acl_directories";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, 'artica_backup');
    if (!$q->ok) {
        if ($GLOBALS["VERBOSE"]) {
            system_admin_events("Fatal,{$q->mysql_error}", __FUNCTION__, __FILE__, __LINE__, "acls");
            echo $q->mysql_error . "\n";
            return;
        }
    }
    $count = mysql_num_rows($results);
    system_admin_events("INFO,acls {$count} items", __FUNCTION__, __FILE__, __LINE__, "acls");
    echo "Starting......: " . date("H:i:s") . " acls {$count} items\n";
    if ($count == 0) {
        return;
    }
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        ApplySingleAcls($ligne["directory"]);
    }
    $setfacl_bin = $unix->find_program("setfacl");
    if (is_file($setfacl_bin)) {
        shell_exec("{$setfacl_bin} -b /tmp 2>&1");
    }
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:33,代码来源:exec.acls.php

示例8: start

function start()
{
    $sock = new sockets();
    $unix = new unix();
    @mkdir("/etc/artica-postfix/pids", 0755, true);
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pid = @file_get_contents($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        echo "SWAP: [INFO] Already running...\n";
        die;
    }
    @file_put_contents($pidfile, getmypid());
    $sysctl = $unix->find_program("sysctl");
    $swapoff = $unix->find_program("swapoff");
    $swapon = $unix->find_program("swapon");
    $nohup = $unix->find_program("nohup");
    $DisableSWAPP = $sock->GET_INFO("DisableSWAPP");
    if (!is_numeric($DisableSWAPP)) {
        $DisableSWAPP = 0;
    }
    if ($DisableSWAPP == 0) {
        echo "SWAP: [INFO] swap is enabled, aborting\n";
        shell_exec("{$nohup} {$swapon} -a >/dev/null 2>&1 &");
        return;
    }
    echo "SWAP: [INFO] swap is disabled, hide swap usage...\n";
    shell_exec("{$sysctl} -w vm.swappiness=0 >/dev/null 2>&1");
    shell_exec("{$nohup} {$swapoff} -a >/dev/null 2>&1 &");
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.initd-swap.php

示例9: build

function build()
{
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $unix = new unix();
    $sock = new sockets();
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        die;
    }
    $php = $unix->LOCATE_PHP5_BIN();
    @file_put_contents($pidfile, getmypid());
    progress("{get_system_informations}", 30);
    support_step1();
    progress("{APP_UFDBGUARD}", 40);
    $EnableUfdbGuard = intval($sock->EnableUfdbGuard());
    if ($EnableUfdbGuard == 1) {
        $ufdbguardd = $unix->find_program("ufdbguardd");
        if (is_file($ufdbguardd)) {
            shell_exec("{$php} /usr/share/artica-postfix/exec.squidguard.php --build --force --verbose >/usr/share/artica-postfix/ressources/support/build-ufdbguard.log 2>&1");
        }
    }
    progress("{get_all_logs}", 50);
    support_step2();
    progress("{get_all_logs}", 70);
    export_tables();
    progress("{compressing_package}", 90);
    support_step3();
    progress("{success}", 100);
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:29,代码来源:exec.support.package.php

示例10: xstart

function xstart()
{
    $unix = new unix();
    $sock = new sockets();
    $GLOBALS["CLASS_SOCKETS"] = $sock;
    $FORCED_TEXT = null;
    $NOTIFY = false;
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidTime = "/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS_FULL.db";
    $pid = $unix->get_pid_from_file($pidfile);
    $GLOBALS["CLASS_UNIX"] = $unix;
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Already executed\n";
        return;
    }
    if (!$GLOBALS["FORCE"]) {
        if ($unix->file_time_min($pidTime) < 30) {
            return;
        }
    }
    $GLOBALS["MAIN_ARRAY"] = unserialize(@file_get_contents("/usr/share/artica-postfix/ressources/logs/ARTICA_DBS_STATUS.db"));
    ArticaWebFilter();
    ArticaUfdb();
    @mkdir("/usr/share/artica-postfix/ressources/logs", 0755, true);
    @unlink($pidTime);
    @file_put_contents($pidTime, serialize($GLOBALS["MAIN_ARRAY"]));
    if ($GLOBALS["VERBOSE"]) {
        echo "Saving {$pidTime}\n";
    }
    @chmod($pidTime, 0755);
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:32,代码来源:exec.ufdb.databases.php

示例11: start_interface

function start_interface($eth)
{
    $unix = new unix();
    if (!isset($GLOBALS["SNORT_PATH"])) {
        $GLOBALS["SNORT_PATH"] = $unix->find_program("snort");
    }
    $pidpath = "/var/run/snort_{$eth}.pid";
    $pid = @file_get_contents($pidpath);
    if ($unix->process_exists($pid)) {
        echo "Starting......: " . date("H:i:s") . " Snort Daemon for Interface \"{$eth}\" Already running PID {$pid}\n";
        return;
    }
    $cmds[] = "{$GLOBALS["SNORT_PATH"]}";
    $cmds[] = "--create-pidfile";
    $cmds[] = "--pid-path /var/run/snort_{$eth}.pid";
    $cmds[] = "-m 027 -D -d -l /var/log/snort -u root -g root";
    $cmds[] = "-c /etc/snort/snort.conf -i {$eth}";
    $cmd = @implode(" ", $cmds);
    if ($GLOBALS["VERBOSE"]) {
        echo "\n\n" . $cmd . "\n\n";
    }
    shell_exec($cmd);
    for ($i = 0; $i < 6; $i++) {
        $pid = @file_get_contents($pidpath);
        if ($unix->process_exists($pid)) {
            echo "Starting......: " . date("H:i:s") . " Snort Daemon for Interface \"{$eth}\" success PID {$pid}\n";
            return;
        }
        sleep(1);
    }
    echo "Starting......: " . date("H:i:s") . " Snort Daemon for Interface \"{$eth}\" failed\n";
    echo "Starting......: " . date("H:i:s") . " Snort {$cmd}\n";
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:33,代码来源:exec.snort.php

示例12: purge

function purge()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . "." . __FUNCTION__ . ".pid";
    $pidtime = "/etc/artica-postfix/pids/exec.suricata.hourly.purge.time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        $time = $unix->PROCCESS_TIME_MIN($pid);
        echo "Starting......: " . date("H:i:s") . " [INIT]: Already Artica task running PID {$pid} since {$time}mn\n";
        return;
    }
    @file_put_contents($pidfile, getmypid());
    if (system_is_overloaded()) {
        return;
    }
    $timeExec = $unix->file_time_min($pidtime);
    if ($timeExec < 1440) {
        return;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    $q = new postgres_sql();
    $sock = new sockets();
    $SuricataPurge = intval($sock->GET_INFO("SuricataPurge"));
    if ($SuricataPurge == 0) {
        $SuricataPurge = 15;
    }
    $q->QUERY_SQL("DELETE FROM suricata_events WHERE zdate < NOW() - INTERVAL '{$SuricataPurge} days'");
}
开发者ID:articatech,项目名称:artica,代码行数:29,代码来源:exec.suricata.hourly.php

示例13: xstart

function xstart()
{
    $unix = new unix();
    $pidfile = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pidtime = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".time";
    $pid = $unix->get_pid_from_file($pidfile);
    if ($unix->process_exists($pid, basename(__FILE__))) {
        return;
    }
    $TimeExec = $unix->file_time_min($pidtime);
    if ($TimeExec < 360) {
        return;
    }
    @unlink($pidtime);
    @file_put_contents($pidtime, time());
    @file_put_contents($pidfile, getmypid());
    $php5 = $unix->LOCATE_PHP5_BIN();
    $q = new mysql_squid_builder();
    $q->CreateCategoryUrisTable("malware");
    $COUNT1 = $q->COUNT_ROWS("categoryuris_malware");
    vxvault();
    malwareurls_joxeankoret();
    clean_mx_de();
    $COUNT2 = $q->COUNT_ROWS("categoryuris_malware");
    $URLS_ADDED = $COUNT2 - $COUNT1;
    if ($URLS_ADDED > 0) {
        system("{$php5} /usr/share/artica-postfix/exec.squidguard.php --compile-category malware");
        squid_admin_mysql(2, "{$URLS_ADDED} malware URLs added", null, __FILE__, __LINE__);
    }
}
开发者ID:articatech,项目名称:artica,代码行数:30,代码来源:exec.infected.urls.php

示例14: CheckCMDLine

function CheckCMDLine()
{
    $unix = new unix();
    $PID_FILE = "/etc/artica-postfix/pids/" . basename(__FILE__) . ".pid";
    $pid = $unix->get_pid_from_file($PID_FILE);
    if ($unix->process_exists($pid)) {
        return;
    }
    @file_put_contents($PID_FILE, getmypid());
    if (system_is_overloaded()) {
        die;
    }
    $sock = new sockets();
    $ips = unserialize(base64_decode($sock->GET_INFO("RBLCheckIPList")));
    if (count($ips) > 0) {
        if ($GLOBALS["VERBOSE"]) {
            echo count($ips) . " elements to check\n";
        }
        if (is_array($ips)) {
            while (list($num, $ip) = each($ips)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "{$ip} element...\n";
                }
                ChecksDNSBL($ip, false, true);
            }
            ChecksDNSBL();
            return;
        }
    }
    ChecksDNSBL();
}
开发者ID:BillTheBest,项目名称:1.6.x,代码行数:31,代码来源:exec.my-rbl.check.php

示例15: process_queue

function process_queue()
{
    $unix = new unix();
    $pgrep = $unix->find_program("pgrep");
    exec("pgrep -l -f \"exec.squid-tail-injector.php --squid-sql-proc\" 2>&1", $results);
    while (list($index, $ligne) = each($results)) {
        if (preg_match("#pgrep#", $ligne)) {
            continue;
        }
        if (preg_match("#^([0-9]+).*?\\s+([0-9]+)-([0-9]+)-([0-9]+)-([0-9]+)\$#", $ligne, $re)) {
            $pid = $re[1];
            if (!$unix->process_exists($pid)) {
                continue;
            }
            if (!is_dir("/proc/{$pid}")) {
                continue;
            }
            $ttl = $unix->PROCESS_UPTIME($pid);
            $day = strtotime("{$re[2]}-{$re[3]}-{$re[4]} {$re[5]}:00:00");
            $dayText = date("{l} {F} d H", $day) . "h";
            if ($ttl == null) {
                continue;
            }
            $ttl = str_replace("uptime=", "", $ttl);
            $array[$day] = array("TTL" => $ttl, "PID" => $pid, "day" => $dayText);
            continue;
        }
    }
    krsort($array);
    echo "<articadatascgi>" . base64_encode(serialize($array)) . "</articadatascgi>";
}
开发者ID:brucewu16899,项目名称:1.6.x,代码行数:31,代码来源:squidstats.php


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