Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
open-source
MetaGer
Commits
3ff2e9d1
Commit
3ff2e9d1
authored
Jul 18, 2016
by
Dominik Hebeler
Browse files
Merge branch 'development' into 'master'
Development See merge request
!148
parents
36442636
af313829
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/Http/Controllers/AdminInterface.php
View file @
3ff2e9d1
...
...
@@ -57,9 +57,11 @@ class AdminInterface extends Controller
$yesterday
=
0
;
$rekordTag
=
0
;
$rekordTagDate
=
""
;
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
28
;
$i
++
)
{
$logDate
=
"/var/log/metager/archive/
"
.
date
(
"Y-m-d"
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
)
-
$i
,
date
(
"Y"
)))
.
"_
mg3.log"
;
$logDate
=
"/var/log/metager/archive/mg3.log
.
$i
"
;
if
(
file_exists
(
$logDate
)
)
{
$sameTime
=
exec
(
"grep -n '"
.
date
(
'H'
)
.
":"
.
date
(
'i'
)
.
":'
$logDate
| tail -1 | cut -f1 -d':'"
);
...
...
@@ -72,69 +74,22 @@ class AdminInterface extends Controller
}
$oldLogs
[
$i
][
'sameTime'
]
=
$sameTime
;
$oldLogs
[
$i
][
'insgesamt'
]
=
$insgesamt
;
}
}
$median
=
[];
# Median für 7 Tage:
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
7
;
$i
++
)
{
if
(
isset
(
$oldLogs
[
$i
])
)
{
$count
+=
$oldLogs
[
$i
][
'insgesamt'
];
# Nun noch den median:
$count
+=
$insgesamt
;
$size
++
;
if
(
$size
>
0
)
$oldLogs
[
$i
][
'median'
]
=
(
$count
/
$size
);
}
}
$median
[
7
]
=
(
$count
/
$size
);
# Median für 14 Tage:
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
14
;
$i
++
)
{
if
(
isset
(
$oldLogs
[
$i
])
)
{
$count
+=
$oldLogs
[
$i
][
'insgesamt'
];
$size
++
;
}
}
$median
[
14
]
=
(
$count
/
$size
);
# Median für 21 Tage:
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
21
;
$i
++
)
{
if
(
isset
(
$oldLogs
[
$i
])
)
{
$count
+=
$oldLogs
[
$i
][
'insgesamt'
];
$size
++
;
}
}
$median
[
21
]
=
(
$count
/
$size
);
# Median für 28 Tage:
$size
=
0
;
$count
=
0
;
for
(
$i
=
1
;
$i
<=
28
;
$i
++
)
{
if
(
isset
(
$oldLogs
[
$i
])
)
{
$count
+=
$oldLogs
[
$i
][
'insgesamt'
];
$size
++
;
}
}
$median
[
28
]
=
(
$count
/
$size
);
return
view
(
'admin.count'
)
->
with
(
'title'
,
'Suchanfragen - MetaGer'
)
->
with
(
'today'
,
number_format
(
floatval
(
sizeof
(
$logToday
)),
0
,
","
,
"."
))
->
with
(
'oldLogs'
,
$oldLogs
)
->
with
(
'rekordCount'
,
number_format
(
floatval
(
$rekordTag
),
0
,
","
,
"."
))
->
with
(
'rekordTagSameTime'
,
number_format
(
floatval
(
$rekordTagSameTime
),
0
,
","
,
"."
))
->
with
(
'rekordDate'
,
$rekordTagDate
)
->
with
(
'median'
,
$median
);
->
with
(
'rekordDate'
,
$rekordTagDate
);
}
public
function
check
()
{
...
...
app/MetaGer.php
View file @
3ff2e9d1
...
...
@@ -152,7 +152,7 @@ class MetaGer
private
function
createLogs
()
{
$redis
=
Redis
::
connection
(
'redisLogs'
);
if
(
$redis
)
try
{
$logEntry
=
""
;
$logEntry
.
=
"["
.
date
(
DATE_RFC822
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
),
date
(
"Y"
)))
.
"]"
;
...
...
@@ -177,6 +177,9 @@ class MetaGer
$logEntry
.
=
" iter= mm= time="
.
round
((
microtime
(
true
)
-
$this
->
starttime
),
2
)
.
" serv="
.
$this
->
fokus
.
" which= hits= stringSearch= QuickTips= SSS= check="
;
$logEntry
.
=
" search="
.
$this
->
eingabe
;
$redis
->
rpush
(
'logs.search'
,
$logEntry
);
}
catch
(
\
Exception
$e
)
{
return
;
}
}
...
...
app/Providers/AppServiceProvider.php
View file @
3ff2e9d1
...
...
@@ -28,25 +28,32 @@ class AppServiceProvider extends ServiceProvider
$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"
))));
$redis
=
Redis
::
connection
(
'redisLogs'
);
$p
=
getmypid
();
$host
=
gethostname
();
$begin
=
$this
->
begin
-
$today
;
$redis
->
pipeline
(
function
(
$pipe
)
use
(
$p
,
$expireAt
,
$host
,
$begin
,
$end
)
{
for
(
$i
=
$begin
;
$i
<=
$end
;
$i
++
)
try
{
$redis
=
Redis
::
connection
(
'redisLogs'
);
if
(
!
$redis
)
return
;
$p
=
getmypid
();
$host
=
gethostname
();
$begin
=
$this
->
begin
-
$today
;
$redis
->
pipeline
(
function
(
$pipe
)
use
(
$p
,
$expireAt
,
$host
,
$begin
,
$end
)
{
$pipe
->
sadd
(
"logs.worker.
$host
.
$i
"
,
strval
(
$p
));
$pipe
->
expire
(
"logs.worker.
$host
.
$i
"
,
10
);
$pipe
->
eval
(
"redis.call('hset', 'logs.worker.
$host
', '
$i
', redis.call('scard', 'logs.worker.
$host
.
$i
'))"
,
0
);
$pipe
->
sadd
(
"logs.worker"
,
$host
);
if
(
date
(
"H"
)
!==
0
)
for
(
$i
=
$begin
;
$i
<=
$end
;
$i
++
)
{
$pipe
->
expire
(
"logs.worker.
$host
"
,
$expireAt
);
$pipe
->
expire
(
"logs.worker"
,
$expireAt
);
$pipe
->
sadd
(
"logs.worker.
$host
.
$i
"
,
strval
(
$p
));
$pipe
->
expire
(
"logs.worker.
$host
.
$i
"
,
10
);
$pipe
->
eval
(
"redis.call('hset', 'logs.worker.
$host
', '
$i
', redis.call('scard', 'logs.worker.
$host
.
$i
'))"
,
0
);
$pipe
->
sadd
(
"logs.worker"
,
$host
);
if
(
date
(
"H"
)
!==
0
)
{
$pipe
->
expire
(
"logs.worker.
$host
"
,
$expireAt
);
$pipe
->
expire
(
"logs.worker"
,
$expireAt
);
}
}
}
});
});
}
catch
(
\
Exception
$e
)
{
return
;
}
});
}
...
...
resources/views/admin/count.blade.php
View file @
3ff2e9d1
...
...
@@ -4,14 +4,33 @@
@
section
(
'content'
)
<
h2
>
{{
exec
(
"uptime"
)
}}
</
h2
>
<
h3
>
Heute
haben
wir
bis
jetzt
=>
<
span
class
=
"text-info"
>
{{
$today
}}
</
span
>
Abfragen
</
h3
>
<
h3
>
Gestern
zur
gleichen
Zeit
<
span
class
=
"text-info"
>
{{
$oldLogs
[
1
][
'sameTime'
]
}}
</
span
>
-
insgesamt
<
span
class
=
"text-danger"
>
{{
$oldLogs
[
1
][
'insgesamt'
]
}}
</
span
></
h3
>
<
h3
>
Vorgestern
zur
gleichen
Zeit
<
span
class
=
"text-info"
>
{{
$oldLogs
[
2
][
'sameTime'
]
}}
</
span
>
-
insgesamt
<
span
class
=
"text-danger"
>
{{
$oldLogs
[
2
][
'insgesamt'
]
}}
</
span
></
h3
>
<
h3
>
Vorvorgestern
zur
gleichen
Zeit
<
span
class
=
"text-info"
>
{{
$oldLogs
[
3
][
'sameTime'
]
}}
</
span
>
-
insgesamt
<
span
class
=
"text-danger"
>
{{
$oldLogs
[
3
][
'insgesamt'
]
}}
</
span
></
h3
>
<
ul
class
=
"list-unstyled"
style
=
"text-align:left;"
>
@
foreach
(
$median
as
$time
=>
$value
)
<
li
><
h4
>
Mittelwert
der
letzten
{{
$time
}}
Tage
:
<
span
class
=
"text-danger"
>
{{
number_format
(
$value
,
0
,
","
,
"."
)
}}
</
span
>
Abfragen
pro
Tag
</
h4
></
li
>
<
table
class
=
"table table-striped"
>
<
caption
>
Daten
der
letzten
Tage
</
caption
>
<
tr
>
<
th
>
Datum
</
th
>
<
th
>
Suchanfragen
zur
gleichen
Zeit
</
th
>
<
th
>
Suchanfragen
insgesamt
</
th
>
<
th
>
Mittelwert
</
th
>
</
tr
>
@
if
(
isset
(
$today
)
)
<
tr
>
<
td
>
{{
date
(
DATE_RFC822
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
),
date
(
"Y"
)))
}}
</
td
>
<
td
>
{{
$today
}}
</
td
>
<
td
>???</
td
>
<
td
>???</
td
>
</
tr
>
@
endif
@
foreach
(
$oldLogs
as
$key
=>
$value
)
<
tr
>
<
td
>
{{
date
(
DATE_RFC822
,
mktime
(
date
(
"H"
),
date
(
"i"
),
date
(
"s"
),
date
(
"m"
),
date
(
"d"
)
-
$key
,
date
(
"Y"
)))
}}
</
td
>
<
td
>
{{
$value
[
'sameTime'
]
}}
</
td
>
<
td
>
{{
$value
[
'insgesamt'
]
}}
</
td
>
<
td
>
{{
$value
[
'median'
]
}}
</
td
>
</
tr
>
@
endforeach
</
ul
>
</
table
>
@
if
(
isset
(
$rekordDate
)
&&
isset
(
$rekordTagSameTime
)
&&
isset
(
$rekordCount
)
)
<
h3
>
Rekord
am
{{
$rekordDate
}}
zur
gleichen
Zeit
<
span
class
=
"text-info"
>
{{
$rekordTagSameTime
}}
</
span
>
-
insgesamt
<
span
class
=
"text-danger"
>
{{
$rekordCount
}}
</
span
></
h3
>
@
endif
@
endsection
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment