Commit 1b2910f7 authored by Dominik Hebeler's avatar Dominik Hebeler
Browse files

fixed scaling of graph. little speed improvement

parent 2a970c84
...@@ -45,33 +45,37 @@ class ConvertCountFile implements ShouldQueue ...@@ -45,33 +45,37 @@ class ConvertCountFile implements ShouldQueue
$logTime = []; $logTime = [];
$interface = ""; $interface = "";
// i.e. [Wed Apr 17 00:00:01] ref=https://metager.de/ time=0.51 serv=web interface=de // i.e. [Wed Apr 17 00:00:01] ref=https://metager.de/ time=0.51 serv=web interface=de
if (preg_match('/(\d{2}:\d{2}:\d{2}).*?\sinterface=(\S+)/', $line, $matches)) { if (preg_match('/(\d{2}):(\d{2}):\d{2}.*?\sinterface=(\S+)/', $line, $matches)) {
// Create Date Object // Create Date Object
$logTime = $matches[1]; $logTime = $matches[1];
$interface = $matches[2]; $minutes = intval($matches[2]);
$minutes = $minutes - ($minutes % 5);
if($minutes < 10){
$minutes = "0" . $minutes;
}
$logTime .= ":" . $minutes;
$interface = $matches[3];
} else { } else {
continue; continue;
} }
$thatTime = \DateTime::createFromFormat('H:i:s', $logTime);
$thatTime->sub(new \DateInterval("PT" . ($thatTime->format('i') % 5) . "M"));
if (empty($result["time"][$thatTime->format('H:i')])) { if (empty($result["time"][$logTime])) {
$result["time"][$thatTime->format('H:i')] = [ $result["time"][$logTime] = [
"insgesamt" => [ "insgesamt" => [
"all" => 0, "all" => 0,
], ],
]; ];
} }
if (empty($result["time"][$thatTime->format('H:i')]["all"])) { if (empty($result["time"][$logTime]["all"])) {
$result["time"][$thatTime->format('H:i')]["all"] = 1; $result["time"][$logTime]["all"] = 1;
} else { } else {
$result["time"][$thatTime->format('H:i')]["all"]++; $result["time"][$logTime]["all"]++;
} }
if (!empty($interface)) { if (!empty($interface)) {
if (empty($result["time"][$thatTime->format('H:i')][$interface])) { if (empty($result["time"][$logTime][$interface])) {
$result["time"][$thatTime->format('H:i')][$interface] = 1; $result["time"][$logTime][$interface] = 1;
} else { } else {
$result["time"][$thatTime->format('H:i')][$interface]++; $result["time"][$logTime][$interface]++;
} }
} }
// Update the total statistics // Update the total statistics
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
@php ($startX = 20) @php ($startX = 20)
@php ($startY = $height-20) @php ($startY = $height-20)
@php ($maxCount = intval(str_replace(".", "", $rekordCount))) @php ($maxCount = intval(str_replace(".", "", $rekordCount)))
@php ($minCount = $minCount) @php ($minCount = 0)
@php ($scaleFromTo = $maxCount - $minCount) @php ($scaleFromTo = $maxCount - $minCount)
@php ($yPerSearch = ($startY - $padding - $paddingArrow) / floatval($scaleFromTo)) @php ($yPerSearch = ($startY - $padding - $paddingArrow) / floatval($scaleFromTo))
@php ($entryCount = min(sizeof($oldLogs), 30)) @php ($entryCount = min(sizeof($oldLogs), 30))
...@@ -50,7 +50,6 @@ ...@@ -50,7 +50,6 @@
@endfor @endfor
</svg> </svg>
</div> </div>
<p>{{ exec("uptime") }}</p>
@if( isset($rekordDate) && isset($rekordTagSameTime) && isset($rekordCount) ) @if( isset($rekordDate) && isset($rekordTagSameTime) && isset($rekordCount) )
<p>Rekord am {{ $rekordDate }} zur gleichen Zeit <span class="text-info">{{ $rekordTagSameTime }}</span> - insgesamt <span class="text-danger">{{ $rekordCount }}</span></p> <p>Rekord am {{ $rekordDate }} zur gleichen Zeit <span class="text-info">{{ $rekordTagSameTime }}</span> - insgesamt <span class="text-danger">{{ $rekordCount }}</span></p>
@endif @endif
...@@ -97,7 +96,7 @@ ...@@ -97,7 +96,7 @@
style="color: green" style="color: green"
@endif @endif
> >
@if($averageIncrease < 0)-@else+@endif{{number_format(floatval($averageIncrease), 0, ",", ".")}} @if($averageIncrease >= 0)+@endif{{number_format(floatval($averageIncrease), 0, ",", ".")}}
</span> </span>
@endif</td> @endif</td>
<td>???</td> <td>???</td>
......
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