Exemplo n.º 1
0
                     }
                 }
             }
         }
     }
 } else {
     /* in an event - name is $eventname */
     /* if we get a blank line then we have gotten to the */
     /* end of this event - do something with it.         */
     if (strlen($line) == 0) {
         $event = false;
         if ($eventname == "PeerStatus") {
             if (!isset($cause_txt)) {
                 $cause_txt = "";
             }
             peer_status($peer_name, $peer_status, $cause, $time, $cause_txt);
         } else {
             if ($eventname == "UserEvent") {
                 /* If we get a user event we need to make this available to the */
                 /* frontend interface.  It is either a disconnect or a connect. */
                 if (isset($remote_agent_disconnect)) {
                     //list($agent_num, $cidname, $cidnum) = explode("-",$remote_agent);
                     agent_disconnected($remote_agent_disconnect);
                 } else {
                     list($agent_num, $queue_name, $callerid) = explode("-", $remote_agent);
                     agent_connected($agent_num, $queue_name, $callerid);
                 }
             } else {
                 if ($eventname == "QueueMemberStatus") {
                     queue_member_status($member_name, $queue, $location, $membership, $calls_taken, $last_call, $status, $paused, $penalty);
                 } else {
Exemplo n.º 2
0
function counters($aspid = false)
{
    $cacheFile = "/usr/share/artica-postfix/ressources/logs/web/squid.counters.db";
    if (!is_dir(dirname($cacheFile))) {
        @mkdir(dirname($cacheFile), 0755, true);
    }
    $unix = new unix();
    if (!$GLOBALS["VERBOSE"]) {
        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);
                if ($GLOBALS["OUTPUT"]) {
                    echo "Stopping......: " . date("H:i:s") . "Already `task` running PID {$pid} since {$time}mn\n";
                }
                return;
            }
            @file_put_contents($pidfile, getmypid());
        }
    }
    $timefile = $unix->file_time_min($cacheFile);
    if ($GLOBALS["VERBOSE"]) {
        echo basename($cacheFile) . " {$timefile}mn\n";
    }
    if (!$GLOBALS["FORCE"]) {
        if ($timefile < 5) {
            if (!$GLOBALS["VERBOSE"]) {
                return;
            }
        }
    }
    $sock = new sockets();
    $datas = explode("\n", CurlGet("5min"));
    while (list($num, $ligne) = each($datas)) {
        $ligne = trim($ligne);
        if (!preg_match("#(.+?)=(.+)#", $ligne, $re)) {
            continue;
        }
        $ARRAY[trim($re[1])] = trim($re[2]);
    }
    $datas = explode("\n", CurlGet("active_requests"));
    @file_put_contents("/var/log/squid/monitor.sessions.cache", serialize($datas));
    $c = 0;
    while (list($num, $ligne) = each($datas)) {
        $ligne = trim($ligne);
        if (!preg_match("#Connection:\\s+(.+)#", $ligne, $re)) {
            continue;
        }
        if (trim($re[1]) == "close") {
            continue;
        }
        $c++;
    }
    $ARRAY["active_requests"] = $c;
    $ARRAY["SAVETIME"] = time();
    @unlink($cacheFile);
    @file_put_contents($cacheFile, serialize($ARRAY));
    @chmod($cacheFile, 0775);
    peer_status(true);
}