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
113c28e4
authored
Sep 17, 2014
by
Bach Dániel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: add allocated_memory() task
parent
c3c52c3c
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
29 additions
and
4 deletions
+29
-4
circle/manager/moncelery.py
+6
-0
circle/manager/scheduler.py
+1
-3
circle/monitor/tasks/local_periodic_tasks.py
+16
-0
circle/vm/models/node.py
+6
-1
No files found.
circle/manager/moncelery.py
View file @
113c28e4
...
...
@@ -61,6 +61,12 @@ celery.conf.update(
'schedule'
:
timedelta
(
seconds
=
30
),
'options'
:
{
'queue'
:
'localhost.monitor'
}
},
'monitor.allocated_memory'
:
{
'task'
:
'monitor.tasks.local_periodic_tasks.'
'allocated_memory'
,
'schedule'
:
timedelta
(
seconds
=
30
),
'options'
:
{
'queue'
:
'localhost.monitor'
}
},
}
)
circle/manager/scheduler.py
View file @
113c28e4
...
...
@@ -17,7 +17,6 @@
from
logging
import
getLogger
from
django.db.models
import
Sum
from
django.utils.translation
import
ugettext_noop
from
common.models
import
HumanReadableException
...
...
@@ -95,8 +94,7 @@ def has_enough_ram(ram_size, node):
unused
=
total
-
used
overcommit
=
node
.
ram_size_with_overcommit
reserved
=
(
node
.
instance_set
.
aggregate
(
r
=
Sum
(
'ram_size'
))[
'r'
]
or
0
)
*
1024
*
1024
reserved
=
node
.
allocated_ram
free
=
overcommit
-
reserved
retval
=
ram_size
<
unused
and
ram_size
<
free
...
...
circle/monitor/tasks/local_periodic_tasks.py
View file @
113c28e4
...
...
@@ -107,3 +107,19 @@ def instance_per_template():
time
()))
Client
()
.
send
(
metrics
)
@celery.task
(
ignore_result
=
True
)
def
allocated_memory
():
graphite_string
=
lambda
hostname
,
val
,
time
:
(
"circle.
%
s.memory.allocated
%
d
%
s"
%
(
hostname
,
val
,
time
)
)
metrics
=
[]
for
n
in
Node
.
objects
.
all
():
print
n
.
allocated_ram
metrics
.
append
(
graphite_string
(
n
.
host
.
hostname
,
n
.
allocated_ram
,
time
()))
Client
()
.
send
(
metrics
)
circle/vm/models/node.py
View file @
113c28e4
...
...
@@ -24,7 +24,7 @@ import requests
from
django.conf
import
settings
from
django.db.models
import
(
CharField
,
IntegerField
,
ForeignKey
,
BooleanField
,
ManyToManyField
,
FloatField
,
permalink
,
FloatField
,
permalink
,
Sum
)
from
django.utils
import
timezone
from
django.utils.translation
import
ugettext_lazy
as
_
,
ugettext_noop
...
...
@@ -116,6 +116,11 @@ class Node(OperatedMixin, TimeStampedModel):
info
=
property
(
get_info
)
@property
def
allocated_ram
(
self
):
return
(
self
.
instance_set
.
aggregate
(
r
=
Sum
(
'ram_size'
))[
'r'
]
or
0
)
*
1024
*
1024
@property
def
ram_size
(
self
):
warn
(
'Use Node.info["ram_size"]'
,
DeprecationWarning
)
return
self
.
info
[
'ram_size'
]
...
...
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