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

SVG Grafik geändert, sodass Sie nur den Zeitraum der letzten Stunde anzeigt

parent 0d4f68ee
No related branches found
No related tags found
2 merge requests!127Development,!126SVG Grafik geändert, sodass Sie nur den Zeitraum der letzten Stunde anzeigt
...@@ -9,23 +9,36 @@ use Redis; ...@@ -9,23 +9,36 @@ use Redis;
class AdminInterface extends Controller class AdminInterface extends Controller
{ {
public function index () public function index (Request $request)
{ {
$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"))));
$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);
$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') return view('admin')
->with('data', $data) ->with('data', $data)
->with('title', "Admin-Interface-MetaGer"); ->with('title', "Admin-Interface-MetaGer")
->with('time', $time);
} }
} }
...@@ -27,25 +27,43 @@ ...@@ -27,25 +27,43 @@
<line x1="99%" y1="95%" x2="98%" y2="98%" 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 --> <!-- Beschriftungen der X-Achse -->
@for( $x = (((99-1) / 24) + 1); $x < 98.9; $x = ($x + ((99-1) / 24)) ) <?php
<line x1="{{ $x }}%" y1="93%" x2="{{ $x }}%" y2="97%" style="stroke:rgb(0,0,0);stroke-width:1" /> $last = 0;
<text x="{{ $x }}%" y="99%" fill="black" style="font-size:10px;">{{ (($x-1) / 98)*24 }}</text> for( $x = (((99-1) / $time) + 1); $x < 98.9; $x = ($x + ((99-1) / $time)) )
@endfor {
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> <text x="95%" y="90%" fill="red">Zeit (h): y</text>
<!-- Nun die Datenpunkte: --> <!-- Nun die Datenpunkte: -->
<?php <?php
$count = 0; $count = 0;
$maximum = 0;
$maximumY = 0;
foreach($dataPoints as $key => $value) foreach($dataPoints as $key => $value)
{ {
if($count > 0) if($count > 0)
{ {
$x1 = ($oldKey / 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"))));
$x2 = ($key / 86400) * 98; $lastkey = $oldKey - $start;
$newkey = $key - $start ;
$x1 = (($lastkey / ($time*60)) * 98) + 1;
$x2 = (($newkey / ($time*60)) * 98) + 1;
$y1 = 95 - (($oldVal / 100) * 95); $y1 = 95 - (($oldVal / 100) * 95);
$y2 = 95 - (($value / 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" />'; echo '<line x1="'.$x1.'%" y1="'.$y1.'%" x2="'.$x2.'%" y2="'.$y2.'%" style="stroke:rgb(0,0,0);stroke-width:1" />';
} }
$oldKey = $key; $oldKey = $key;
...@@ -53,6 +71,8 @@ ...@@ -53,6 +71,8 @@
$count++; $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> </svg>
</div> </div>
@endforeach @endforeach
......
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