Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
apachedex
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Pelletier
apachedex
Commits
e07b1f25
Commit
e07b1f25
authored
Nov 04, 2020
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support %{ms}T for duration in milliseconds
Since 2.4.13, httpd suports %{UNIT}T in LogFormat
parent
86913b29
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
apachedex/__init__.py
apachedex/__init__.py
+5
-0
apachedex/tests.py
apachedex/tests.py
+39
-0
No files found.
apachedex/__init__.py
View file @
e07b1f25
...
@@ -114,6 +114,7 @@ INPUT_ENCODING_ERROR_HANDLER = 'replace'
...
@@ -114,6 +114,7 @@ INPUT_ENCODING_ERROR_HANDLER = 'replace'
MONTH_VALUE_DICT
=
dict
((
y
,
x
)
for
(
x
,
y
)
in
enumerate
((
'Jan'
,
'Feb'
,
'Mar'
,
MONTH_VALUE_DICT
=
dict
((
y
,
x
)
for
(
x
,
y
)
in
enumerate
((
'Jan'
,
'Feb'
,
'Mar'
,
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
),
1
))
'Apr'
,
'May'
,
'Jun'
,
'Jul'
,
'Aug'
,
'Sep'
,
'Oct'
,
'Nov'
,
'Dec'
),
1
))
MS_PER_S
=
10
**
3
US_PER_S
=
10
**
6
US_PER_S
=
10
**
6
N_HOTTEST_PAGES_DEFAULT
=
20
N_HOTTEST_PAGES_DEFAULT
=
20
...
@@ -806,6 +807,7 @@ class ERP5SiteStats(GenericSiteStats):
...
@@ -806,6 +807,7 @@ class ERP5SiteStats(GenericSiteStats):
attribute
[
value_date
].
accumulateFrom
(
apdex
)
attribute
[
value_date
].
accumulateFrom
(
apdex
)
DURATION_US_FORMAT
=
'%D'
DURATION_US_FORMAT
=
'%D'
DURATION_MS_FORMAT
=
'%{ms}T'
DURATION_S_FORMAT
=
'%T'
DURATION_S_FORMAT
=
'%T'
server_name_group_dict
=
{
server_name_group_dict
=
{
...
@@ -826,6 +828,7 @@ logformat_dict = {
...
@@ -826,6 +828,7 @@ logformat_dict = {
'%{REMOTE_USER}i'
:
r'(?P<remote_user>[^"]*)'
,
# XXX: expected to be enclosed in "
'%{REMOTE_USER}i'
:
r'(?P<remote_user>[^"]*)'
,
# XXX: expected to be enclosed in "
'%{User-Agent}i'
:
r'(?P<agent>[^"]*)'
,
# XXX: expected to be enclosed in "
'%{User-Agent}i'
:
r'(?P<agent>[^"]*)'
,
# XXX: expected to be enclosed in "
DURATION_US_FORMAT
:
r'(?P<duration>[0-9]*)'
,
DURATION_US_FORMAT
:
r'(?P<duration>[0-9]*)'
,
DURATION_MS_FORMAT
:
r'(?P<duration_ms>[0-9]*)'
,
DURATION_S_FORMAT
:
r'(?P<duration_s>[0-9]*)'
,
DURATION_S_FORMAT
:
r'(?P<duration_s>[0-9]*)'
,
'%%'
:
r'%'
,
'%%'
:
r'%'
,
'%v'
:
r'(?P<servername>[^ ]*)'
,
'%v'
:
r'(?P<servername>[^ ]*)'
,
...
@@ -1369,6 +1372,8 @@ def main():
...
@@ -1369,6 +1372,8 @@ def main():
'must be specified.'
)
'must be specified.'
)
if
DURATION_US_FORMAT
in
args
.
logformat
:
if
DURATION_US_FORMAT
in
args
.
logformat
:
getDuration
=
lambda
x
:
int
(
x
.
group
(
'duration'
))
getDuration
=
lambda
x
:
int
(
x
.
group
(
'duration'
))
elif
DURATION_MS_FORMAT
in
args
.
logformat
:
getDuration
=
lambda
x
:
int
(
x
.
group
(
'duration_ms'
))
*
MS_PER_S
elif
DURATION_S_FORMAT
in
args
.
logformat
:
elif
DURATION_S_FORMAT
in
args
.
logformat
:
getDuration
=
lambda
x
:
int
(
x
.
group
(
'duration_s'
))
*
US_PER_S
getDuration
=
lambda
x
:
int
(
x
.
group
(
'duration_s'
))
*
US_PER_S
else
:
else
:
...
...
apachedex/tests.py
View file @
e07b1f25
...
@@ -100,3 +100,42 @@ else:
...
@@ -100,3 +100,42 @@ else:
class
TestLzmaEncoding
(
ApacheDEXTestCase
):
class
TestLzmaEncoding
(
ApacheDEXTestCase
):
def
test
(
self
):
def
test
(
self
):
self
.
skipTest
(
"lzma not available"
)
self
.
skipTest
(
"lzma not available"
)
class
TestTimeEnconding
(
ApacheDEXTestCase
):
def
test_seconds_timing
(
self
):
with
tempfile
.
NamedTemporaryFile
()
as
fout
:
sys
.
argv
=
[
'apachedex'
,
'--base=/'
,
'-'
,
'--logformat'
,
'%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %T'
,
'-f'
,
'json'
,
'-o'
,
fout
.
name
]
sys
.
stdin
=
StringIO
(
'''127.0.0.1 - - [14/Jul/2017:09:41:41 +0200] "GET / HTTP/1.1" 200 7499 "https://example.org/" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" 1'''
)
apachedex
.
main
()
fout
.
seek
(
0
)
state
=
json
.
load
(
fout
)
self
.
assertEqual
(
state
[
0
][
1
][
'apdex'
][
'2017/07/14 09:41'
][
'duration_max'
],
1000000
)
def
test_milliseconds_timing
(
self
):
with
tempfile
.
NamedTemporaryFile
()
as
fout
:
sys
.
argv
=
[
'apachedex'
,
'--base=/'
,
'-'
,
'--logformat'
,
'%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %D'
,
'-f'
,
'json'
,
'-o'
,
fout
.
name
]
sys
.
stdin
=
StringIO
(
'''127.0.0.1 - - [14/Jul/2017:09:41:41 +0200] "GET / HTTP/1.1" 200 7499 "https://example.org/" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" 1000000'''
)
apachedex
.
main
()
fout
.
seek
(
0
)
state
=
json
.
load
(
fout
)
self
.
assertEqual
(
state
[
0
][
1
][
'apdex'
][
'2017/07/14 09:41'
][
'duration_max'
],
1000000
)
def
test_microseconds_timing
(
self
):
with
tempfile
.
NamedTemporaryFile
()
as
fout
:
sys
.
argv
=
[
'apachedex'
,
'--base=/'
,
'-'
,
'--logformat'
,
'%h %l %u %t "%r" %>s %O "%{Referer}i" "%{User-Agent}i" %{ms}T'
,
'-f'
,
'json'
,
'-o'
,
fout
.
name
]
sys
.
stdin
=
StringIO
(
'''127.0.0.1 - - [14/Jul/2017:09:41:41 +0200] "GET / HTTP/1.1" 200 7499 "https://example.org/" "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36" 1000
'''
)
apachedex
.
main
()
fout
.
seek
(
0
)
state
=
json
.
load
(
fout
)
self
.
assertEqual
(
state
[
0
][
1
][
'apdex'
][
'2017/07/14 09:41'
][
'duration_max'
],
1000000
)
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