Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
monitor-client
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d6655c03
authored
Feb 17, 2014
by
Gregory Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cpuTimes added and syncronization added with celerymonitor
parent
101f5a4b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
19 deletions
+23
-19
config/client.conf
+1
-0
src/client.py
+11
-16
src/cnfparse.py
+1
-0
src/metrics.py
+10
-3
No files found.
config/client.conf
View file @
d6655c03
...
...
@@ -3,6 +3,7 @@ Debug = True
[
Metrics
]
cpuUsage
=
5
cpuTimes
=
5
memoryUsage
=
5
userCount
=
60
swapUsage
=
30
...
...
src/client.py
View file @
d6655c03
...
...
@@ -176,26 +176,21 @@ class Client:
except
IndexError
:
pass
if
((
self
.
beat
%
30
)
is
0
):
metrics
.
append
((
self
.
name
+
"."
+
"vmcount"
+
"
%
d"
%
len
(
running_vms
)
+
"
%
d"
%
(
time
.
time
())
))
metrics
.
append
(
"
%
s.vmcount
%
d
%
d"
%
(
self
.
name
,
len
(
running_vms
),
time
.
time
()))
for
vm
in
running_vms
:
vm_proc
=
psutil
.
Process
(
vm
[
1
])
if
((
self
.
beat
%
self
.
kvmCPU
)
is
0
)
and
vm_proc
.
is_running
():
metrics
.
append
((
"vm."
+
vm
[
0
]
+
"."
+
"memory.usage"
+
"
%
f"
%
(
vm_proc
.
get_memory_percent
()
/
100
*
vm
[
2
])
+
"
%
d"
%
(
time
.
time
())
))
metrics
.
append
(
"vm.
%
s.memory.usage
%
f
%
d"
%
(
vm
[
0
],
vm_proc
.
get_memory_percent
()
/
100
*
vm
[
2
]),
time
.
time
())
if
((
self
.
beat
%
self
.
kvmMem
)
is
0
)
and
vm_proc
.
is_running
():
metrics
.
append
((
"vm."
+
vm
[
0
]
+
"."
+
"cpu.usage"
+
"
%
f"
%
(
vm_proc
.
get_cpu_times
()
.
system
+
vm_proc
.
get_cpu_times
()
.
user
)
+
"
%
d"
%
(
time
.
time
())
))
systemtime
=
vm_proc
.
get_cpu_times
()
.
system
usertime
=
vm_proc
.
get_cpu_times
()
.
user
sumCpu
=
systemtime
+
usertime
metrics
.
append
(
"vm.
%
s.cpu.usage
%
f
%
d"
%
(
sumCpu
,
time
.
time
()))
interfaces_list
=
psutil
.
network_io_counters
(
pernic
=
True
)
if
((
self
.
beat
%
self
.
kvmNet
)
is
0
):
...
...
src/cnfparse.py
View file @
d6655c03
...
...
@@ -9,6 +9,7 @@ def importConf(path_to_file):
metrics
=
{}
params
[
"debugMode"
]
=
config
.
get
(
"Client"
,
"Debug"
)
metrics
[
"cpu.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuUsage"
))
metrics
[
"cpu.times"
]
=
int
(
config
.
get
(
"Metrics"
,
"cpuTimes"
))
metrics
[
"memory.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"memoryUsage"
))
metrics
[
"user.count"
]
=
int
(
config
.
get
(
"Metrics"
,
"userCount"
))
metrics
[
"swap.usage"
]
=
int
(
config
.
get
(
"Metrics"
,
"swapUsage"
))
...
...
src/metrics.py
View file @
d6655c03
...
...
@@ -37,12 +37,19 @@ class Collection(object):
class
std
(
Collection
):
class
cpu
(
Collection
.
Group
):
class
usage
(
Collection
.
Group
.
Metric
):
name
=
"cpu.usage"
collector_function
=
ps
.
cpu_percent
collector_function_arguments
=
{
'interval'
:
0.0
}
class
times
(
Collection
.
Group
.
Metric
):
name
=
"cpu.times"
@classmethod
def
harvest
(
cls
):
return
Metrics
(
cls
.
name
,
ps
.
cpu_times
()
.
user
+
ps
.
cpu_times
()
.
system
)
class
memory
(
Collection
.
Group
):
class
usage
(
Collection
.
Group
.
Metric
):
name
=
"memory.usage"
...
...
@@ -65,12 +72,12 @@ class std(Collection):
class
network
(
Collection
.
Group
):
class
packages_sent
(
Collection
.
Group
.
Metric
):
name
=
"network.pack
age
s_sent"
name
=
"network.pack
et
s_sent"
collector_function
=
ps
.
network_io_counters
collector_function_result_attr
=
"packets_sent"
class
packages_received
(
Collection
.
Group
.
Metric
):
name
=
"network.pack
ages_received
"
name
=
"network.pack
ets_recv
"
collector_function
=
ps
.
network_io_counters
collector_function_result_attr
=
"packets_recv"
...
...
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