Commit 85267ea6 authored by Dominik Hebeler's avatar Dominik Hebeler

added stats

parent dbee982d
...@@ -193,6 +193,54 @@ class AdminInterface extends Controller ...@@ -193,6 +193,54 @@ class AdminInterface extends Controller
} }
public function engineStats()
{
$result = [];
$result["loadavg"] = sys_getloadavg();
// Memory Data
$data = explode("\n", trim(file_get_contents("/proc/meminfo")));
$meminfo = [];
foreach ($data as $line) {
list($key, $val) = explode(":", $line);
$meminfo[$key] = trim($val);
}
$conversions = [
"KB",
"MB",
"GB",
"TB",
];
$memAvailable = $meminfo["MemAvailable"];
$memAvailable = intval(explode(" ", $memAvailable)[0]);
$counter = 0;
while ($memAvailable > 1000) {
$memAvailable /= 1000.0;
$counter++;
}
$memAvailable = round($memAvailable);
$memAvailable .= " " . $conversions[$counter];
$result["memoryAvailable"] = $memAvailable;
$resultCount = 0;
$file = "/var/log/metager/mg3.log";
if (file_exists($file)) {
$fh = fopen($file, "r");
try {
while (fgets($fh) !== false) {
$resultCount++;
}
} finally {
fclose($fh);
}
}
$result["resultCount"] = number_format($resultCount, 0, ",", ".");
return response()->json($result);
}
private function getStats($days) private function getStats($days)
{ {
$maxDate = Carbon::createFromFormat('d.m.Y', "28.06.2016"); $maxDate = Carbon::createFromFormat('d.m.Y', "28.06.2016");
......
...@@ -12,14 +12,14 @@ ...@@ -12,14 +12,14 @@
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="auto" viewBox="0 0 400 100"> <svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="auto" viewBox="0 0 400 100">
<!-- Y-Achse --> <!-- Y-Achse -->
<path d="m{{$startX}} {{$startY}} L{{$startX}} {{$padding}} L{{$startX-1}} {{$padding}} L{{$startX}} {{$padding-1}} L{{$startX+1}} {{$padding}} L{{$startX}} {{$padding}}z" fill="#333" stroke="#333" stroke-width=".7" /> <path d="m{{$startX}} {{$startY}} L{{$startX}} {{$padding}} L{{$startX-1}} {{$padding}} L{{$startX}} {{$padding-1}} L{{$startX+1}} {{$padding}} L{{$startX}} {{$padding}}z" fill="#333" stroke="#333" stroke-width=".7" />
<text x="{{ $startX + 4}}" y="{{ $padding + $paddingArrow - 2 }}" style="font-size: .3em;" fill="rgba(0,0,0,.5)"> <text x="{{ $startX + 4}}" y="{{ $padding + $paddingArrow - 2 }}" style="font-size: 6px;" fill="rgba(0,0,0,.5)">
X(Abfragen) Y(Abfragen)
</text> </text>
<!-- Skalierung Y-Achse --> <!-- Skalierung Y-Achse -->
@for($i = 0; $i < 10; $i++) @for($i = 0; $i < 10; $i++)
<line x1="{{$startX-1}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$startX+1}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#333" stroke="#333" stroke-width=".7" /> <line x1="{{$startX-1}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$startX+1}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#333" stroke="#333" stroke-width=".7" />
<line x1="{{$startX}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$width-$padding-$paddingArrow}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#777" stroke="#777" stroke-width=".2" /> <line x1="{{$startX}}" y1="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" x2="{{$width-$padding-$paddingArrow}}" y2="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) }}" fill="#777" stroke="#777" stroke-width=".2" />
<text x="{{$startX - 15}}" y="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) + 2 }}" style="font-size: .3em;"> <text x="{{$startX - 15}}" y="{{ ($padding+$paddingArrow) + (($startY-($padding+$paddingArrow)) * ($i/10.0)) + 2 }}" style="font-size: 6px;">
@php ($value = round($data["max"] - $i * ($data["max"] / 10.0))) @php ($value = round($data["max"] - $i * ($data["max"] / 10.0)))
@if($value >= 1000) @if($value >= 1000)
@php($value = round($value / 100.0) / 10.0 . "k" ) @php($value = round($value / 100.0) / 10.0 . "k" )
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
@endfor @endfor
@for($i = 0; $i < $entryCount; $i++) @for($i = 0; $i < $entryCount; $i++)
<rect x="{{ $startX + ($widthPerElement * $i * 2) + $widthPerElement}}" y="{{ $startY - ($heightPerSearch * $data["hourly"][$i]) }}" width="{{ $widthPerElement }}" height="{{ ($heightPerSearch * $data["hourly"][$i]) }}" style="fill:rgb(255,127,0); stroke-width:0;" /> <rect x="{{ $startX + ($widthPerElement * $i * 2) + $widthPerElement}}" y="{{ $startY - ($heightPerSearch * $data["hourly"][$i]) }}" width="{{ $widthPerElement }}" height="{{ ($heightPerSearch * $data["hourly"][$i]) }}" style="fill:rgb(255,127,0); stroke-width:0;" />
<text x="{{ $startX + ($widthPerElement * 1.4) + (($width - $padding - $paddingArrow - $startX - ($widthPerElement * 2)) * ($i/($entryCount-1)))}}" y="{{$startY + 6}}" style="font-size: .3em;" > <text x="{{ $startX + ($widthPerElement * 1.4) + (($width - $padding - $paddingArrow - $startX - ($widthPerElement * 2)) * ($i/($entryCount-1)))}}" y="{{$startY + 6}}" style="font-size: 6px;" >
{{ number_format($i, 0, ",", ".") }} {{ number_format($i, 0, ",", ".") }}
</text> </text>
@endfor @endfor
<!-- X-Achse --> <!-- X-Achse -->
<path d="m{{$startX}} {{$startY}} L{{$width-$padding}} {{$startY}} L{{$width-$padding}} {{$startY-1}} L{{$width-($padding-1)}} {{$startY}} L{{$width-$padding}} {{$startY+1}} L{{$width-$padding}} {{$startY}}z" fill="#333" stroke="#333" stroke-width=".5" /> <path d="m{{$startX}} {{$startY}} L{{$width-$padding}} {{$startY}} L{{$width-$padding}} {{$startY-1}} L{{$width-($padding-1)}} {{$startY}} L{{$width-$padding}} {{$startY+1}} L{{$width-$padding}} {{$startY}}z" fill="#333" stroke="#333" stroke-width=".5" />
<text x="{{ $width - 4}}" y="{{ $startY + 3}}" style="font-size: .3em;" fill="rgba(0,0,0,.5)" writing-mode="tb"> <text x="{{ $width - 4}}" y="{{ $startY + 3}}" style="font-size: 6px;" fill="rgba(0,0,0,.5)" writing-mode="tb">
Y(h) X(h)
</text> </text>
</svg> </svg>
...@@ -171,6 +171,7 @@ Route::group( ...@@ -171,6 +171,7 @@ Route::group(
Route::get('/', 'AdminInterface@index'); Route::get('/', 'AdminInterface@index');
Route::match(['get', 'post'], 'count', 'AdminInterface@count'); Route::match(['get', 'post'], 'count', 'AdminInterface@count');
Route::get('count/graphtoday.svg', 'AdminInterface@countGraphToday'); Route::get('count/graphtoday.svg', 'AdminInterface@countGraphToday');
Route::get('engine/stats.json', 'AdminInterface@engineStats');
Route::get('check', 'AdminInterface@check'); Route::get('check', 'AdminInterface@check');
Route::get('engines', 'AdminInterface@engines'); Route::get('engines', 'AdminInterface@engines');
}); });
......
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