Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
Show 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):
...
@@ -199,29 +199,30 @@ class Node(TimeStampedModel):
return
default
return
default
def
get_monitor_info
(
self
):
def
get_monitor_info
(
self
):
collected
=
{}
try
:
try
:
handler
=
GraphiteHandler
()
handler
=
GraphiteHandler
()
except
:
except
RuntimeError
:
response
=
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
30
)
return
self
.
remote_query
(
vm_tasks
.
get_node_metrics
,
30
)
collected
[
'cpu.usage'
]
=
response
[
'cpu.usage'
]
collected
[
'memory.usage'
]
=
response
[
'memory.usage'
]
return
collected
query
=
Query
()
query
=
Query
()
query
.
set_target
(
self
.
host
.
hostname
+
".circle"
)
query
.
set_target
(
self
.
host
.
hostname
+
".circle"
)
query
.
set_format
(
"json"
)
query
.
set_format
(
"json"
)
query
.
set_relative_start
(
5
,
"minutes"
)
query
.
set_relative_start
(
5
,
"minutes"
)
metrics
=
[
"cpu.usage"
,
"memory.usage"
]
metrics
=
[
"cpu.usage"
,
"memory.usage"
]
collected
=
{}
for
metric
in
metrics
:
for
metric
in
metrics
:
query
.
set_metric
(
metric
)
query
.
set_metric
(
metric
)
query
.
generate
()
query
.
generate
()
handler
.
put
(
query
)
handler
.
put
(
query
)
handler
.
send
()
handler
.
send
()
collected
=
{}
for
metric
in
metrics
:
for
metric
in
metrics
:
response
=
handler
.
pop
()
response
=
handler
.
pop
()
length
=
len
(
response
[
0
][
"datapoints"
])
try
:
cache
=
response
[
0
][
"datapoints"
][
length
-
1
][
0
]
cache
=
response
[
0
][
"datapoints"
][
-
1
][
0
]
except
(
IndexError
,
KeyError
):
cache
=
0
if
cache
is
None
:
if
cache
is
None
:
cache
=
0
cache
=
0
collected
[
metric
]
=
cache
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