Exemplo n.º 1
0
 /**
  * getLogFileDataFromDisk
  *
  * $logFileArray is a array of log files to parse 
  * for a simple individual log file its a array of 1
  * for more complex log files that are split across separate files its a array of > 1
  *
  */
 public static function getLogFileDataFromDisk($logFileArray)
 {
     //first we need to loop through log file and build mycontents array which is newline exploded
     //array of data sets from each log file read from disk!
     $arraysize = 0;
     foreach ($logFileArray as $dataKey => $thelogFile) {
         if (file_exists($thelogFile)) {
             $mycontents[$arraysize] = file_get_contents($thelogFile);
             $mycontents[$arraysize] = explode("\n", $mycontents[$arraysize]);
             //used just for collectd to clean top of datasets where descriptions are
             if (LOGGER == "collectd") {
                 array_shift($mycontents[$arraysize]);
             }
             //if last value is null or empty or ???? delete it
             if (end($mycontents[$arraysize]) == null || end($mycontents[$arraysize]) == "") {
                 array_pop($mycontents[$arraysize]);
             }
             $arraysize++;
         }
     }
     //if its just a single log file we can return it now
     //otherwise parse it and then return it
     if ($arraysize == 1) {
         return $mycontents[0];
     } else {
         $finaldata = LoadUtility::parseComplexLogFiles($mycontents, $arraysize);
         return $finaldata;
     }
 }