Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
metrics-tasks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Legacy
gitolite
metrics-tasks
Commits
2136868c
Commit
2136868c
authored
10 years ago
by
Karsten Loesing
Browse files
Options
Downloads
Patches
Plain Diff
Fix calculate_2mo_avg (#9889).
parent
2f8696e1
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
task-9889/tshirt.py
+3
-13
3 additions, 13 deletions
task-9889/tshirt.py
with
3 additions
and
13 deletions
task-9889/tshirt.py
+
3
−
13
View file @
2136868c
...
...
@@ -98,18 +98,8 @@ def calculate_2mo_avg(response, response_type):
if
data
[
'
values
'
][
i
]
not
in
[
None
,
'
null
'
]:
_sum
+=
(
data
[
'
values
'
][
i
])
count
+=
1
# Find number of values between last and today
time_interval
=
int
((
today
-
last
).
total_seconds
())
last_today_values
=
time_interval
/
data
[
'
interval
'
]
# Calculate the result
if
response_type
==
'
uptime
'
:
total_up_time
=
_sum
*
data
[
'
factor
'
]
*
data
[
'
interval
'
]
uptime_percent
=
round
(
total_up_time
*
100
/
TWO_MONTHS
,
2
)
return
uptime_percent
elif
response_type
==
'
bandwidth
'
:
total_values
=
count
+
last_today_values
result
=
(
_sum
*
data
[
'
factor
'
])
/
total_values
return
round
(
result
/
1000.0
,
2
)
return
(
_sum
*
data
[
'
factor
'
])
/
count
def
check_in_ports
(
ports
):
...
...
@@ -139,13 +129,13 @@ def check_exit_port(response):
def
get_uptime_percent
(
response
):
"""
Calculates the relay
'
s uptime from onionoo
'
s uptime document
"""
return
calculate_2mo_avg
(
response
,
'
uptime
'
)
return
round
(
calculate_2mo_avg
(
response
,
'
uptime
'
)
*
100
,
2
)
def
get_avg_bandwidth
(
response
):
"""
Calculates average bandwidth of traffic through the relay
"""
return
calculate_2mo_avg
(
response
,
'
bandwidth
'
)
return
round
(
calculate_2mo_avg
(
response
,
'
bandwidth
'
)
/
1000.0
,
2
)
def
check_tshirt
(
search_query
):
...
...
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