Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
flame-clmc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
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
flame
flame-clmc
Commits
ea8ab9fe
Commit
ea8ab9fe
authored
6 years ago
by
Nikolay Stanchev
Browse files
Options
Downloads
Patches
Plain Diff
Slight update to logging in aggregator
parent
c40efc7d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/service/clmcservice/aggregator.py
+21
-18
21 additions, 18 deletions
src/service/clmcservice/aggregator.py
with
21 additions
and
18 deletions
src/service/clmcservice/aggregator.py
+
21
−
18
View file @
ea8ab9fe
...
...
@@ -32,14 +32,6 @@ import sys
import
logging
log
=
logging
.
getLogger
(
'
aggregator
'
)
hdlr
=
logging
.
FileHandler
(
'
/var/log/clmcservice/aggregator.log
'
,
mode
=
'
a
'
)
formatter
=
logging
.
Formatter
(
'
%(asctime)s %(levelname)s %(message)s
'
)
hdlr
.
setFormatter
(
formatter
)
log
.
addHandler
(
hdlr
)
log
.
setLevel
(
logging
.
INFO
)
class
Aggregator
(
object
):
"""
A class used to perform the aggregation feature of the CLMC - aggregating network and media service measurements. Implemented as a separate process.
...
...
@@ -49,7 +41,7 @@ class Aggregator(object):
DATABASE
=
'
CLMCMetrics
'
# default database the aggregator uses
DATABASE_URL
=
'
http://172.40.231.51:8086
'
# default database URL the aggregator uses
def
__init__
(
self
,
database_name
=
DATABASE
,
database_url
=
DATABASE_URL
,
report_period
=
REPORT_PERIOD
):
def
__init__
(
self
,
database_name
=
DATABASE
,
database_url
=
DATABASE_URL
,
report_period
=
REPORT_PERIOD
,
logger
=
None
):
"""
Constructs an Aggregator instance.
...
...
@@ -58,11 +50,16 @@ class Aggregator(object):
:param report_period: the report period in seconds
"""
log
.
info
(
"
Connecting to Influx database {0} with URL {1}
"
.
format
(
database_name
,
database_url
))
if
logger
is
None
:
self
.
log
=
logging
.
getLogger
(
'
aggregator
'
)
else
:
self
.
log
=
logger
self
.
log
.
info
(
"
Connecting to Influx database {0} with URL {1}
"
.
format
(
database_name
,
database_url
))
# initialise a database client using the database url and the database name
url_object
=
urlparse
(
database_url
)
self
.
db_client
=
InfluxDBClient
(
host
=
url_object
.
hostname
,
port
=
url_object
.
port
,
database
=
database_name
,
timeout
=
10
)
log
.
info
(
"
Successfully connected to Influx database {0} with URL {1}
"
.
format
(
database_name
,
database_url
))
self
.
log
.
info
(
"
Successfully connected to Influx database {0} with URL {1}
"
.
format
(
database_name
,
database_url
))
self
.
db_url
=
database_url
self
.
db_name
=
database_name
...
...
@@ -80,7 +77,7 @@ class Aggregator(object):
Stop the aggregator from running.
"""
log
.
info
(
"
Aggregator
'
s stop flag has been set.
"
)
self
.
log
.
info
(
"
Aggregator
'
s stop flag has been set.
"
)
self
.
_stop_flag
.
set
()
def
run
(
self
):
...
...
@@ -88,11 +85,11 @@ class Aggregator(object):
Performs the functionality of the aggregator - query data from both measurements merge that data and post it back in influx every 5 seconds.
"""
log
.
info
(
"
Aggregator started running.
"
)
self
.
log
.
info
(
"
Aggregator started running.
"
)
current_time
=
int
(
time
())
while
not
self
.
_stop_flag
.
is_set
():
log
.
info
(
"
Trying to generate an E2E measurement.
"
)
self
.
log
.
info
(
"
Trying to generate an E2E measurement.
"
)
boundary_time
=
current_time
-
self
.
report_period
...
...
@@ -171,9 +168,9 @@ class Aggregator(object):
e2e_arguments
[
'
delay_service
'
],
e2e_arguments
[
"
avg_request_size
"
],
e2e_arguments
[
'
avg_response_size
'
],
e2e_arguments
[
'
avg_bandwidth
'
],
e2e_arguments
[
'
time
'
]))
log
.
info
(
"
Successfully generated an E2E measurement and posted back to Influx.
"
)
self
.
log
.
info
(
"
Successfully generated an E2E measurement and posted back to Influx.
"
)
else
:
log
.
info
(
"
Couldn
'
t generate an E2E measurement although some of the data could be fetched.
"
)
self
.
log
.
info
(
"
Couldn
'
t generate an E2E measurement although some of the data could be fetched.
"
)
old_timestamp
=
current_time
# wait until {report_period) seconds have passed
...
...
@@ -181,10 +178,16 @@ class Aggregator(object):
sleep
(
1
)
current_time
=
int
(
time
())
log
.
info
(
"
Aggregator stopped running.
"
)
self
.
log
.
info
(
"
Aggregator stopped running.
"
)
if
__name__
==
'
__main__
'
:
log
=
logging
.
getLogger
(
'
aggregator
'
)
hdlr
=
logging
.
FileHandler
(
'
/var/log/clmcservice/aggregator.log
'
,
mode
=
'
a
'
)
formatter
=
logging
.
Formatter
(
'
%(asctime)s %(levelname)s %(message)s
'
)
hdlr
.
setFormatter
(
formatter
)
log
.
addHandler
(
hdlr
)
log
.
setLevel
(
logging
.
INFO
)
# Parse command line options
try
:
...
...
@@ -203,7 +206,7 @@ if __name__ == '__main__':
elif
opt
in
(
'
-u
'
,
'
--url
'
):
arg_database_url
=
arg
Aggregator
(
database_name
=
arg_database_name
,
database_url
=
arg_database_url
,
report_period
=
arg_period
).
run
()
Aggregator
(
database_name
=
arg_database_name
,
database_url
=
arg_database_url
,
report_period
=
arg_period
,
logger
=
log
).
run
()
# log.info the error messages in case of a parse error
except
getopt
.
GetoptError
as
err
:
...
...
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