76 if (!is_dir($this->statdir)) {
77 throw new Exception(
'Statistics module: output dir do not exists [' . $this->statdir .
']');
80 if (!file_exists($this->inputfile)) {
81 throw new Exception(
'Statistics module: input file do not exists [' . $this->inputfile .
']');
84 $file =
fopen($this->inputfile,
'r');
86 if ($file ===
false) {
87 throw new Exception(
'Statistics module: unable to open file [' . $this->inputfile .
']');
91 $this->statconfig->getValue(
'datestart', 0), $this->statconfig->getValue(
'datelength', 15), $this->statconfig->getValue(
'offsetspan', 44)
102 if (isset($this->metadata)) {
103 $notBefore = $this->metadata[
'notBefore'];
104 $lastlinehash = $this->metadata[
'lastlinehash'];
107 $lastlogline =
'sdfsdf';
108 $lastlineflip =
false;
113 while (!feof($file)) {
114 $logline = fgets($file, 4096);
117 if (!preg_match(
'/STAT/', $logline)) {
122 $lastlogline = $logline;
125 $epoch = $logparser->parseEpoch($logline);
126 $content = $logparser->parseContent($logline);
129 if ($this->fromcmdline && (
$i % 10000) == 0) {
130 echo(
"Read line " .
$i .
"\n");
134 echo(
"----------------------------------------\n");
135 echo(
'Log line: ' . $logline .
"\n");
136 echo(
'Date parse [' . substr($logline, 0, $this->statconfig->getValue(
'datelength', 15)) .
'] to [' . date(DATE_RFC822, $epoch) .
']' .
"\n");
137 echo htmlentities(print_r($content,
true));
143 if ($epoch > $lastRead) {
147 if ($epoch === $notBefore) {
148 if (!$lastlineflip) {
149 if (sha1($logline) === $lastlinehash) {
150 $lastlineflip =
true;
156 if ($epoch < $notBefore) {
161 foreach ($this->statrules as $rulename =>
$rule) {
164 if (array_key_exists(
'type',
$rule)) {
168 if (
$type !==
'aggregate') {
172 foreach ($this->timeres as $tres => $tresconfig ) {
174 if (isset($tresconfig[
'customDateHandler'])) {
175 $dh = $tresconfig[
'customDateHandler'];
178 $timeslot = $datehandler[
'default']->toSlot($epoch, $tresconfig[
'slot']);
179 $fileslot = $datehandler[$dh]->toSlot($epoch, $tresconfig[
'fileslot']);
185 $difcol = self::getDifCol($content,
$rule[
'col']);
199 $this->metadata[
'notBefore'] = $lastRead;
200 $this->metadata[
'lastline'] = $lastlogline;
201 $this->metadata[
'lastlinehash'] = sha1($lastlogline);