Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
XDG Integration
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Silent mode is enabled
All outbound communications are blocked.
Learn more
.
Show more breadcrumbs
JennaHuntsman
XDG Integration
Commits
61ab9821
Commit
61ab9821
authored
4 years ago
by
Brad Payne (Vir Linden)
Browse files
Options
Downloads
Patches
Plain Diff
SL-15031 - ViewerStats analysis script
parent
026f4c60
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/metrics/viewerstats.py
+92
-0
92 additions, 0 deletions
scripts/metrics/viewerstats.py
with
92 additions
and
0 deletions
scripts/metrics/viewerstats.py
0 → 100644
+
92
−
0
View file @
61ab9821
#!runpy.sh
"""
\
This module contains code for analyzing ViewerStats data as uploaded by the viewer.
$LicenseInfo:firstyear=2021&license=viewerlgpl$
Second Life Viewer Source Code
Copyright (C) 2021, Linden Research, Inc.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation;
version 2.1 of the License only.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
$/LicenseInfo$
"""
import
argparse
import
numpy
as
np
import
pandas
as
pd
import
json
from
collections
import
Counter
,
defaultdict
def
show_stats_by_key
(
recs
,
indices
):
cnt
=
Counter
()
per_key_cnt
=
defaultdict
(
Counter
)
for
r
in
recs
:
try
:
d
=
r
for
idx
in
indices
:
d
=
d
[
idx
]
for
k
,
v
in
d
.
items
():
if
isinstance
(
v
,
dict
):
continue
cnt
[
k
]
+=
1
if
isinstance
(
v
,
list
):
v
=
tuple
(
v
)
per_key_cnt
[
k
][
v
]
+=
1
except
Exception
as
e
:
print
"
err
"
,
e
print
"
d
"
,
d
,
"
k
"
,
k
,
"
v
"
,
v
raise
mc
=
cnt
.
most_common
(
100
)
print
"
=========================
"
keyprefix
=
""
if
len
(
indices
)
>
0
:
keyprefix
=
"
.
"
.
join
(
indices
)
+
"
.
"
for
i
,
m
in
enumerate
(
mc
):
k
=
m
[
0
]
bigc
=
m
[
1
]
kmc
=
per_key_cnt
[
k
].
most_common
(
5
)
print
i
,
keyprefix
+
str
(
k
),
bigc
for
v
in
kmc
:
print
"
"
,
"
value
"
,
v
[
0
],
"
count
"
,
v
[
1
]
if
__name__
==
"
__main__
"
:
parser
=
argparse
.
ArgumentParser
(
description
=
"
process tab-separated table containing viewerstats logs
"
)
parser
.
add_argument
(
"
--verbose
"
,
action
=
"
store_true
"
,
help
=
"
verbose flag
"
)
parser
.
add_argument
(
"
--preferences
"
,
action
=
"
store_true
"
,
help
=
"
analyze preference info
"
)
parser
.
add_argument
(
"
--column
"
,
help
=
"
name of column containing viewerstats info
"
)
parser
.
add_argument
(
"
infiles
"
,
nargs
=
"
+
"
,
help
=
"
name of .tsv files to process
"
)
args
=
parser
.
parse_args
()
for
fname
in
args
.
infiles
:
print
"
process
"
,
fname
df
=
pd
.
read_csv
(
fname
,
sep
=
'
\t
'
)
#print "DF", df.describe()
jstrs
=
df
[
'
RAW_LOG:BODY
'
]
#print "JSTRS", jstrs.describe()
recs
=
[]
for
i
,
jstr
in
enumerate
(
jstrs
):
recs
.
append
(
json
.
loads
(
jstr
))
show_stats_by_key
(
recs
,[])
show_stats_by_key
(
recs
,[
"
agent
"
])
if
args
.
preferences
:
show_stats_by_key
(
recs
,[
"
preferences
"
,
"
settings
"
])
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