Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
41f48265
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,体验更适合开发者的 AI 搜索 >>
提交
41f48265
编写于
1月 11, 2019
作者:
S
sangoh.hong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Client Browser's thread management added.
Curses Browser's key bug fixed.
上级
8aecac8f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
22 addition
and
9 deletion
+22
-9
.gitignore
.gitignore
+3
-0
glances/client_browser.py
glances/client_browser.py
+12
-4
glances/outputs/glances_curses_browser.py
glances/outputs/glances_curses_browser.py
+7
-5
未找到文件。
.gitignore
浏览文件 @
41f48265
...
...
@@ -47,3 +47,6 @@ _build
# web ui
node_modules/
bower_components/
# visual stdio code
.vscode/
\ No newline at end of file
glances/client_browser.py
浏览文件 @
41f48265
...
...
@@ -219,12 +219,16 @@ class GlancesClientBrowser(object):
# It's done by the GlancesAutoDiscoverListener class (autodiscover.py)
# Or define staticaly in the configuration file (module static_list.py)
# For each server in the list, grab elementary stats (CPU, LOAD, MEM, OS...)
while
Tru
e
:
thread_list
=
{}
while
self
.
screen
.
is_end
==
Fals
e
:
logger
.
debug
(
"Iter through the following server list: {}"
.
format
(
self
.
get_servers_list
()))
for
v
in
self
.
get_servers_list
():
thread
=
threading
.
Thread
(
target
=
self
.
__update_stats
,
args
=
[
v
])
thread
.
start
()
key
=
v
[
"key"
]
thread
=
thread_list
.
get
(
key
,
None
)
if
thread
is
None
or
thread
.
is_alive
()
==
False
:
thread
=
threading
.
Thread
(
target
=
self
.
__update_stats
,
args
=
[
v
])
thread_list
[
key
]
=
thread
thread
.
start
()
# Update the screen (list or Glances client)
if
self
.
screen
.
active_server
is
None
:
...
...
@@ -234,6 +238,10 @@ class GlancesClientBrowser(object):
# Display the active server
self
.
__display_server
(
self
.
get_servers_list
()[
self
.
screen
.
active_server
])
# exit key pressed
for
thread
in
thread_list
.
values
():
thread
.
join
()
def
serve_forever
(
self
):
"""Wrapper to the serve_forever function.
...
...
glances/outputs/glances_curses_browser.py
浏览文件 @
41f48265
...
...
@@ -61,6 +61,8 @@ class GlancesCursesBrowser(_GlancesCurses):
self
.
_page_max
=
0
self
.
_page_max_lines
=
0
self
.
is_end
=
False
@
property
def
active_server
(
self
):
"""Return the active server or None if it's the browser list."""
...
...
@@ -124,6 +126,8 @@ class GlancesCursesBrowser(_GlancesCurses):
"""Set next page."""
if
self
.
_current_page
+
1
<
self
.
_page_max
:
self
.
_current_page
+=
1
else
:
self
.
_current_page
=
0
self
.
cursor_position
=
0
def
__catch_key
(
self
,
stats
):
...
...
@@ -138,7 +142,8 @@ class GlancesCursesBrowser(_GlancesCurses):
# 'ESC'|'q' > Quit
self
.
end
()
logger
.
info
(
"Stop Glances client browser"
)
sys
.
exit
(
0
)
# sys.exit(0)
self
.
is_end
=
True
elif
self
.
pressedkey
==
10
:
# 'ENTER' > Run Glances on the selected server
self
.
active_server
=
self
.
_current_page
*
self
.
_page_max_lines
+
self
.
cursor_position
...
...
@@ -288,10 +293,7 @@ class GlancesCursesBrowser(_GlancesCurses):
self
.
cursor
=
len
(
stats
)
-
1
start_line
=
self
.
_page_max_lines
*
self
.
_current_page
end_line
=
start_line
+
self
.
_page_max_lines
if
end_line
>
stats_len
:
end_line
=
stats_len
end_line
=
start_line
+
self
.
get_pagelines
(
stats
)
current_page
=
stats
[
start_line
:
end_line
]
# Display table
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录