Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
7f5c5e7d
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 搜索 >>
提交
7f5c5e7d
编写于
6月 05, 2021
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Get system sensors temperatures thresholds #1864
上级
c022aa95
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
35 addition
and
15 deletion
+35
-15
conf/glances.conf
conf/glances.conf
+4
-4
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+8
-1
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+23
-10
未找到文件。
conf/glances.conf
浏览文件 @
7f5c5e7d
...
...
@@ -263,10 +263,10 @@ disable=False
# Hide some sensors
#hide=ambient
# Sensors core thresholds (in Celsius...)
# Default values
if not defined: 60/70/80
temperature_core_careful
=
60
temperature_core_warning
=
70
temperature_core_critical
=
80
# Default values
are grabbed from the system
#
temperature_core_careful=60
#
temperature_core_warning=70
#
temperature_core_critical=80
# Temperatures threshold in °C for hddtemp
# Default values if not defined: 45/52/60
temperature_hdd_careful
=
45
...
...
glances/plugins/glances_plugin.py
浏览文件 @
7f5c5e7d
...
...
@@ -603,7 +603,7 @@ class GlancesPlugin(object):
return
self
.
get_refresh
()
def
set_limits
(
self
,
item
,
value
):
"""
Return
the limits object."""
"""
Set
the limits object."""
self
.
_limits
[
'{}_{}'
.
format
(
self
.
plugin_name
,
item
)]
=
value
def
get_limits
(
self
,
item
=
None
):
...
...
@@ -763,6 +763,13 @@ class GlancesPlugin(object):
action_key
=
action_key
,
log
=
True
)
def
is_limit
(
self
,
criticity
,
stat_name
=
""
):
"""Return true if the criticity limit exist for the given stat_name"""
if
stat_name
==
""
:
return
self
.
plugin_name
+
'_'
+
criticity
in
self
.
_limits
else
:
return
stat_name
+
'_'
+
criticity
in
self
.
_limits
def
get_limit
(
self
,
criticity
,
stat_name
=
""
):
"""Return the limit value for the alert."""
# Get the limit for stat + header
...
...
glances/plugins/glances_sensors.py
浏览文件 @
7f5c5e7d
...
...
@@ -166,9 +166,6 @@ class Plugin(GlancesPlugin):
def
update_views
(
self
):
"""Update stats views."""
# @TODO: manage limits coming from system here for temperature_core
# ...
# Call the father's method
super
(
Plugin
,
self
).
update_views
()
...
...
@@ -177,12 +174,26 @@ class Plugin(GlancesPlugin):
for
i
in
self
.
stats
:
if
not
i
[
'value'
]:
continue
if
i
[
'type'
]
==
'battery'
:
self
.
views
[
i
[
self
.
get_key
()]][
'value'
][
'decoration'
]
=
self
.
get_alert
(
current
=
100
-
i
[
'value'
],
header
=
i
[
'type'
])
# Alert processing
if
i
[
'type'
]
==
'temperature_core'
and
not
self
.
is_limit
(
'critical'
,
stat_name
=
i
[
'type'
]):
if
i
[
'critical'
]
is
None
:
alert
=
'DEFAULT'
elif
i
[
'value'
]
>=
i
[
'critical'
]:
alert
=
'CRITICAL'
elif
i
[
'warning'
]
is
None
:
alert
=
'DEFAULT'
elif
i
[
'value'
]
>=
i
[
'warning'
]:
alert
=
'WARNING'
else
:
alert
=
'OK'
elif
i
[
'type'
]
==
'battery'
:
alert
=
self
.
get_alert
(
current
=
100
-
i
[
'value'
],
header
=
i
[
'type'
])
else
:
self
.
views
[
i
[
self
.
get_key
()]][
'value'
][
'decoration'
]
=
self
.
get_alert
(
current
=
i
[
'value'
],
header
=
i
[
'type'
])
alert
=
self
.
get_alert
(
current
=
i
[
'value'
],
header
=
i
[
'type'
])
# Set the alert in the view
self
.
views
[
i
[
self
.
get_key
()]][
'value'
][
'decoration'
]
=
alert
def
msg_curse
(
self
,
args
=
None
,
max_width
=
None
):
"""Return the dict to display in the curse interface."""
...
...
@@ -316,8 +327,10 @@ class GlancesGrabSensors(object):
sensors_current
[
'label'
]
=
feature
.
label
# Sensors value, limit and unit
sensors_current
[
'value'
]
=
int
(
getattr
(
feature
,
'current'
,
0
)
if
getattr
(
feature
,
'current'
,
0
)
else
0
)
sensors_current
[
'warning'
]
=
int
(
getattr
(
feature
,
'high'
,
0
)
if
getattr
(
feature
,
'high'
,
0
)
else
0
)
sensors_current
[
'critical'
]
=
int
(
getattr
(
feature
,
'critical'
,
0
)
if
getattr
(
feature
,
'critical'
,
0
)
else
0
)
warning
=
getattr
(
feature
,
'high'
,
None
)
sensors_current
[
'warning'
]
=
int
(
warning
)
if
warning
is
not
None
else
None
critical
=
getattr
(
feature
,
'critical'
,
None
)
sensors_current
[
'critical'
]
=
int
(
critical
)
if
critical
is
not
None
else
None
sensors_current
[
'unit'
]
=
type
# Add sensor to the list
ret
.
append
(
sensors_current
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录