Exemplo n.º 1
0
function getArrayData($array, $field, $globalVar)
{
    foreach ($array as $key => $value) {
        if (is_array($value)) {
            getArrayData($value, $field, $globalVar);
        } else {
            if ($key == $field && $key != "sort") {
                $GLOBALS[$globalVar][$GLOBALS['arrayPosition']] = $value;
                $GLOBALS['arrayPosition']++;
            }
        }
    }
}
Exemplo n.º 2
0
$ESindex = $configFile['es_words_index'];
$fistTimeIndex = true;
$AgentParams = ['index' => $ESindex, 'type' => 'TextEvent', 'body' => ['size' => 0, 'aggs' => ['agents' => ['terms' => ['field' => 'agentId.raw']]]]];
$allAgentList = $client->search($AgentParams);
$fraudTriangleTerms = array('rationalization' => '0 1 0', 'opportunity' => '0 0 1', 'pressure' => '1 0 0');
$jsonFT = json_decode(file_get_contents($configFile['fta_text_rule_spanish']), true);
/* Unique agentID List */
$GLOBALS['arrayPosition'] = 0;
getArrayData($allAgentList, "key", "agentList");
/* Start the loop for each agent */
if (indexExist($configFile['es_alerter_status_index'], $configFile)) {
    $firstTimeIndex = false;
    logToFile($configFile['log_file'], "[INFO] - The alerter index already exist, continue with data range matching ...");
    $endDate = extractEndDateFromAlerter($configFile['es_alerter_status_index'], "AlertStatus");
    $GLOBALS['arrayPosition'] = 0;
    getArrayData($endDate, "endTime", 'lastAlertDate');
    logToFile($configFile['log_file'], "[INFO] - Checking events from last date: " . $GLOBALS['lastAlertDate'][0] . "  ...");
    foreach ($GLOBALS['agentList'] as $agentID) {
        $typedWords = extractTypedWordsFromAgentIDWithDate($agentID, $ESindex, $GLOBALS['lastAlertDate'][0], $GLOBALS['currentTime']);
        if ($typedWords['hits']['total'] == 0) {
            continue;
        } else {
            getMultiArrayData($typedWords, "typedWord", "applicationTitle", "sourceTimestamp", $agentID . "_typedWords");
            $arrayOfWordsAndWindows = $GLOBALS[$agentID . "_typedWords"];
            $lastWindowTitle = null;
            $lastTimeStamp = null;
            $stringOfWords = null;
            $counter = 0;
            foreach ($arrayOfWordsAndWindows as $key => $value) {
                $windowTitle = $value[1];
                $timeStamp = $value[2];