diff --git a/app/Http/Controllers/AdminInterface.php b/app/Http/Controllers/AdminInterface.php index b0d2117a644121d973a573c21d6aa7756c7589a6..c6eb5d77166be4d393d3be2759bffa340f8c7fc3 100644 --- a/app/Http/Controllers/AdminInterface.php +++ b/app/Http/Controllers/AdminInterface.php @@ -9,23 +9,36 @@ use Redis; class AdminInterface extends Controller { - public function index () + public function index (Request $request) { + $time = $request->input('time', 60); + # Zunächst einmal die Redis-Verbindung: $redis = Redis::connection('redisLogs'); # Dann lesen wir alle Server aus: $member = $redis->smembers('logs.worker'); + $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; # Jetzt besorgen wir uns die Daten für jeden Server: $data = []; foreach( $member as $mem ) { $tmp = $redis->hgetall('logs.worker.' . $mem); - $data[$mem] = $tmp; + ksort($tmp, SORT_NUMERIC); + $tmp2 = []; + foreach($tmp as $el => $value) + { + if($el >= $beginningTime) + $data[$mem][$el] = $value ; + } } + #$data = [ 5 => "majm", 2 => "mngsn", 7 => "akljsd"]; + #arsort($data); return view('admin') ->with('data', $data) - ->with('title', "Admin-Interface-MetaGer"); + ->with('title', "Admin-Interface-MetaGer") + ->with('time', $time); } } diff --git a/resources/views/admin.blade.php b/resources/views/admin.blade.php index 61cbcf091159a1cea51d76960a882cba62966a59..924962c9ce5fc546385e5a6243308c29c82829bf 100644 --- a/resources/views/admin.blade.php +++ b/resources/views/admin.blade.php @@ -27,25 +27,43 @@ <line x1="99%" y1="95%" x2="98%" y2="98%" style="stroke:rgb(0,0,0);stroke-width:3" /> <!-- Beschriftungen der X-Achse --> - @for( $x = (((99-1) / 24) + 1); $x < 98.9; $x = ($x + ((99-1) / 24)) ) - <line x1="{{ $x }}%" y1="93%" x2="{{ $x }}%" y2="97%" style="stroke:rgb(0,0,0);stroke-width:1" /> - <text x="{{ $x }}%" y="99%" fill="black" style="font-size:10px;">{{ (($x-1) / 98)*24 }}</text> - @endfor + <?php + $last = 0; + for( $x = (((99-1) / $time) + 1); $x < 98.9; $x = ($x + ((99-1) / $time)) ) + { + echo '<line x1="'.$x.'%" y1="93%" x2="'.$x.'%" y2="97%" style="stroke:rgb(0,0,0);stroke-width:1" />'; + if( ($x - $last) >= 3) + { + echo '<text x="'.($x-1).'%" y="99%" fill="black" style="font-size:8px;">'.date("H:i", mktime(date("H"),date("i")-($time -(($x-1) / 98)*$time), date("s"), date("m"), date("d"), date("Y"))).'</text>'; + $last = $x; + } + } + ?> <text x="95%" y="90%" fill="red">Zeit (h): y</text> <!-- Nun die Datenpunkte: --> <?php $count = 0; - + $maximum = 0; + $maximumY = 0; foreach($dataPoints as $key => $value) { if($count > 0) { - $x1 = ($oldKey / 86400) * 98; - $x2 = ($key / 86400) * 98; + $start = strtotime(date(DATE_RFC822, mktime(date("H"),date("i")-$time, date("s"), date("m"), date("d"), date("Y")))) - strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d"), date("Y")))); + $lastkey = $oldKey - $start; + $newkey = $key - $start ; + + $x1 = (($lastkey / ($time*60)) * 98) + 1; + $x2 = (($newkey / ($time*60)) * 98) + 1; $y1 = 95 - (($oldVal / 100) * 95); $y2 = 95 - (($value / 100) * 95); + if($value > $maximum) + { + $maximum = $value; + $maximumY = $y2; + } echo '<line x1="'.$x1.'%" y1="'.$y1.'%" x2="'.$x2.'%" y2="'.$y2.'%" style="stroke:rgb(0,0,0);stroke-width:1" />'; } $oldKey = $key; @@ -53,6 +71,8 @@ $count++; } ?> + <!-- Und noch eine Linie für das Maximum: --> + <line x1="1%" y1="{{ $maximumY }}%" x2="99%" y2="{{ $maximumY }}%" style="stroke:rgb(255,0,0);stroke-width:1" stroke-dasharray="5,5" d="M5 20 l215 0"/> </svg> </div> @endforeach