Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gutyán Gábor
/
circlestack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b5d5bf17
authored
Mar 13, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
vm: add exception handling to get_monitor_info()
parent
f2794a01
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
circle/vm/models/node.py
+10
-9
No files found.
circle/vm/models/node.py
View file @
b5d5bf17
...
...
@@ -199,29 +199,30 @@ class Node(TimeStampedModel):
return
default
def
get_monitor_info
(
self
):
collected
=
{}
try
:
handler
=
GraphiteHandler
()
except
:
response
=
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
30
)
collected
[
'cpu.usage'
]
=
response
[
'cpu.usage'
]
collected
[
'memory.usage'
]
=
response
[
'memory.usage'
]
return
collected
except
RuntimeError
:
return
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
30
)
query
=
Query
()
query
.
set_target
(
self
.
host
.
hostname
+
".circle"
)
query
.
set_format
(
"json"
)
query
.
set_relative_start
(
5
,
"minutes"
)
metrics
=
[
"cpu.usage"
,
"memory.usage"
]
collected
=
{}
for
metric
in
metrics
:
query
.
set_metric
(
metric
)
query
.
generate
()
handler
.
put
(
query
)
handler
.
send
()
collected
=
{}
for
metric
in
metrics
:
response
=
handler
.
pop
()
length
=
len
(
response
[
0
][
"datapoints"
])
cache
=
response
[
0
][
"datapoints"
][
length
-
1
][
0
]
try
:
cache
=
response
[
0
][
"datapoints"
][
-
1
][
0
]
except
(
IndexError
,
KeyError
):
cache
=
0
if
cache
is
None
:
cache
=
0
collected
[
metric
]
=
cache
...
...
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