Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
672ff0d9
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 搜索 >>
提交
672ff0d9
编写于
2月 07, 2015
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Grab FAN speed in the Glances sensors plugin (issue #501)
上级
d390e03a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
20 deletion
+60
-20
NEWS
NEWS
+8
-1
glances/plugins/glances_batpercent.py
glances/plugins/glances_batpercent.py
+1
-1
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+51
-18
未找到文件。
NEWS
浏览文件 @
672ff0d9
...
...
@@ -5,7 +5,14 @@ Glances Version 2.x
Version 2.4
===========
...
Enhancements and news features:
* Grab FAN speed in the Glances sensors plugin (issue #501)
Bugs corrected:
* Correct monitor list, all processes are take into account (issue #507)
* Correct duplicated --enable-history in the doc (issue #511)
Version 2.3
===========
...
...
glances/plugins/glances_batpercent.py
浏览文件 @
672ff0d9
...
...
@@ -94,7 +94,7 @@ class GlancesGrabBat(object):
"""Update the stats."""
if
self
.
initok
:
self
.
bat
.
update
()
self
.
bat_list
=
[{
'label'
:
_
(
"Battery
(%)"
),
'value'
:
self
.
getcapacitypercent
()
}]
self
.
bat_list
=
[{
'label'
:
_
(
"Battery
"
),
'value'
:
self
.
getcapacitypercent
(),
'unit'
:
'%'
}]
else
:
self
.
bat_list
=
[]
...
...
glances/plugins/glances_sensors.py
浏览文件 @
672ff0d9
...
...
@@ -33,6 +33,11 @@ from glances.plugins.glances_batpercent import Plugin as BatPercentPlugin
from
glances.plugins.glances_hddtemp
import
Plugin
as
HddTempPlugin
from
glances.plugins.glances_plugin
import
GlancesPlugin
if
is_py3
:
SENSOR_TEMP_UNIT
=
_
(
'°C'
)
else
:
SENSOR_TEMP_UNIT
=
_
(
'°C '
)
SENSOR_FAN_UNIT
=
_
(
'RPM'
)
class
Plugin
(
GlancesPlugin
):
...
...
@@ -80,11 +85,25 @@ class Plugin(GlancesPlugin):
if
self
.
get_input
()
==
'local'
:
# Update stats using the dedicated lib
self
.
stats
=
[]
# Get the temperature
try
:
self
.
stats
=
self
.
__set_type
(
self
.
glancesgrabsensors
.
get
(
),
'temperature_core'
)
temperature
=
self
.
__set_type
(
self
.
glancesgrabsensors
.
get
(
'temperature_core'
),
'temperature_core'
)
except
Exception
as
e
:
logger
.
error
(
"Cannot grab sensors temperatures (%s)"
%
e
)
else
:
# Append temperature
self
.
stats
.
extend
(
temperature
)
# Get the FAN speed
try
:
fan_speed
=
self
.
__set_type
(
self
.
glancesgrabsensors
.
get
(
'fan_speed'
),
'fan_speed'
)
except
Exception
as
e
:
logger
.
error
(
"Cannot grab FAN speed (%s)"
%
e
)
else
:
# Append FAN speed
self
.
stats
.
extend
(
fan_speed
)
# Update HDDtemp stats
try
:
hddtemp
=
self
.
__set_type
(
self
.
hddtemp_plugin
.
update
(),
...
...
@@ -119,10 +138,11 @@ class Plugin(GlancesPlugin):
def
__set_type
(
self
,
stats
,
sensor_type
):
"""Set the plugin type.
3 types of stats is possible in the sensors plugin:
- Core temperature
- HDD temperature
- Battery capacity
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery'
"""
for
i
in
stats
:
i
.
update
({
'type'
:
sensor_type
})
...
...
@@ -149,18 +169,13 @@ class Plugin(GlancesPlugin):
ret
=
[]
# Only process if stats exist and display plugin enable...
if
not
self
.
stats
or
args
.
disable_sensors
:
if
not
self
.
stats
or
args
.
disable_sensors
or
self
.
stats
==
[]
:
return
ret
# Build the string message
# Header
msg
=
'{0:18}'
.
format
(
_
(
"SENSORS"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
if
is_py3
:
msg
=
'{0:>5}'
.
format
(
_
(
"°C"
))
else
:
msg
=
'{0:>6}'
.
format
(
_
(
"°C"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
for
i
in
self
.
stats
:
if
i
[
'value'
]
is
not
None
and
i
[
'value'
]
!=
[]:
...
...
@@ -170,10 +185,12 @@ class Plugin(GlancesPlugin):
label
=
self
.
has_alias
(
i
[
'label'
].
lower
())
if
label
is
None
:
label
=
i
[
'label'
]
label
=
label
[:
18
]
msg
=
'{0:18}'
.
format
(
label
)
try
:
msg
=
"{0:12} {1:3}"
.
format
(
label
[:
11
],
i
[
'unit'
])
except
KeyError
:
msg
=
'{0:16}'
.
format
(
label
[:
15
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
'{0:>
5
}'
.
format
(
i
[
'value'
])
msg
=
'{0:>
7
}'
.
format
(
i
[
'value'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
self
.
get_views
(
item
=
i
[
self
.
get_key
()],
key
=
'value'
,
...
...
@@ -207,22 +224,38 @@ class GlancesGrabSensors(object):
# Reset the list
self
.
reset
()
# grab only temperature stats
if
self
.
initok
:
for
chip
in
sensors
.
iter_detected_chips
():
for
feature
in
chip
:
sensors_current
=
{}
if
feature
.
name
.
startswith
(
b
'temp'
):
# Temperature sensor
sensors_current
[
'unit'
]
=
SENSOR_TEMP_UNIT
elif
feature
.
name
.
startswith
(
b
'fan'
):
# Fan speed sensor
sensors_current
[
'unit'
]
=
SENSOR_FAN_UNIT
if
sensors_current
!=
{}:
sensors_current
[
'label'
]
=
feature
.
label
sensors_current
[
'value'
]
=
int
(
feature
.
get_value
())
self
.
sensors_list
.
append
(
sensors_current
)
return
self
.
sensors_list
def
get
(
self
):
def
get
(
self
,
type
=
'temperature_core'
):
"""Get sensors list."""
self
.
__update__
()
return
self
.
sensors_list
if
type
==
'temperature_core'
:
logger
.
info
(
type
)
ret
=
[
s
for
s
in
self
.
sensors_list
if
s
[
'unit'
]
==
SENSOR_TEMP_UNIT
]
elif
type
==
'fan_speed'
:
logger
.
info
(
type
)
ret
=
[
s
for
s
in
self
.
sensors_list
if
s
[
'unit'
]
==
SENSOR_FAN_UNIT
]
else
:
# Unknown type
logger
.
debug
(
"Unknown sensor type %s"
%
type
)
ret
=
[]
logger
.
info
(
ret
)
return
ret
def
quit
(
self
):
"""End of connection."""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录