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

Admin Interface hinzugefügt

parent 825086fa
No related branches found
No related tags found
2 merge requests!122Development,!120Resolve "Der Status der laufenden Worker wird noch nicht in die Suche mit einbezogen."
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use Redis;
class AdminInterface extends Controller
{
public function index ()
{
# Zunächst einmal die Redis-Verbindung:
$redis = Redis::connection('redisLogs');
# Dann lesen wir alle Server aus:
$member = $redis->smembers('logs.worker');
# Jetzt besorgen wir uns die Daten für jeden Server:
$data = [];
foreach( $member as $mem )
{
$tmp = $redis->hgetall('logs.worker.' . $mem);
$data[$mem] = $tmp;
}
return view('admin')
->with('data', $data)
->with('title', "Admin-Interface-MetaGer");
}
}
...@@ -112,6 +112,8 @@ ...@@ -112,6 +112,8 @@
->with('navbarFocus', 'dienste'); ->with('navbarFocus', 'dienste');
}); });
Route::get('admin', ['middleware' => 'auth.basic', 'uses' => 'AdminInterface@index']);
Route::get('settings', 'StartpageController@loadSettings'); Route::get('settings', 'StartpageController@loadSettings');
......
...@@ -25,14 +25,16 @@ class AppServiceProvider extends ServiceProvider ...@@ -25,14 +25,16 @@ class AppServiceProvider extends ServiceProvider
$this->begin = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y")))); $this->begin = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y"))));
}); });
Queue::after(function (JobProcessed $event) { Queue::after(function (JobProcessed $event) {
$this->end = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y")))); $today = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d"), date("Y"))));
$end = strtotime(date(DATE_RFC822, mktime(date("H"),date("i"), date("s"), date("m"), date("d"), date("Y")))) - $today;
$expireAt = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d")+1, date("Y")))); $expireAt = strtotime(date(DATE_RFC822, mktime(0,0,0, date("m"), date("d")+1, date("Y"))));
$redis = Redis::connection('redisLogs'); $redis = Redis::connection('redisLogs');
$p = getmypid(); $p = getmypid();
$host = gethostname(); $host = gethostname();
$redis->pipeline(function($pipe) use ($p, $expireAt, $host) $begin = $this->begin - $today;
$redis->pipeline(function($pipe) use ($p, $expireAt, $host, $begin, $end)
{ {
for( $i = $this->begin; $i <= $this->end; $i++) for( $i = $begin; $i <= $end; $i++)
{ {
$pipe->sadd("logs.worker.$host.$i", strval($p)); $pipe->sadd("logs.worker.$host.$i", strval($p));
$pipe->expire("logs.worker.$host.$i", 10); $pipe->expire("logs.worker.$host.$i", 10);
......
No preview for this file type
@extends('layouts.subPages')
@section('title', $title )
@section('content')
@foreach( $data as $serverName => $dataPoints )
<div>
<h1>{{ $serverName }}</h1>
<svg width="100%" height="500px">
<!-- Zunächst die Achsen: -->
<!-- Y-Achse -->
<line x1="1%" y1="0" x2="1%" y2="95%" style="stroke:rgb(0,0,0);stroke-width:3" />
<line x1="1%" y1="0" x2="0" y2="3%" style="stroke:rgb(0,0,0);stroke-width:3" />
<line x1="1%" y1="0" x2="2%" y2="3%" style="stroke:rgb(0,0,0);stroke-width:3" />
<!-- Beschriftungen der Y-Achse -->
@for( $y = ((95-0) / 10); $y < ((95-0) / 10) * 10; $y = $y + ((95-0) / 10) )
<line x1="0.5%" y1="{{ $y }}%" x2="1.5%" y2="{{ $y }}%" style="stroke:rgb(0,0,0);stroke-width:1" />
<text x="1.8%" y="{{ $y }}%" fill="black" style="font-size:10px;">{{ 100 - (($y / 95)*100) }}</text>
@endfor
<text x="3%" y="2%" fill="red">Anzahl Worker: x</text>
<!-- X-Achse -->
<line x1="1%" y1="95%" x2="99%" y2="95%" style="stroke:rgb(0,0,0);stroke-width:3" />
<line x1="99%" y1="95%" x2="98%" y2="92%" style="stroke:rgb(0,0,0);stroke-width:3" />
<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
<text x="95%" y="90%" fill="red">Zeit (h): y</text>
<!-- Nun die Datenpunkte: -->
<?php
$count = 0;
foreach($dataPoints as $key => $value)
{
if($count > 0)
{
$x1 = ($oldKey / 86400) * 98;
$x2 = ($key / 86400) * 98;
$y1 = 95 - (($oldVal / 100) * 95);
$y2 = 95 - (($value / 100) * 95);
echo '<line x1="'.$x1.'%" y1="'.$y1.'%" x2="'.$x2.'%" y2="'.$y2.'%" style="stroke:rgb(0,0,0);stroke-width:1" />';
}
$oldKey = $key;
$oldVal = $value;
$count++;
}
?>
</svg>
</div>
@endforeach
@endsection
\ No newline at end of file
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