Skip to content
Snippets Groups Projects
Commit 9fe94eb8 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

Darstellung verändert

parent c39eb1ab
No related branches found
No related tags found
1 merge request!359Development
...@@ -3,86 +3,79 @@ ...@@ -3,86 +3,79 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use App\Http\Requests;
use Redis; use Redis;
use Response;
class AdminInterface extends Controller class AdminInterface extends Controller
{ {
public function index (Request $request) public function index(Request $request)
{ {
$time = $request->input('time', 60); $time = $request->input('time', 60);
# Zunächst einmal die Redis-Verbindung: # Zunächst einmal die Redis-Verbindung:
$redis = Redis::connection('redisLogs'); $redis = Redis::connection('redisLogs');
# Dann lesen wir alle Server aus: # Dann lesen wir alle Server aus:
$member = $redis->smembers('logs.worker'); $member = $redis->smembers('logs.worker');
$today = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d"), date("Y")))); $today = strtotime(date(DATE_RFC822, mktime(0, 0, 0, date("m"), date("d"), date("Y"))));
$beginningTime = strtotime(date(DATE_RFC822, mktime(date("H"),date("i")-$time, date("s"), date("m"), date("d"), date("Y")))) - $today; $beginningTime = strtotime(date(DATE_RFC822, mktime(date("H"), date("i") - $time, date("s"), date("m"), date("d"), date("Y")))) - $today;
# Jetzt besorgen wir uns die Daten für jeden Server: # Jetzt besorgen wir uns die Daten für jeden Server:
$data = []; $data = [];
foreach( $member as $mem ) foreach ($member as $mem) {
{ $tmp = $redis->hgetall('logs.worker.' . $mem);
$tmp = $redis->hgetall('logs.worker.' . $mem);
ksort($tmp, SORT_NUMERIC); ksort($tmp, SORT_NUMERIC);
$tmp2 = []; $tmp2 = [];
foreach($tmp as $el => $value) foreach ($tmp as $el => $value) {
{ if ($el >= $beginningTime) {
if($el >= $beginningTime) $data[$mem][$el] = $value;
$data[$mem][$el] = $value ; }
} }
} }
#$data = [ 5 => "majm", 2 => "mngsn", 7 => "akljsd"]; #$data = [ 5 => "majm", 2 => "mngsn", 7 => "akljsd"];
#arsort($data); #arsort($data);
return view('admin.admin') return view('admin.admin')
->with('data', $data) ->with('data', $data)
->with('title', "Admin-Interface-MetaGer") ->with('title', "Admin-Interface-MetaGer")
->with('time', $time); ->with('time', $time);
} }
public function count() public function count()
{ {
$logToday = "mg3.log"; $logToday = "mg3.log";
if(file_exists("/var/log/metager/".$logToday)) if (file_exists("/var/log/metager/" . $logToday)) {
{ $logToday = file("/var/log/metager/" . $logToday);
$logToday = file("/var/log/metager/".$logToday); } else {
}else
{
return redirect(''); return redirect('');
} }
$oldLogs = []; $oldLogs = [];
$yesterday = 0; $yesterday = 0;
$rekordTag = 0; $rekordTag = 0;
$rekordTagDate = ""; $rekordTagDate = "";
$size = 0; $size = 0;
$count = 0; $count = 0;
for($i = 1; $i <= 28; $i ++ ) for ($i = 1; $i <= 28; $i++) {
{
$logDate = "/var/log/metager/archive/mg3.log.$i"; $logDate = "/var/log/metager/archive/mg3.log.$i";
if( file_exists($logDate) ) if (file_exists($logDate)) {
{ $sameTime = exec("grep -n '" . date('H') . ":" . date('i') . ":' $logDate | tail -1 | cut -f1 -d':'");
$sameTime = exec("grep -n '" . date('H') . ":" . date('i') . ":' $logDate | tail -1 | cut -f1 -d':'");
$insgesamt = exec("wc -l $logDate | cut -f1 -d' '"); $insgesamt = exec("wc -l $logDate | cut -f1 -d' '");
if($insgesamt > $rekordTag) if ($insgesamt > $rekordTag) {
{ $rekordTag = $insgesamt;
$rekordTag = $insgesamt;
$rekordTagSameTime = $sameTime; $rekordTagSameTime = $sameTime;
$rekordTagDate = date("d.m.Y", mktime(date("H"),date("i"), date("s"), date("m"), date("d")-$i, date("Y"))); $rekordTagDate = date("d.m.Y", mktime(date("H"), date("i"), date("s"), date("m"), date("d") - $i, date("Y")));
} }
$oldLogs[$i]['sameTime'] = $sameTime; $oldLogs[$i]['sameTime'] = number_format(floatval($sameTime), 0, ",", ".");
$oldLogs[$i]['insgesamt'] = $insgesamt; $oldLogs[$i]['insgesamt'] = number_format(floatval($insgesamt), 0, ",", ".");
# Nun noch den median: # Nun noch den median:
$count += $insgesamt; $count += $insgesamt;
$size++; $size++;
if($size > 0) if ($size > 0) {
$oldLogs[$i]['median'] = ($count/$size); $oldLogs[$i]['median'] = number_format(floatval(round($count / $size)), 0, ",", ".");
}
} }
} }
return view('admin.count') return view('admin.count')
->with('title', 'Suchanfragen - MetaGer') ->with('title', 'Suchanfragen - MetaGer')
->with('today', number_format(floatval(sizeof($logToday)), 0, ",", ".")) ->with('today', number_format(floatval(sizeof($logToday)), 0, ",", "."))
...@@ -91,14 +84,13 @@ class AdminInterface extends Controller ...@@ -91,14 +84,13 @@ class AdminInterface extends Controller
->with('rekordTagSameTime', number_format(floatval($rekordTagSameTime), 0, ",", ".")) ->with('rekordTagSameTime', number_format(floatval($rekordTagSameTime), 0, ",", "."))
->with('rekordDate', $rekordTagDate); ->with('rekordDate', $rekordTagDate);
} }
public function check () public function check()
{ {
$q = ""; $q = "";
$redis = Redis::connection('redisLogs'); $redis = Redis::connection('redisLogs');
if($redis) if ($redis) {
{
$q = $redis->lrange("logs.search", -1, -1)[0]; $q = $redis->lrange("logs.search", -1, -1)[0];
$q = substr($q, strpos($q, "search=")+7); $q = substr($q, strpos($q, "search=") + 7);
} }
return view('admin.check') return view('admin.check')
->with('title', 'Wer sucht was? - MetaGer') ->with('title', 'Wer sucht was? - MetaGer')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment