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
d5cb939a
authored
Jun 24, 2014
by
Kálmán Viktor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monitor: instances per template
parent
392f026e
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
2 deletions
+27
-2
circle/manager/mancelery.py
+7
-1
circle/monitor/tasks/local_periodic_tasks.py
+20
-1
No files found.
circle/manager/mancelery.py
View file @
d5cb939a
...
...
@@ -79,7 +79,13 @@ celery.conf.update(
},
'monitor.check_celery_queues'
:
{
'task'
:
'monitor.tasks.local_periodic_tasks.'
'check_celeries'
,
'check_celery_queues'
,
'schedule'
:
timedelta
(
seconds
=
5
),
'options'
:
{
'queue'
:
'localhost.man'
}
},
'monitor.instance_per_template'
:
{
'task'
:
'monitor.tasks.local_periodic_tasks.'
'instance_per_template'
,
'schedule'
:
timedelta
(
seconds
=
5
),
'options'
:
{
'queue'
:
'localhost.man'
}
},
...
...
circle/monitor/tasks/local_periodic_tasks.py
View file @
d5cb939a
...
...
@@ -23,7 +23,7 @@ from django.conf import settings
from
manager.mancelery
import
celery
from
vm.tasks.vm_tasks
import
check_queue
from
vm.models
import
Node
from
vm.models
import
Node
,
InstanceTemplate
from
storage.models
import
DataStore
from
monitor.client
import
Client
...
...
@@ -68,3 +68,22 @@ def check_celery_queues():
"vm-"
+
s
,
is_queue_alive
,
time
()))
Client
()
.
send
(
metrics
)
@celery.task
(
ignore_result
=
True
)
def
instance_per_template
():
graphite_string
=
lambda
pk
,
state
,
val
,
time
:
(
"template.
%
d.instances.
%
s
%
d
%
s"
%
(
pk
,
state
,
val
,
time
)
)
metrics
=
[]
for
t
in
InstanceTemplate
.
objects
.
all
():
base
=
t
.
instance_set
.
filter
(
destroyed_at
=
None
)
running
=
base
.
filter
(
status
=
"RUNNING"
)
.
count
()
not_running
=
base
.
exclude
(
status
=
"RUNNING"
)
.
count
()
metrics
.
append
(
graphite_string
(
t
.
pk
,
"running"
,
running
,
time
()))
metrics
.
append
(
graphite_string
(
t
.
pk
,
"not_running"
,
not_running
,
time
()))
Client
()
.
send
(
metrics
)
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