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
14997630
authored
Feb 05, 2014
by
Gregory Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug fixed: exception when process lost and network usage metrics
parent
6a0882f6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
36 deletions
+40
-36
src/client.py
+40
-36
No files found.
src/client.py
View file @
14997630
...
@@ -152,7 +152,11 @@ class Client:
...
@@ -152,7 +152,11 @@ class Client:
running_vms
=
[]
running_vms
=
[]
procList
=
psutil
.
get_process_list
()
procList
=
psutil
.
get_process_list
()
for
entry
in
procList
:
for
entry
in
procList
:
if
entry
.
name
in
"kvm"
:
try
:
entry_name
=
entry
.
name
except
psutil
.
_error
.
NoSuchProcess
:
entry_name
=
""
if
entry_name
in
"kvm"
:
cmdLine
=
entry
.
as_dict
()[
"cmdline"
]
cmdLine
=
entry
.
as_dict
()[
"cmdline"
]
search
=
[
cmd_param_index
for
cmd_param_index
,
cmd_param
in
search
=
[
cmd_param_index
for
cmd_param_index
,
cmd_param
in
enumerate
(
cmdLine
)
enumerate
(
cmdLine
)
...
@@ -192,41 +196,41 @@ class Client:
...
@@ -192,41 +196,41 @@ class Client:
vm_proc
.
get_cpu_times
()
.
user
)
vm_proc
.
get_cpu_times
()
.
user
)
+
"
%
d"
%
(
time
.
time
())
+
"
%
d"
%
(
time
.
time
())
))
))
interfaces_list
=
psutil
.
network_io_counters
(
interfaces_list
=
psutil
.
network_io_counters
(
pernic
=
True
)
pernic
=
True
)
interfaces_list_enum
=
enumerate
(
interfaces_list
)
interfaces_list_enum
=
enumerate
(
interfaces_list
)
if
((
self
.
beat
%
self
.
kvmNet
)
is
0
)
and
vm_proc
.
is_running
():
if
((
self
.
beat
%
self
.
kvmNet
)
is
0
)
and
vm_proc
.
is_running
():
for
vm
in
running_vms
:
for
vm
in
running_vms
:
for
iname_index
,
iname
in
interfaces_list_enum
:
for
iname_index
,
iname
in
interfaces_list_enum
:
if
vm
[
0
]
in
iname
:
if
vm
[
0
]
in
iname
:
metrics
.
append
((
"vm."
+
metrics
.
append
((
"vm."
+
vm
[
0
]
+
vm
[
0
]
+
"."
+
"network.packages_sent"
+
"."
+
"network.packages_sent"
+
"
%
d"
%
interfaces_list
[
"
%
d"
%
interfaces_list
[
iname
]
.
packets_sent
iname
]
.
packets_sent
+
"
%
d"
%
(
time
.
time
())
+
"
%
d"
%
(
time
.
time
())
))
))
metrics
.
append
((
"vm."
+
metrics
.
append
((
"vm."
+
vm
[
0
]
+
vm
[
0
]
+
"."
+
"network.packages_recv"
+
"."
+
"network.packages_recv"
+
"
%
d"
%
interfaces_list
[
"
%
d"
%
interfaces_list
[
iname
]
.
packets_recv
iname
]
.
packets_recv
+
"
%
d"
%
(
time
.
time
())
+
"
%
d"
%
(
time
.
time
())
))
))
metrics
.
append
((
"vm."
+
metrics
.
append
((
"vm."
+
vm
[
0
]
+
"."
+
"network"
vm
[
0
]
+
"."
+
"network"
".bytes_sent"
+
".bytes_sent"
+
"
%
d"
%
interfaces_list
[
"
%
d"
%
interfaces_list
[
iname
]
.
bytes_sent
iname
]
.
bytes_sent
+
"
%
d"
%
(
time
.
time
())
+
"
%
d"
%
(
time
.
time
())
))
))
metrics
.
append
((
"vm."
+
metrics
.
append
((
"vm."
+
vm
[
0
]
+
vm
[
0
]
+
+
"network.bytes_recv"
+
+
"network.bytes_recv"
+
"
%
d"
%
"
%
d"
%
(
interfaces_list
[
iname
]
.
bytes_recv
)
(
interfaces_list
[
iname
]
.
bytes_recv
)
+
"
%
d"
%
(
time
.
time
())
+
"
%
d"
%
(
time
.
time
())
))
))
return
metrics
return
metrics
def
getMaxFrequency
(
self
,
metricCollectors
=
[]):
def
getMaxFrequency
(
self
,
metricCollectors
=
[]):
...
...
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