Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
c39789b9
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,发现更多精彩内容 >>
提交
c39789b9
编写于
6月 29, 2014
作者:
N
Nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Side bar use more space in SNMP mode
上级
39807301
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
127 addition
and
57 deletion
+127
-57
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+12
-5
glances/plugins/glances_fs.py
glances/plugins/glances_fs.py
+14
-7
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+1
-1
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+12
-6
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+26
-6
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+62
-32
未找到文件。
glances/outputs/glances_curses.py
浏览文件 @
c39789b9
...
...
@@ -304,23 +304,30 @@ class GlancesCurses(object):
stats_memswap
=
stats
.
get_plugin
(
'memswap'
).
get_stats_display
()
l
+=
self
.
get_stats_display_width
(
stats_load
)
+
self
.
get_stats_display_width
(
stats_mem
)
+
self
.
get_stats_display_width
(
stats_memswap
)
# Space between column
if
screen_x
>
(
3
*
self
.
space_between_column
+
l
):
self
.
space_between_column
=
int
((
screen_x
-
l
)
/
3
)
space_number
=
int
(
stats_load
[
'msgdict'
]
!=
[])
+
int
(
stats_mem
[
'msgdict'
]
!=
[])
+
int
(
stats_memswap
[
'msgdict'
]
!=
[])
if
screen_x
>
(
space_number
*
self
.
space_between_column
+
l
):
self
.
space_between_column
=
int
((
screen_x
-
l
)
/
space_number
)
# Display
if
self
.
args
.
percpu
:
self
.
display_plugin
(
stats_percpu
)
else
:
self
.
display_plugin
(
stats_cpu
,
display_optional
=
(
screen_x
>=
80
))
self
.
display_plugin
(
stats_load
)
self
.
display_plugin
(
stats_mem
,
display_optional
=
(
screen_x
>=
(
3
*
self
.
space_between_column
+
l
)))
self
.
display_plugin
(
stats_mem
,
display_optional
=
(
screen_x
>=
(
space_number
*
self
.
space_between_column
+
l
)))
self
.
display_plugin
(
stats_memswap
)
# Space between column
self
.
space_between_column
=
3
# Display left sidebar (NETWORK+DISKIO+FS+SENSORS)
self
.
display_plugin
(
stats
.
get_plugin
(
'network'
).
get_stats_display
(
args
=
self
.
args
))
if
cs_status
==
'SNMP'
:
# No process list
# More space for others plugins
plugin_max_width
=
43
else
:
plugin_max_width
=
None
self
.
display_plugin
(
stats
.
get_plugin
(
'network'
).
get_stats_display
(
args
=
self
.
args
,
max_width
=
plugin_max_width
))
self
.
display_plugin
(
stats
.
get_plugin
(
'diskio'
).
get_stats_display
(
args
=
self
.
args
))
self
.
display_plugin
(
stats
.
get_plugin
(
'fs'
).
get_stats_display
(
args
=
self
.
args
))
self
.
display_plugin
(
stats
.
get_plugin
(
'fs'
).
get_stats_display
(
args
=
self
.
args
,
max_width
=
plugin_max_width
))
self
.
display_plugin
(
stats
.
get_plugin
(
'sensors'
).
get_stats_display
(
args
=
self
.
args
))
# Display last line (currenttime)
self
.
display_plugin
(
stats
.
get_plugin
(
'now'
).
get_stats_display
())
...
...
glances/plugins/glances_fs.py
浏览文件 @
c39789b9
...
...
@@ -150,7 +150,7 @@ class Plugin(GlancesPlugin):
return
self
.
stats
def
msg_curse
(
self
,
args
=
None
):
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return the dict to display in the curse interface."""
# Init the return message
ret
=
[]
...
...
@@ -159,9 +159,16 @@ class Plugin(GlancesPlugin):
if
self
.
stats
==
[]
or
args
.
disable_fs
:
return
ret
# Max size for the fsname name
if
max_width
is
not
None
and
max_width
>=
23
:
# Interface size name = max_width - space for interfaces bitrate
fsname_max_width
=
max_width
-
14
else
:
fsname_max_width
=
9
# Build the string message
# Header
msg
=
'{0:
9}'
.
format
(
_
(
"FILE SYS"
)
)
msg
=
'{0:
{width}}'
.
format
(
_
(
"FILE SYS"
),
width
=
fsname_max_width
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
'{0:>7}'
.
format
(
_
(
"Used"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
...
...
@@ -172,17 +179,17 @@ class Plugin(GlancesPlugin):
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
fs
:
fs
[
'mnt_point'
]):
# New line
ret
.
append
(
self
.
curse_new_line
())
if
i
[
'device_name'
]
==
''
:
if
i
[
'device_name'
]
==
''
or
i
[
'device_name'
]
==
'none'
:
mnt_point
=
i
[
'mnt_point'
]
elif
len
(
i
[
'mnt_point'
])
+
len
(
i
[
'device_name'
].
split
(
'/'
)[
-
1
])
<=
6
:
elif
len
(
i
[
'mnt_point'
])
+
len
(
i
[
'device_name'
].
split
(
'/'
)[
-
1
])
<=
fsname_max_width
-
3
:
# If possible concatenate mode info... Glances touch inside :)
mnt_point
=
i
[
'mnt_point'
]
+
' ('
+
i
[
'device_name'
].
split
(
'/'
)[
-
1
]
+
')'
elif
len
(
i
[
'mnt_point'
])
>
9
:
elif
len
(
i
[
'mnt_point'
])
>
fsname_max_width
:
# Cut mount point name if it is too long
mnt_point
=
'_'
+
i
[
'mnt_point'
][
-
8
:]
mnt_point
=
'_'
+
i
[
'mnt_point'
][
-
fsname_max_width
+
1
:]
else
:
mnt_point
=
i
[
'mnt_point'
]
msg
=
'{0:
9}'
.
format
(
mnt_point
)
msg
=
'{0:
{width}}'
.
format
(
mnt_point
,
width
=
fsname_max_width
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{0:>7}'
.
format
(
self
.
auto_unit
(
i
[
'used'
]))
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_alert
(
i
[
'used'
],
max
=
i
[
'size'
])))
...
...
glances/plugins/glances_memswap.py
浏览文件 @
c39789b9
...
...
@@ -102,7 +102,7 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'free'
]
=
self
.
stats
[
'total'
]
-
self
.
stats
[
'used'
]
break
else
:
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
)
self
.
stats
=
self
.
set_stats_snmp
(
snmp_oid
=
snmp_oid
[
'default'
]
)
if
self
.
stats
[
'total'
]
==
''
:
self
.
reset
()
...
...
glances/plugins/glances_network.py
浏览文件 @
c39789b9
...
...
@@ -174,9 +174,8 @@ class Plugin(GlancesPlugin):
return
self
.
stats
def
msg_curse
(
self
,
args
=
None
):
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return the dict to display in the curse interface."""
# !!! TODO: Add alert on network interface bitrate
# Init the return message
ret
=
[]
...
...
@@ -185,9 +184,16 @@ class Plugin(GlancesPlugin):
if
self
.
stats
==
[]
or
args
.
disable_network
:
return
ret
# Max size for the interface name
if
max_width
is
not
None
and
max_width
>=
23
:
# Interface size name = max_width - space for interfaces bitrate
ifname_max_width
=
max_width
-
14
else
:
ifname_max_width
=
9
# Build the string message
# Header
msg
=
'{0:
9}'
.
format
(
_
(
"NETWORK"
)
)
msg
=
'{0:
{width}}'
.
format
(
_
(
"NETWORK"
),
width
=
ifname_max_width
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
if
args
.
network_cumul
:
# Cumulative stats
...
...
@@ -219,9 +225,9 @@ class Plugin(GlancesPlugin):
continue
# Format stats
ifname
=
i
[
'interface_name'
].
split
(
':'
)[
0
]
if
len
(
ifname
)
>
9
:
if
len
(
ifname
)
>
ifname_max_width
:
# Cut interface name if it is too long
ifname
=
'_'
+
ifname
[
-
8
:]
ifname
=
'_'
+
ifname
[
-
ifname_max_width
+
1
:]
if
args
.
byte
:
# Bytes per second (for dummy)
if
args
.
network_cumul
:
...
...
@@ -248,7 +254,7 @@ class Plugin(GlancesPlugin):
int
(
i
[
'tx'
]
//
i
[
'time_since_update'
]
*
8
))
+
"b"
# New line
ret
.
append
(
self
.
curse_new_line
())
msg
=
'{0:
9}'
.
format
(
ifname
)
msg
=
'{0:
{width}}'
.
format
(
ifname
,
width
=
ifname_max_width
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
if
args
.
network_sum
:
msg
=
'{0:>14}'
.
format
(
sx
)
...
...
glances/plugins/glances_plugin.py
浏览文件 @
c39789b9
...
...
@@ -268,11 +268,11 @@ class GlancesPlugin(object):
"""Return True if the value is in the hide configuration list."""
return
value
in
self
.
get_hide
(
header
=
header
)
def
msg_curse
(
self
,
args
):
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return default string to display in the curse interface."""
return
[
self
.
curse_add_line
(
str
(
self
.
stats
))]
def
get_stats_display
(
self
,
args
=
None
):
def
get_stats_display
(
self
,
args
=
None
,
max_width
=
None
):
"""Return a dict with all the information needed to display the stat.
key | description
...
...
@@ -293,10 +293,18 @@ class GlancesPlugin(object):
if
hasattr
(
self
,
'line_curse'
):
line_curse
=
self
.
line_curse
return
{
'display'
:
display_curse
,
'msgdict'
:
self
.
msg_curse
(
args
),
'column'
:
column_curse
,
'line'
:
line_curse
}
if
max_width
is
not
None
:
ret
=
{
'display'
:
display_curse
,
'msgdict'
:
self
.
msg_curse
(
args
,
max_width
=
max_width
),
'column'
:
column_curse
,
'line'
:
line_curse
}
else
:
ret
=
{
'display'
:
display_curse
,
'msgdict'
:
self
.
msg_curse
(
args
),
'column'
:
column_curse
,
'line'
:
line_curse
}
return
ret
def
curse_add_line
(
self
,
msg
,
decoration
=
"DEFAULT"
,
optional
=
False
,
splittable
=
False
):
"""Return a dict with: { 'msg': msg, 'decoration': decoration, 'optional': False }.
...
...
@@ -328,6 +336,18 @@ class GlancesPlugin(object):
"""Go to a new line."""
return
self
.
curse_add_line
(
'
\n
'
)
def
set_curse_column
(
self
,
column
):
"""Set the Curse column
Enter -1 to right align
"""
self
.
column_curse
=
column
def
set_curse_line
(
self
,
line
):
"""Set the Curse line
Enter -1 to right align
"""
self
.
line_curse
=
line
def
auto_unit
(
self
,
number
,
low_precision
=
False
):
"""Make a nice human-readable string out of number.
...
...
glances/plugins/glances_processlist.py
浏览文件 @
c39789b9
...
...
@@ -63,10 +63,9 @@ class Plugin(GlancesPlugin):
# Update stats using the standard system lib
# Note: Update is done in the processcount plugin
# Just return the processes list
self
.
stats
=
glances_processes
.
getlist
()
self
.
stats
=
glances_processes
.
getlist
()
elif
self
.
get_input
()
==
'snmp'
:
# Update stats using SNMP
# !!! TODO
# No SNMP grab for processes
pass
return
self
.
stats
...
...
@@ -124,42 +123,68 @@ class Plugin(GlancesPlugin):
for
p
in
self
.
sortlist
(
process_sort_key
):
ret
.
append
(
self
.
curse_new_line
())
# CPU
msg
=
'{0:>6.1f}'
.
format
(
p
[
'cpu_percent'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_alert
(
p
[
'cpu_percent'
],
header
=
"cpu"
)))
if
'cpu_percent'
in
p
:
msg
=
'{0:>6.1f}'
.
format
(
p
[
'cpu_percent'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_alert
(
p
[
'cpu_percent'
],
header
=
"cpu"
)))
else
:
msg
=
'{0:>6}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# MEM
msg
=
'{0:>6.1f}'
.
format
(
p
[
'memory_percent'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_alert
(
p
[
'memory_percent'
],
header
=
"mem"
)))
# VMS
msg
=
'{0:>6}'
.
format
(
self
.
auto_unit
(
p
[
'memory_info'
][
1
],
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# RSS
msg
=
'{0:>6}'
.
format
(
self
.
auto_unit
(
p
[
'memory_info'
][
0
],
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
if
'memory_percent'
in
p
:
msg
=
'{0:>6.1f}'
.
format
(
p
[
'memory_percent'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_alert
(
p
[
'memory_percent'
],
header
=
"mem"
)))
else
:
msg
=
'{0:>6}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# VMS/RSS
if
'memory_info'
in
p
:
# VMS
msg
=
'{0:>6}'
.
format
(
self
.
auto_unit
(
p
[
'memory_info'
][
1
],
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# RSS
msg
=
'{0:>6}'
.
format
(
self
.
auto_unit
(
p
[
'memory_info'
][
0
],
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
else
:
msg
=
'{0:>6}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# PID
msg
=
'{0:>6}'
.
format
(
p
[
'pid'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# USER
# docker internal users are displayed as ints only, therefore str()
msg
=
' {0:9}'
.
format
(
str
(
p
[
'username'
])[:
9
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
if
'username'
in
p
:
# docker internal users are displayed as ints only, therefore str()
msg
=
' {0:9}'
.
format
(
str
(
p
[
'username'
])[:
9
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
else
:
msg
=
' {0:9}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# NICE
nice
=
p
[
'nice'
]
if
nice
is
None
:
nice
=
'?'
msg
=
'{0:>5}'
.
format
(
nice
)
if
isinstance
(
nice
,
int
)
and
((
is_windows
and
nice
!=
32
)
or
(
not
is_windows
and
nice
!=
0
)):
ret
.
append
(
self
.
curse_add_line
(
msg
,
decoration
=
'NICE'
))
if
'nice'
in
p
:
nice
=
p
[
'nice'
]
if
nice
is
None
:
nice
=
'?'
msg
=
'{0:>5}'
.
format
(
nice
)
if
isinstance
(
nice
,
int
)
and
((
is_windows
and
nice
!=
32
)
or
(
not
is_windows
and
nice
!=
0
)):
ret
.
append
(
self
.
curse_add_line
(
msg
,
decoration
=
'NICE'
))
else
:
ret
.
append
(
self
.
curse_add_line
(
msg
))
else
:
msg
=
'{0:>5}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# STATUS
status
=
p
[
'status'
]
msg
=
'{0:>2}'
.
format
(
status
)
if
status
==
'R'
:
ret
.
append
(
self
.
curse_add_line
(
msg
,
decoration
=
'STATUS'
))
if
'status'
in
p
:
status
=
p
[
'status'
]
msg
=
'{0:>2}'
.
format
(
status
)
if
status
==
'R'
:
ret
.
append
(
self
.
curse_add_line
(
msg
,
decoration
=
'STATUS'
))
else
:
ret
.
append
(
self
.
curse_add_line
(
msg
))
else
:
msg
=
'{0:>2}'
.
format
(
'?'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
# TIME+
if
tag_proc_time
:
...
...
@@ -250,9 +275,14 @@ class Plugin(GlancesPlugin):
reverse
=
sortedreverse
)
else
:
# Others sorts
listsorted
=
sorted
(
self
.
stats
,
key
=
lambda
process
:
process
[
sortedby
],
reverse
=
sortedreverse
)
try
:
listsorted
=
sorted
(
self
.
stats
,
key
=
lambda
process
:
process
[
sortedby
],
reverse
=
sortedreverse
)
except
KeyError
:
listsorted
=
sorted
(
self
.
stats
,
key
=
lambda
process
:
process
[
'name'
],
reverse
=
False
)
self
.
stats
=
listsorted
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录