Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
engine
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
Container registry
Model registry
Operate
Environments
Monitor
Incidents
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
Show more breadcrumbs
AURA
engine
Commits
045e8d86
Commit
045e8d86
authored
4 years ago
by
David Trattnig
Browse files
Options
Downloads
Patches
Plain Diff
Extend monitoring.
parent
57317de7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/core/monitor.py
+24
-10
24 additions, 10 deletions
modules/core/monitor.py
with
24 additions
and
10 deletions
modules/core/monitor.py
+
24
−
10
View file @
045e8d86
...
@@ -21,11 +21,19 @@ import urllib
...
@@ -21,11 +21,19 @@ import urllib
import
logging
import
logging
import
json
import
json
import
os.path
import
os.path
from
os
import
path
from
os
import
path
from
enum
import
Enum
from
modules.communication.redis.adapter
import
ClientRedisAdapter
from
modules.communication.redis.adapter
import
ClientRedisAdapter
class
MonitorResponseCode
(
Enum
):
OK
=
"
OK
"
INVALID_STATE
=
"
INVALID-STATE
"
class
Monitoring
:
class
Monitoring
:
"""
"""
Engine Monitoring
Engine Monitoring
...
@@ -47,7 +55,7 @@ class Monitoring:
...
@@ -47,7 +55,7 @@ class Monitoring:
self
.
status
[
"
api
"
]
=
dict
()
self
.
status
[
"
api
"
]
=
dict
()
self
.
status
[
"
api
"
][
"
steering
"
]
=
dict
()
self
.
status
[
"
api
"
][
"
steering
"
]
=
dict
()
self
.
status
[
"
api
"
][
"
tank
"
]
=
dict
()
self
.
status
[
"
api
"
][
"
tank
"
]
=
dict
()
self
.
status
[
"
api
"
][
"
engine
"
]
=
dict
()
def
update_status
(
self
):
def
update_status
(
self
):
...
@@ -63,18 +71,24 @@ class Monitoring:
...
@@ -63,18 +71,24 @@ class Monitoring:
#self.status["soundsystem"]["recorder"] = self.soundsystem.get_recorder_status()
#self.status["soundsystem"]["recorder"] = self.soundsystem.get_recorder_status()
self
.
soundsystem
.
disable_transaction
(
self
.
soundsystem
.
client
)
self
.
soundsystem
.
disable_transaction
(
self
.
soundsystem
.
client
)
self
.
status
[
"
api
"
][
"
steering
"
][
"
url
"
]
=
self
.
config
.
get
(
"
api_steering_status
"
)
self
.
status
[
"
api
"
][
"
steering
"
][
"
available
"
]
=
self
.
validate_url_connection
(
self
.
config
.
get
(
"
api_steering_status
"
))
self
.
status
[
"
api
"
][
"
steering
"
][
"
available
"
]
=
self
.
validate_url_connection
(
self
.
config
.
get
(
"
api_steering_status
"
))
self
.
status
[
"
api
"
][
"
tank
"
][
"
available
"
]
=
self
.
validate_url_connection
(
self
.
config
.
get
(
"
api_tank_status
"
))
self
.
status
[
"
api
"
][
"
tank
"
][
"
status
"
]
=
self
.
get_url_response
(
self
.
config
.
get
(
"
api_tank_status
"
))
self
.
status
[
"
redis_ready
"
]
=
self
.
validate_redis_connection
()
self
.
status
[
"
api
"
][
"
tank
"
][
"
url
"
]
=
self
.
config
.
get
(
"
api_tank_status
"
)
self
.
status
[
"
audio_store
"
]
=
self
.
validate_directory
(
self
.
config
.
get
(
"
audiofolder
"
))
self
.
status
[
"
api
"
][
"
tank
"
][
"
available
"
]
=
self
.
validate_url_connection
(
self
.
config
.
get
(
"
api_tank_status
"
))
self
.
status
[
"
api
"
][
"
tank
"
][
"
status
"
]
=
self
.
get_url_response
(
self
.
config
.
get
(
"
api_tank_status
"
))
self
.
status
[
"
api
"
][
"
engine
"
][
"
url
"
]
=
self
.
config
.
get
(
"
exposed_api_url
"
)
self
.
status
[
"
api
"
][
"
engine
"
][
"
available
"
]
=
self
.
validate_url_connection
(
self
.
config
.
get
(
"
exposed_api_url
"
))
self
.
status
[
"
redis_ready
"
]
=
self
.
validate_redis_connection
()
self
.
status
[
"
audio_store
"
]
=
self
.
validate_directory
(
self
.
config
.
get
(
"
audiofolder
"
))
# Set overall status
# Set overall status
if
self
.
has_valid_status
():
if
self
.
has_valid_status
():
self
.
status
[
"
engine_status
"
]
=
"
OK
"
self
.
status
[
"
engine_status
"
]
=
MonitorResponseCode
.
OK
.
value
else
:
else
:
self
.
status
[
"
engine_status
"
]
=
"
INVALID
"
self
.
status
[
"
engine_status
"
]
=
MonitorResponseCode
.
INVALID_STATE
.
value
...
@@ -90,7 +104,7 @@ class Monitoring:
...
@@ -90,7 +104,7 @@ class Monitoring:
return
ios
return
ios
except
Exception
as
e
:
except
Exception
as
e
:
self
.
logger
.
warn
(
"
Got invalid JSON from soundsystem -
"
+
str
(
e
))
self
.
logger
.
warn
(
"
Got invalid JSON from soundsystem -
"
+
str
(
e
))
return
"
[ERROR]
"
return
MonitorResponseCode
.
INVALID_STATE
.
value
...
@@ -179,8 +193,8 @@ class Monitoring:
...
@@ -179,8 +193,8 @@ class Monitoring:
request
=
urllib
.
request
.
Request
(
url
)
request
=
urllib
.
request
.
Request
(
url
)
response
=
urllib
.
request
.
urlopen
(
request
)
response
=
urllib
.
request
.
urlopen
(
request
)
data
=
response
.
read
()
data
=
response
.
read
()
return
json
.
loads
(
data
,
strict
=
False
)
except
(
urllib
.
error
.
URLError
,
IOError
,
ValueError
)
as
e
:
except
(
urllib
.
error
.
URLError
,
IOError
,
ValueError
)
as
e
:
self
.
logger
.
error
(
"
Error while connecting to URL
'
%s
'
- %s
"
%
(
url
,
e
))
self
.
logger
.
error
(
"
Error while connecting to URL
'
%s
'
- %s
"
%
(
url
,
e
))
return
json
.
loads
(
data
,
strict
=
False
)
return
MonitorResponseCode
.
INVALID_STATE
.
value
\ No newline at end of file
\ No newline at end of file
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