Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MetaGer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open-source
MetaGer
Commits
f460f090
Commit
f460f090
authored
7 years ago
by
Dominik Hebeler
Browse files
Options
Downloads
Plain Diff
Merge branch '485-ux-bei-such-timeout' into 'development'
Erstes Admin Interface für die Üebrwachung der Fetcher Closes
#485
See merge request
!844
parents
4817fac4
7602cfdb
No related branches found
Branches containing commit
No related tags found
1 merge request
!1365
Resolve "Filter Options for MetaGer"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
app/Http/Controllers/AdminInterface.php
+67
-22
67 additions, 22 deletions
app/Http/Controllers/AdminInterface.php
resources/views/admin/admin.blade.php
+20
-67
20 additions, 67 deletions
resources/views/admin/admin.blade.php
routes/web.php
+2
-1
2 additions, 1 deletion
routes/web.php
with
89 additions
and
90 deletions
app/Http/Controllers/AdminInterface.php
+
67
−
22
View file @
f460f090
...
@@ -4,40 +4,85 @@ namespace App\Http\Controllers;
...
@@ -4,40 +4,85 @@ namespace App\Http\Controllers;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Redis
;
use
Response
;
class
AdminInterface
extends
Controller
class
AdminInterface
extends
Controller
{
{
public
function
index
(
Request
$request
)
public
function
index
(
Request
$request
)
{
{
$time
=
$request
->
input
(
'time'
,
60
);
$localFetcher
=
file_get_contents
(
action
(
"AdminInterface@getFetcherStatus"
));
die
(
var_dump
(
$localFetcher
));
}
# Zunächst einmal die Redis-Verbindung:
public
function
getFetcherStatus
()
$redis
=
Redis
::
connection
(
'redisLogs'
);
{
// Let's get the stats for this server.
// First we need to check, which Fetcher could be available by parsing the sumas.xml
$names
=
$this
->
getSearchEngineNames
();
# Dann lesen wir alle Server aus:
// Now we gonna check which stats we can find
$member
=
$redis
->
smembers
(
'logs.worker'
);
$stati
=
array
();
$today
=
strtotime
(
date
(
DATE_RFC822
,
mktime
(
0
,
0
,
0
,
date
(
"m"
),
date
(
"d"
),
date
(
"Y"
))));
foreach
(
$names
as
$name
){
$beginningTime
=
strtotime
(
date
(
DATE_RFC822
,
mktime
(
date
(
"H"
),
date
(
"i"
)
-
$time
,
date
(
"s"
),
date
(
"m"
),
date
(
"d"
),
date
(
"Y"
))))
-
$today
;
$stats
=
Redis
::
hgetall
(
$name
.
".stats"
);
if
(
sizeof
(
$stats
)
>
0
){
# Jetzt besorgen wir uns die Daten für jeden Server:
$fetcherStatus
=
Redis
::
get
(
$name
);
$data
=
[];
$stati
[
$name
][
"status"
]
=
$fetcherStatus
;
foreach
(
$member
as
$mem
)
{
foreach
(
$stats
as
$pid
=>
$value
){
$tmp
=
$redis
->
hgetall
(
'logs.worker.'
.
$mem
);
if
(
strstr
(
$value
,
";"
)){
ksort
(
$tmp
,
SORT_NUMERIC
);
$value
=
explode
(
";"
,
$value
);
$tmp2
=
[];
$connection
=
json_decode
(
base64_decode
(
$value
[
0
]),
true
);
foreach
(
$tmp
as
$el
=>
$value
)
{
foreach
(
$connection
as
$key
=>
$val
){
if
(
$el
>=
$beginningTime
)
{
if
(
strstr
(
$key
,
"_time"
))
$data
[
$mem
][
$el
]
=
$value
;
$stati
[
$name
][
"fetcher"
][
$pid
][
"connection"
][
$key
]
=
$val
;
}
$stati
[
$name
][
"fetcher"
][
$pid
][
"poptime"
]
=
$value
[
1
];
}
}
}
}
}
// So now we can generate Median Times for every Fetcher
foreach
(
$stati
as
$engineName
=>
$engineStats
){
$connection
=
array
();
$poptime
=
0
;
foreach
(
$engineStats
[
"fetcher"
]
as
$pid
=>
$stats
){
foreach
(
$stats
[
"connection"
]
as
$key
=>
$value
){
if
(
!
isset
(
$connection
[
$key
])){
$connection
[
$key
]
=
$value
;
}
else
{
$connection
[
$key
]
+=
$value
;
}
}
$poptime
+=
floatval
(
$stats
[
"poptime"
]);
}
foreach
(
$connection
as
$key
=>
$value
){
$connection
[
$key
]
/=
sizeof
(
$engineStats
[
"fetcher"
]);
}
}
$poptime
/=
sizeof
(
$engineStats
[
"fetcher"
]);
$stati
[
$engineName
][
"median-connection"
]
=
$connection
;
$stati
[
$engineName
][
"median-poptime"
]
=
$poptime
;
}
}
#$data = [ 5 => "majm", 2 => "mngsn", 7 => "akljsd"];
#arsort($data);
return
view
(
'admin.admin'
)
return
view
(
'admin.admin'
)
->
with
(
'data'
,
$data
)
->
with
(
'title'
,
'Fetcher Status'
)
->
with
(
'title'
,
"Admin-Interface-MetaGer"
)
->
with
(
'stati'
,
$stati
);
->
with
(
'time'
,
$time
);
$stati
=
json_encode
(
$stati
);
$response
=
Response
::
make
(
$stati
,
200
);
$response
->
header
(
"Content-Type"
,
"application/json"
);
return
$response
;
}
private
function
getSearchEngineNames
(){
$url
=
config_path
()
.
"/sumas.xml"
;
$xml
=
simplexml_load_file
(
$url
);
$sumas
=
$xml
->
xpath
(
"suma"
);
$names
=
array
();
foreach
(
$sumas
as
$suma
){
$names
[]
=
$suma
[
"name"
]
->
__toString
();
}
return
$names
;
}
}
public
function
count
()
public
function
count
()
...
...
This diff is collapsed.
Click to expand it.
resources/views/admin/admin.blade.php
+
20
−
67
View file @
f460f090
...
@@ -3,71 +3,24 @@
...
@@ -3,71 +3,24 @@
@
section
(
'title'
,
$title
)
@
section
(
'title'
,
$title
)
@
section
(
'content'
)
@
section
(
'content'
)
@
foreach
(
$data
as
$serverName
=>
$dataPoints
)
<
table
class
=
"table table-bordered"
>
<
div
>
<
thead
>
<
h1
>
{{
$serverName
}}
</
h1
>
<
th
>
Name
</
th
>
<
svg
width
=
"100%"
height
=
"500px"
>
<
th
>
Status
</
th
>
<!--
Zunächst
die
Achsen
:
-->
<
th
>
Fetcher
Anzahl
</
th
>
<!--
Y
-
Achse
-->
<
th
>
Abfragedauer
</
th
>
<
line
x1
=
"1%"
y1
=
"0"
x2
=
"1%"
y2
=
"95%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
<
th
>
Abfragelast
</
th
>
<
line
x1
=
"1%"
y1
=
"0"
x2
=
"0"
y2
=
"3%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
</
thead
>
<
line
x1
=
"1%"
y1
=
"0"
x2
=
"2%"
y2
=
"3%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
<
tbody
>
@
foreach
(
$stati
as
$engineName
=>
$engineStats
)
<!--
Beschriftungen
der
Y
-
Achse
-->
<
tr
>
@
for
(
$y
=
((
95
-
0
)
/
10
);
$y
<
((
95
-
0
)
/
10
)
*
10
;
$y
=
$y
+
((
95
-
0
)
/
10
)
)
<
td
>
{{
$engineName
}}
</
td
>
<
line
x1
=
"0.5%"
y1
=
"{{
$y
}}%"
x2
=
"1.5%"
y2
=
"{{
$y
}}%"
style
=
"stroke:rgb(0,0,0);stroke-width:1"
/>
<
td
>
{{
$engineStats
[
"status"
]}}
</
td
>
<
text
x
=
"1.8%"
y
=
"{{
$y
}}%"
fill
=
"black"
style
=
"font-size:10px;"
>
{{
100
-
((
$y
/
95
)
*
100
)
}}
</
text
>
<
td
>
{{
sizeof
(
$engineStats
[
"fetcher"
])}}
</
td
>
@
endfor
<
td
>
{{
$engineStats
[
"median-connection"
][
"total_time"
]}}
s
</
td
>
<
text
x
=
"3%"
y
=
"2%"
fill
=
"red"
>
Anzahl
Worker
:
x
</
text
>
<
td
>
{{
$engineStats
[
"median-poptime"
]}}
</
td
>
</
tr
>
<!--
X
-
Achse
-->
@
endforeach
<
line
x1
=
"1%"
y1
=
"95%"
x2
=
"99%"
y2
=
"95%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
</
tbody
>
<
line
x1
=
"99%"
y1
=
"95%"
x2
=
"98%"
y2
=
"92%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
</
table
>
<
line
x1
=
"99%"
y1
=
"95%"
x2
=
"98%"
y2
=
"98%"
style
=
"stroke:rgb(0,0,0);stroke-width:3"
/>
<!--
Beschriftungen
der
X
-
Achse
-->
<?
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
)
{
$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
;
$oldVal
=
$value
;
$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
@
endsection
@
endsection
\ No newline at end of file
This diff is collapsed.
Click to expand it.
routes/web.php
+
2
−
1
View file @
f460f090
...
@@ -129,8 +129,9 @@ Route::group(
...
@@ -129,8 +129,9 @@ Route::group(
Route
::
get
(
'zitat-suche'
,
'ZitatController@zitatSuche'
);
Route
::
get
(
'zitat-suche'
,
'ZitatController@zitatSuche'
);
Route
::
group
([
'middleware'
=>
[
'referer.check'
],
'prefix'
=>
'admin'
],
function
()
{
Route
::
group
([
/*
'middleware' => ['referer.check'],
*/
'prefix'
=>
'admin'
],
function
()
{
Route
::
get
(
'/'
,
'AdminInterface@index'
);
Route
::
get
(
'/'
,
'AdminInterface@index'
);
Route
::
get
(
'fetcher-status'
,
"AdminInterface@getFetcherStatus"
);
Route
::
get
(
'count'
,
'AdminInterface@count'
);
Route
::
get
(
'count'
,
'AdminInterface@count'
);
Route
::
get
(
'check'
,
'AdminInterface@check'
);
Route
::
get
(
'check'
,
'AdminInterface@check'
);
Route
::
get
(
'engines'
,
'AdminInterface@engines'
);
Route
::
get
(
'engines'
,
'AdminInterface@engines'
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment