Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
c96fee90
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,发现更多精彩内容 >>
提交
c96fee90
编写于
3月 21, 2021
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor the way importants stats are displayed #1826
上级
c5e70b7c
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
60 addition
and
37 deletion
+60
-37
conf/glances.conf
conf/glances.conf
+20
-6
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+32
-26
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+4
-2
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+4
-3
未找到文件。
conf/glances.conf
浏览文件 @
c96fee90
...
...
@@ -42,24 +42,38 @@ swap_critical=90
[
cpu
]
disable
=
False
# See https://scoutapm.com/blog/slow_server_flow_chart
#
# I/O wait percentage should be lower than 1/# (# = Logical CPU cores)
# Leave commented to just use the default config:
# Careful=1/#*100-20% / Warning=1/#*100-10% / Critical=1/#*100
#iowait_careful=30
#iowait_warning=40
#iowait_critical=50
#
# Total % is 100 - idle
total_careful
=
65
total_warning
=
75
total_critical
=
85
total_log
=
True
#
# Default values if not defined: 50/70/90 (except for iowait)
user_careful
=
50
user_warning
=
70
user_critical
=
90
#
user_log=False
user_log
=
False
#user_critical_action=echo {{user}} {{value}} {{max}} > /tmp/cpu.alert
#
system_careful
=
50
system_warning
=
70
system_critical
=
90
system_log
=
False
#
steal_careful
=
50
steal_warning
=
70
steal_critical
=
90
#steal_log=True
# I/O wait percentage should be lower than 1/# (Logical CPU cores)
# Leave commented to just use the default config (1/#-20% / 1/#-10% / 1/#)
#iowait_careful=30
#iowait_warning=40
#iowait_critical=50
#
# Context switch limit (core / second)
# Leave commented to just use the default config (critical is 50000*# (Logical CPU cores)
#ctx_switches_careful=10000
...
...
glances/plugins/glances_cpu.py
浏览文件 @
c96fee90
...
...
@@ -19,6 +19,7 @@
"""CPU plugin."""
from
glances.logger
import
logger
from
glances.timer
import
getTimeSinceLastUpdate
from
glances.compat
import
iterkeys
from
glances.cpu_percent
import
cpu_percent
...
...
@@ -196,11 +197,11 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
for
key
in
[
'user'
,
'system'
,
'iowait'
]:
for
key
in
[
'user'
,
'system'
,
'iowait'
,
'total'
]:
if
key
in
self
.
stats
:
self
.
views
[
key
][
'decoration'
]
=
self
.
get_alert_log
(
self
.
stats
[
key
],
header
=
key
)
# Alert only
for
key
in
[
'steal'
,
'total'
]:
for
key
in
[
'steal'
]:
if
key
in
self
.
stats
:
self
.
views
[
key
][
'decoration'
]
=
self
.
get_alert
(
self
.
stats
[
key
],
header
=
key
)
# Alert only but depend on Core number
...
...
@@ -208,7 +209,7 @@ class Plugin(GlancesPlugin):
if
key
in
self
.
stats
:
self
.
views
[
key
][
'decoration'
]
=
self
.
get_alert
(
self
.
stats
[
key
],
maximum
=
100
*
self
.
stats
[
'cpucore'
],
header
=
key
)
# Optional
for
key
in
[
'nice'
,
'irq'
,
'i
owait
'
,
'steal'
,
'ctx_switches'
,
'interrupts'
,
'soft_interrupts'
,
'syscalls'
]:
for
key
in
[
'nice'
,
'irq'
,
'i
dle
'
,
'steal'
,
'ctx_switches'
,
'interrupts'
,
'soft_interrupts'
,
'syscalls'
]:
if
key
in
self
.
stats
:
self
.
views
[
key
][
'optional'
]
=
True
...
...
@@ -239,17 +240,19 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Total CPU usage
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'total'
])
if
idle_tag
:
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'total'
,
option
=
'decoration'
)))
else
:
# if idle_tag:
# ret.append(self.curse_add_line(
# msg, self.get_views(key='total', option='decoration')))
# else:
# ret.append(self.curse_add_line(msg))
# Idle CPU
if
'idle'
in
self
.
stats
and
not
idle_tag
:
msg
=
' {:8}'
.
format
(
'idle:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'idle'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Nice CPU
if
'nice'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'nice:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
self
.
get_views
(
key
=
'nice'
,
option
=
'optional'
)))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'nice'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
self
.
get_views
(
key
=
'nice'
,
option
=
'optional'
)))
# ctx_switches
if
'ctx_switches'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'ctx_sw:'
)
...
...
@@ -301,14 +304,14 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{:>6}'
.
format
(
self
.
stats
[
'nb_log_core'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# IOWait CPU
if
'iowait'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'iowait:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
self
.
get_views
(
key
=
'iowait'
,
option
=
'optional'
)))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'iowait'
])
# Nice CPU
if
'nice'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'nice:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'iowait'
,
option
=
'decoration'
),
optional
=
self
.
get_views
(
key
=
'iowait'
,
option
=
'optional'
)))
msg
,
optional
=
self
.
get_views
(
key
=
'nice'
,
option
=
'optional'
)))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'nice'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
self
.
get_views
(
key
=
'nice'
,
option
=
'optional'
)))
# soft_interrupts
if
'soft_interrupts'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'sw_int:'
)
...
...
@@ -318,12 +321,15 @@ class Plugin(GlancesPlugin):
# New line
ret
.
append
(
self
.
curse_new_line
())
# Idle CPU
if
'idle'
in
self
.
stats
and
not
idle_tag
:
msg
=
'{:8}'
.
format
(
'idle:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'idle'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# IOWait CPU
if
'iowait'
in
self
.
stats
:
msg
=
'{:8}'
.
format
(
'iowait:'
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
self
.
get_views
(
key
=
'iowait'
,
option
=
'optional'
)))
msg
=
'{:5.1f}%'
.
format
(
self
.
stats
[
'iowait'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'iowait'
,
option
=
'decoration'
),
optional
=
self
.
get_views
(
key
=
'iowait'
,
option
=
'optional'
)))
# Steal CPU usage
if
'steal'
in
self
.
stats
:
msg
=
' {:8}'
.
format
(
'steal:'
)
...
...
glances/plugins/glances_mem.py
浏览文件 @
c96fee90
...
...
@@ -19,6 +19,7 @@
"""Virtual memory plugin."""
from
glances.logger
import
logger
from
glances.compat
import
iterkeys
from
glances.plugins.glances_plugin
import
GlancesPlugin
...
...
@@ -161,7 +162,7 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
self
.
views
[
'
used
'
][
'decoration'
]
=
self
.
get_alert_log
(
self
.
stats
[
'used'
],
maximum
=
self
.
stats
[
'total'
])
self
.
views
[
'
percent
'
][
'decoration'
]
=
self
.
get_alert_log
(
self
.
stats
[
'used'
],
maximum
=
self
.
stats
[
'total'
])
# Optional
for
key
in
[
'active'
,
'inactive'
,
'buffers'
,
'cached'
]:
if
key
in
self
.
stats
:
...
...
@@ -184,7 +185,8 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Percent memory usage
msg
=
'{:>7.1%}'
.
format
(
self
.
stats
[
'percent'
]
/
100
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'percent'
,
option
=
'decoration'
)))
# Active memory usage
if
'active'
in
self
.
stats
:
msg
=
' {:9}'
.
format
(
'active:'
)
...
...
glances/plugins/glances_memswap.py
浏览文件 @
c96fee90
...
...
@@ -139,8 +139,8 @@ class Plugin(GlancesPlugin):
# Add specifics informations
# Alert and log
if
'used'
in
self
.
stats
and
'total'
in
self
.
stats
:
self
.
views
[
'
used
'
][
'decoration'
]
=
self
.
get_alert_log
(
self
.
stats
[
'used'
],
maximum
=
self
.
stats
[
'total'
])
if
'used'
in
self
.
stats
and
'total'
in
self
.
stats
and
'percent'
in
self
.
stats
:
self
.
views
[
'
percent
'
][
'decoration'
]
=
self
.
get_alert_log
(
self
.
stats
[
'used'
],
maximum
=
self
.
stats
[
'total'
])
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return the dict to display in the curse interface."""
...
...
@@ -159,7 +159,8 @@ class Plugin(GlancesPlugin):
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Percent memory usage
msg
=
'{:>6.1%}'
.
format
(
self
.
stats
[
'percent'
]
/
100
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
key
=
'percent'
,
option
=
'decoration'
)))
# New line
ret
.
append
(
self
.
curse_new_line
())
# Total memory usage
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录