Commit 17444e92 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Logs korrigiert

parent eb8c1c04
......@@ -57,9 +57,11 @@ class AdminInterface extends Controller
$yesterday = 0;
$rekordTag = 0;
$rekordTagDate = "";
$size = 0;
$count = 0;
for($i = 1; $i <= 28; $i ++ )
{
$logDate = "/var/log/metager/archive/" . date("Y-m-d", mktime(date("H"),date("i"), date("s"), date("m"), date("d")-$i, date("Y"))) . "_mg3.log";
$logDate = "/var/log/metager/archive/mg3.log.$i";
if( file_exists($logDate) )
{
$sameTime = exec("grep -n '" . date('H') . ":" . date('i') . ":' $logDate | tail -1 | cut -f1 -d':'");
......@@ -72,69 +74,22 @@ class AdminInterface extends Controller
}
$oldLogs[$i]['sameTime'] = $sameTime;
$oldLogs[$i]['insgesamt'] = $insgesamt;
}
}
$median = [];
# Median für 7 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 7; $i++)
{
if( isset($oldLogs[$i]) )
{
$count += $oldLogs[$i]['insgesamt'];
# Nun noch den median:
$count += $insgesamt;
$size++;
if($size > 0)
$oldLogs[$i]['median'] = ($count/$size);
}
}
$median[7] = ($count/$size);
# Median für 14 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 14; $i++)
{
if( isset($oldLogs[$i]) )
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
}
$median[14] = ($count/$size);
# Median für 21 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 21; $i++)
{
if( isset($oldLogs[$i]) )
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
}
$median[21] = ($count/$size);
# Median für 28 Tage:
$size = 0;
$count = 0;
for($i = 1; $i <= 28; $i++)
{
if( isset($oldLogs[$i]) )
{
$count += $oldLogs[$i]['insgesamt'];
$size++;
}
}
$median[28] = ($count/$size);
return view('admin.count')
->with('title', 'Suchanfragen - MetaGer')
->with('today', number_format(floatval(sizeof($logToday)), 0, ",", "."))
->with('oldLogs', $oldLogs)
->with('rekordCount', number_format(floatval($rekordTag), 0, ",", "."))
->with('rekordTagSameTime', number_format(floatval($rekordTagSameTime), 0, ",", "."))
->with('rekordDate', $rekordTagDate)
->with('median', $median);
->with('rekordDate', $rekordTagDate);
}
public function check ()
{
......
......@@ -4,14 +4,33 @@
@section('content')
<h2>{{ exec("uptime") }}</h2>
<h3>Heute haben wir bis jetzt => <span class="text-info">{{ $today }}</span> Abfragen</h3>
<h3>Gestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[1]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[1]['insgesamt'] }}</span></h3>
<h3>Vorgestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[2]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[2]['insgesamt'] }}</span></h3>
<h3>Vorvorgestern zur gleichen Zeit <span class="text-info">{{ $oldLogs[3]['sameTime'] }}</span> - insgesamt <span class="text-danger">{{ $oldLogs[3]['insgesamt'] }}</span></h3>
<ul class="list-unstyled" style="text-align:left;">
@foreach($median as $time => $value)
<li><h4>Mittelwert der letzten {{ $time }} Tage: <span class="text-danger">{{ number_format($value, 0, ",", ".") }}</span> Abfragen pro Tag</h4></li>
<table class="table table-striped">
<caption>Daten der letzten Tage</caption>
<tr>
<th>Datum</th>
<th>Suchanfragen zur gleichen Zeit</th>
<th>Suchanfragen insgesamt</th>
<th>Mittelwert</th>
</tr>
@if( isset($today) )
<tr>
<td>{{ date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))) }}</td>
<td>{{ $today }}</td>
<td>???</td>
<td>???</td>
</tr>
@endif
@foreach($oldLogs as $key => $value)
<tr>
<td>{{ date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d")-$key, date("Y"))) }}</td>
<td>{{ $value['sameTime'] }}</td>
<td>{{ $value['insgesamt'] }}</td>
<td>{{ $value['median'] }}</td>
</tr>
@endforeach
</ul>
</table>
@if( isset($rekordDate) && isset($rekordTagSameTime) && isset($rekordCount) )
<h3>Rekord am {{ $rekordDate }} zur gleichen Zeit <span class="text-info">{{ $rekordTagSameTime }}</span> - insgesamt <span class="text-danger">{{ $rekordCount }}</span></h3>
@endif
@endsection
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment