Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
c3b42a5f
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 搜索 >>
提交
c3b42a5f
编写于
12月 21, 2012
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add color to sensors
上级
2fd4779f
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
12 deletion
+87
-12
NEWS
NEWS
+4
-1
glances/glances.py
glances/glances.py
+36
-3
glances/unitest.py
glances/unitest.py
+47
-8
未找到文件。
NEWS
浏览文件 @
c3b42a5f
...
...
@@ -3,8 +3,11 @@ Version 1.5.2
* Add sensors module (enable it with -e option)
* Improve CPU stats (IO wait, Nice, IRQ)
* More stats in lower space (yes it
i
s possible)
* More stats in lower space (yes it
'
s possible)
* Refactor processes list and count (lower CPU/MEM footprint)
* Add functions to the RCP method
* Completed unit test
* and fixes...
Version 1.5.1
=============
...
...
glances/glances.py
浏览文件 @
c3b42a5f
...
...
@@ -209,9 +209,10 @@ class glancesLimits:
# Exemple:
# limits_list['STD'] = [50, 70, 90]
#_______________________
________
CAREFUL WARNING CRITICAL
#_______________________CAREFUL WARNING CRITICAL
__limits_list
=
{
'STD'
:
[
50
,
70
,
90
],
'LOAD'
:
[
0.7
,
1.0
,
5.0
]}
'LOAD'
:
[
0.7
,
1.0
,
5.0
],
'TEMP'
:
[
50
,
70
,
80
]}
def
__init__
(
self
,
careful
=
50
,
warning
=
70
,
critical
=
90
):
self
.
__limits_list
[
'STD'
]
=
[
careful
,
warning
,
critical
]
...
...
@@ -234,6 +235,15 @@ class glancesLimits:
def
getLOADCritical
(
self
,
core
=
1
):
return
self
.
__limits_list
[
'LOAD'
][
2
]
*
core
def
getTEMPCareful
(
self
):
return
self
.
__limits_list
[
'TEMP'
][
0
]
def
getTEMPWarning
(
self
):
return
self
.
__limits_list
[
'TEMP'
][
1
]
def
getTEMPCritical
(
self
):
return
self
.
__limits_list
[
'TEMP'
][
2
]
class
glancesLogs
:
"""
...
...
@@ -1290,6 +1300,28 @@ class glancesScreen:
def
__getProcessColor
(
self
,
current
=
0
,
max
=
100
):
return
self
.
__getColor2
(
current
,
max
)
def
__getSensorsAlert
(
self
,
current
=
0
):
# Alert for Sensors (temperature in degre)
# If current < CAREFUL then alert = OK
# If current > CAREFUL then alert = CAREFUL
# If current > WARNING then alert = WARNING
# If current > CRITICALthen alert = CRITICAL
if
current
>
limits
.
getTEMPCritical
():
return
'CRITICAL'
elif
current
>
limits
.
getTEMPWarning
():
return
'WARNING'
elif
current
>
limits
.
getTEMPCareful
():
return
'CAREFUL'
return
'OK'
def
__getSensorsColor
(
self
,
current
=
0
):
"""
Return color for Sensors temperature (non logged stats)
"""
return
self
.
__colors_list2
[
self
.
__getSensorsAlert
(
current
)]
def
__catchKey
(
self
):
# Get key
self
.
pressedkey
=
self
.
term_window
.
getch
()
...
...
@@ -1878,7 +1910,8 @@ class glancesScreen:
sensors
[
i
][
'label'
],
21
)
self
.
term_window
.
addnstr
(
self
.
sensors_y
+
1
+
i
,
self
.
sensors_x
+
20
,
format
(
sensors
[
i
][
'value'
],
'>3'
),
3
)
format
(
sensors
[
i
][
'value'
],
'>3'
),
3
,
self
.
__getSensorsColor
(
sensors
[
i
][
'value'
]))
ret
=
ret
+
1
return
ret
return
0
...
...
glances/unitest.py
浏览文件 @
c3b42a5f
...
...
@@ -37,44 +37,83 @@ class TestGlancesStat(unittest.TestCase):
def
test_Glances_getSystem
(
self
):
self
.
stats
.
update
()
system
=
self
.
stats
.
getSystem
()
print
(
"System info: %s"
%
system
)
#~ print("System info: %s" % system)
self
.
assertTrue
(
type
(
system
)
==
dict
)
self
.
assertTrue
(
len
(
system
)
>
1
)
def
test_Glances_getCore
(
self
):
self
.
stats
.
update
()
core
=
self
.
stats
.
getCore
()
print
(
"CPU Core number: %s"
%
core
)
#~ print("CPU Core number: %s" % core)
self
.
assertTrue
(
type
(
core
)
==
int
)
self
.
assertEqual
(
core
,
multiprocessing
.
cpu_count
())
def
test_Glances_getCpu
(
self
):
self
.
stats
.
update
()
cpu
=
self
.
stats
.
getCpu
()
print
(
"CPU stat %s:"
%
cpu
)
#~ print("CPU stat %s:" % cpu)
self
.
assertTrue
(
type
(
cpu
)
==
dict
)
self
.
assertTrue
(
len
(
cpu
)
>
1
)
def
test_Glances_getPerCpu
(
self
):
self
.
stats
.
update
()
percpu
=
self
.
stats
.
getPerCpu
()
print
(
"PerCPU stat %s:"
%
percpu
)
#~ print("PerCPU stat %s:" % percpu)
self
.
assertTrue
(
type
(
percpu
)
==
list
)
self
.
assertEqual
(
len
(
percpu
),
multiprocessing
.
cpu_count
())
def
test_Glances_getMem
(
self
):
self
.
stats
.
update
()
mem
=
self
.
stats
.
getMem
()
print
(
"Mem stat %s:"
%
mem
)
#~ print("Mem stat %s:" % mem)
self
.
assertTrue
(
type
(
mem
)
==
dict
)
self
.
assertTrue
(
len
(
mem
)
>
2
)
def
test_Glances_getMemSwap
(
self
):
self
.
stats
.
update
()
memswap
=
self
.
stats
.
getMemSwap
()
print
(
"MemSwap stat %s:"
%
memswap
)
#~ print("MemSwap stat %s:" % memswap)
self
.
assertTrue
(
type
(
memswap
)
==
dict
)
self
.
assertTrue
(
len
(
memswap
)
>
2
)
def
test_Glances_getNetwork
(
self
):
self
.
stats
.
update
()
net
=
self
.
stats
.
getNetwork
()
print
(
"Network stat %s:"
%
net
)
self
.
assertTrue
(
len
(
net
)
>
1
)
#~ print("Network stat %s:" % net)
self
.
assertTrue
(
type
(
net
)
==
list
)
self
.
assertTrue
(
len
(
net
)
>
0
)
def
test_Glances_getDiskIO
(
self
):
self
.
stats
.
update
()
diskio
=
self
.
stats
.
getDiskIO
()
#~ print("DiskIO stat %s:" % diskio)
self
.
assertTrue
(
type
(
diskio
)
==
list
)
self
.
assertTrue
(
len
(
diskio
)
>
0
)
def
test_Glances_getFs
(
self
):
self
.
stats
.
update
()
fs
=
self
.
stats
.
getFs
()
#~ print("File system stat %s:" % fs)
self
.
assertTrue
(
type
(
fs
)
==
list
)
self
.
assertTrue
(
len
(
fs
)
>
0
)
def
test_Glances_getProcess
(
self
):
self
.
stats
.
update
()
pc
=
self
.
stats
.
getProcessCount
()
pl
=
self
.
stats
.
getProcessList
()
#~ print("Processes stat %s:" % pc)
#~ print("Processes list %s:" % pl)
self
.
assertTrue
(
type
(
pc
)
==
dict
)
self
.
assertTrue
(
len
(
pc
)
>
2
)
self
.
assertTrue
(
type
(
pl
)
==
list
)
self
.
assertTrue
(
len
(
pl
)
>
0
)
def
test_Glances_getSensors
(
self
):
self
.
stats
.
update
()
sensors
=
self
.
stats
.
getSensors
()
#~ print("Optionnal sensors stat %s:" % sensors)
self
.
assertTrue
(
type
(
sensors
)
==
list
)
#~ self.assertTrue(len(sensors) > 0)
if
__name__
==
'__main__'
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录