Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
3cbde4d2
G
glances
项目概览
蜕变的菜鸟
/
glances
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
glances
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3cbde4d2
编写于
3月 22, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Correct a bug on the client/server mode for processes list
上级
803b4154
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
32 addition
and
62 deletion
+32
-62
glances/core/glances_client.py
glances/core/glances_client.py
+5
-4
glances/core/glances_processes.py
glances/core/glances_processes.py
+2
-2
glances/core/glances_server.py
glances/core/glances_server.py
+1
-18
glances/core/glances_stats.py
glances/core/glances_stats.py
+9
-23
glances/plugins/glances_diskio.py
glances/plugins/glances_diskio.py
+3
-3
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+1
-1
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+11
-11
未找到文件。
glances/core/glances_client.py
浏览文件 @
3cbde4d2
...
...
@@ -58,9 +58,9 @@ class GlancesClient():
# Try to connect to the URI
try
:
self
.
client
=
ServerProxy
(
uri
)
except
Exception
:
print
(
_
(
"Error: creating client socket"
)
+
" %s"
%
uri
)
pass
except
Exception
as
e
:
print
(
"{} {} ({})"
.
format
(
_
(
"Error: creating client socket"
),
uri
,
e
)
)
sys
.
exit
(
2
)
# Store the arg/config
self
.
args
=
args
...
...
@@ -82,6 +82,7 @@ class GlancesClient():
print
(
"{} ({})"
.
format
(
_
(
"Error: Connection to server failed"
),
err
))
sys
.
exit
(
2
)
# Test if client and server are "compatible"
if
(
__version__
[:
3
]
==
client_version
[:
3
]):
# Init stats and limits
self
.
stats
=
GlancesStatsClient
()
...
...
@@ -116,7 +117,7 @@ class GlancesClient():
def
serve_forever
(
self
):
"""
Main loop
Main
client
loop
"""
while
True
:
# Update the stats
...
...
glances/core/glances_processes.py
浏览文件 @
3cbde4d2
...
...
@@ -160,10 +160,10 @@ class glancesProcesses:
continue
# Update processcount (global statistics)
try
:
self
.
processcount
[
str
(
proc
.
status
)]
+=
1
self
.
processcount
[
str
(
proc
.
status
()
)]
+=
1
except
KeyError
:
# Key did not exist, create it
self
.
processcount
[
str
(
proc
.
status
)]
=
1
self
.
processcount
[
str
(
proc
.
status
()
)]
=
1
else
:
self
.
processcount
[
'total'
]
+=
1
# Update thread number (global statistics)
...
...
glances/core/glances_server.py
浏览文件 @
3cbde4d2
...
...
@@ -185,8 +185,7 @@ class GlancesInstance():
The goal is to dynamicaly generate the API get'Stats'() methods
"""
# print "!!! __getattr__ in the GlancesInstance classe"
# print "!!! Method: %s" % item
# print "DEBUG: Call method: %s" % item
header
=
'get'
# Check if the attribute starts with 'get'
if
(
item
.
startswith
(
header
)):
...
...
@@ -203,22 +202,6 @@ class GlancesInstance():
# Default behavior
raise
AttributeError
(
item
)
# !!! How to implement theses method in v2 ?
# def __getTimeSinceLastUpdate(self, IOType):
# assert(IOType in ['net', 'disk', 'process_disk'])
# return getTimeSinceLastUpdate(IOType)
# def getNetTimeSinceLastUpdate(self):
# return getTimeSinceLastUpdate('net')
# def getDiskTimeSinceLastUpdate(self):
# return getTimeSinceLastUpdate('net')
# def getProcessDiskTimeSinceLastUpdate(self):
# return getTimeSinceLastUpdate('process_disk')
class
GlancesServer
():
"""
This class creates and manages the TCP server
...
...
glances/core/glances_stats.py
浏览文件 @
3cbde4d2
...
...
@@ -113,14 +113,12 @@ class GlancesStats(object):
else
:
# For client mode
# Update plugin stats with items sent by the server
# print input_stats['processcount']
# sys.exit(2)
for
p
in
input_stats
:
# print "Set: %s" % p
# print "Input: %s" % input_stats[p]
# print "Plugins: %s" % self._plugins
self
.
_plugins
[
p
].
set_stats
(
input_stats
[
p
])
def
update
(
self
,
input_stats
=
{}):
# !!! Why __update__ and update method ?
# Update the stats
self
.
__update__
(
input_stats
)
...
...
@@ -137,6 +135,9 @@ class GlancesStats(object):
class
GlancesStatsServer
(
GlancesStats
):
"""
This class store, update and give stats for the server
"""
def
__init__
(
self
):
# Init the stats
...
...
@@ -172,15 +173,14 @@ class GlancesStatsServer(GlancesStats):
class
GlancesStatsClient
(
GlancesStats
):
"""
This class store, update and give stats for the client
"""
def
__init__
(
self
):
# Init the plugin list dict
self
.
_plugins
=
collections
.
defaultdict
(
dict
)
# Init the all_stats dict used by the server
# all_stats is a dict of dicts filled by the server
self
.
all_stats
=
collections
.
defaultdict
(
dict
)
def
set_plugins
(
self
,
input_plugins
):
"""
Set the plugin list accoring to the Glances' server
...
...
@@ -198,19 +198,5 @@ class GlancesStatsClient(GlancesStats):
# The key is the plugin name
# for example, the file glances_xxx.py
# generate self._plugins_list["xxx"] = ...
# print "DEBUG: Init %s plugin" % plug
self
.
_plugins
[
plug
]
=
m
.
Plugin
()
def
update
(
self
,
input_stats
=
{}):
"""
Update the stats
"""
# Update the stats
GlancesStats
.
__update__
(
self
,
input_stats
)
# Build the all_stats with the get_raw() method of the plugins
for
p
in
self
.
_plugins
:
self
.
all_stats
[
p
]
=
self
.
_plugins
[
p
].
get_raw
()
def
getAll
(
self
):
return
self
.
all_stats
glances/plugins/glances_diskio.py
浏览文件 @
3cbde4d2
...
...
@@ -121,11 +121,11 @@ class Plugin(GlancesPlugin):
# Build the string message
# Header
msg
=
"{0:
8
}"
.
format
(
_
(
"DISK I/O"
))
msg
=
"{0:
9
}"
.
format
(
_
(
"DISK I/O"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
"
{0:>6
}"
.
format
(
_
(
"R/s"
))
msg
=
"
{0:>7
}"
.
format
(
_
(
"R/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"
{0:>6
}"
.
format
(
_
(
"W/s"
))
msg
=
"
{0:>7
}"
.
format
(
_
(
"W/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Disk list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
diskio
:
diskio
[
'disk_name'
]):
...
...
glances/plugins/glances_processcount.py
浏览文件 @
3cbde4d2
...
...
@@ -33,7 +33,7 @@ class Plugin(GlancesPlugin):
GlancesPlugin
.
__init__
(
self
)
# Nothing else to do...
# 'processes' is already init in the _processes.py script
# 'processes' is already init in the
glances
_processes.py script
# We want to display the stat in the curse interface
self
.
display_curse
=
True
...
...
glances/plugins/glances_processlist.py
浏览文件 @
3cbde4d2
...
...
@@ -34,17 +34,6 @@ class Plugin(GlancesPlugin):
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
# Nothing else to do...
# 'processes' is already init in the _processes.py script
def
update
(
self
):
"""
Update processes stats
"""
# Note: Update is done in the processcount plugin
self
.
stats
=
glances_processes
.
getlist
()
# We want to display the stat in the curse interface
self
.
display_curse
=
True
# Set the message position
...
...
@@ -54,6 +43,17 @@ class Plugin(GlancesPlugin):
# Enter -1 to diplay bottom
self
.
line_curse
=
4
# Note 'processes' is already init in the _processes.py script
def
update
(
self
):
"""
Update processes stats
"""
# Note: Update is done in the processcount plugin
self
.
stats
=
glances_processes
.
getlist
()
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录