Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
d947d6e0
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,发现更多精彩内容 >>
提交
d947d6e0
编写于
2月 16, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Process display, first draft
上级
d038e619
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
246 addition
and
41 deletion
+246
-41
glances/plugins/glances_hddtemp.py
glances/plugins/glances_hddtemp.py
+4
-7
glances/plugins/glances_now.py
glances/plugins/glances_now.py
+1
-1
glances/plugins/glances_processcount.py
glances/plugins/glances_processcount.py
+57
-1
glances/plugins/glances_processlist.py
glances/plugins/glances_processlist.py
+112
-2
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+72
-30
未找到文件。
glances/plugins/glances_hddtemp.py
浏览文件 @
d947d6e0
...
...
@@ -36,6 +36,10 @@ class Plugin(GlancesPlugin):
# Init the sensor class
self
.
glancesgrabhddtemp
=
glancesGrabHDDTemp
()
# We do not want to display the stat in a dedicated area
# The HDD temp is displayed within the sensors plugin
self
.
display_curse
=
False
def
update
(
self
):
"""
...
...
@@ -45,13 +49,6 @@ class Plugin(GlancesPlugin):
self
.
stats
=
self
.
glancesgrabhddtemp
.
get
()
def
get_stats
(
self
):
# Return the stats object for the RPC API
# !!! Sort it by label name (why do it here ? Better in client side ?)
self
.
stats
=
sorted
(
self
.
stats
,
key
=
lambda
sensors
:
sensors
[
'label'
])
return
GlancesPlugin
.
get_stats
(
self
)
class
glancesGrabHDDTemp
:
"""
Get hddtemp stats using a socket connection
...
...
glances/plugins/glances_now.py
浏览文件 @
d947d6e0
...
...
@@ -40,7 +40,7 @@ class Plugin(GlancesPlugin):
# Set the message position
# It is NOT the curse position but the Glances column/line
# Enter -1 to right align
self
.
column_curse
=
-
1
self
.
column_curse
=
0
# Enter -1 to diplay bottom
self
.
line_curse
=
-
1
...
...
glances/plugins/glances_processcount.py
浏览文件 @
d947d6e0
...
...
@@ -21,6 +21,7 @@
from
glances_plugin
import
GlancesPlugin
from
_processes
import
processes
class
Plugin
(
GlancesPlugin
):
"""
Glances's processes Plugin
...
...
@@ -33,6 +34,15 @@ class Plugin(GlancesPlugin):
# Nothing else to do...
# 'processes' is already init in the _processes.py script
# We want to display the stat in the curse interface
self
.
display_curse
=
True
# Set the message position
# It is NOT the curse position but the Glances column/line
# Enter -1 to right align
self
.
column_curse
=
1
# Enter -1 to diplay bottom
self
.
line_curse
=
2
def
update
(
self
):
...
...
@@ -40,6 +50,52 @@ class Plugin(GlancesPlugin):
Update processes stats
"""
#
!!! Update is call twisse (one for processcount and one for processlist)
#
Here, update is call for processcount AND processlist
processes
.
update
()
self
.
stats
=
processes
.
getcount
()
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
# Init the return message
ret
=
[]
# Build the string message
# Header
msg
=
"{0} "
.
format
(
_
(
"TASKS"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
# Compute processes
other
=
self
.
stats
[
'total'
]
msg
=
"{0}"
.
format
(
str
(
self
.
stats
[
'total'
]))
ret
.
append
(
self
.
curse_add_line
(
msg
))
if
(
'thread'
in
self
.
stats
):
msg
=
" ({0} {1}),"
.
format
(
str
(
self
.
stats
[
'thread'
]),
_
(
"thr"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
if
(
'running'
in
self
.
stats
):
other
-=
self
.
stats
[
'running'
]
msg
=
" {0} {1},"
.
format
(
str
(
self
.
stats
[
'running'
]),
_
(
"run"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
if
(
'sleeping'
in
self
.
stats
):
other
-=
self
.
stats
[
'sleeping'
]
msg
=
" {0} {1},"
.
format
(
str
(
self
.
stats
[
'sleeping'
]),
_
(
"slp"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
" {0} {1} "
.
format
(
str
(
other
),
_
(
"oth"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Display sort information
if
(
args
.
process_sorted_by
==
'auto'
):
msg
=
"{0}"
.
format
(
_
(
"sorted automatically"
))
else
:
msg
=
"{0}"
.
format
(
_
(
"sorted by "
)
+
args
.
process_sorted_by
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
'UNDERLINE'
))
# Return the message with decoration
return
ret
glances/plugins/glances_processlist.py
浏览文件 @
d947d6e0
...
...
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from
datetime
import
timedelta
from
glances_plugin
import
GlancesPlugin
from
_processes
import
processes
...
...
@@ -41,7 +43,115 @@ class Plugin(GlancesPlugin):
Update processes stats
"""
#
!!! Update is call twisse (one for processcount and one for processlist)
processes
.
update
()
#
Note: Update is done in the processcount plugin
self
.
stats
=
processes
.
getlist
()
# We want to display the stat in the curse interface
self
.
display_curse
=
True
# Set the message position
# It is NOT the curse position but the Glances column/line
# Enter -1 to right align
self
.
column_curse
=
1
# Enter -1 to diplay bottom
self
.
line_curse
=
3
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
# Init the return message
ret
=
[]
# Header
msg
=
"{0:15}"
.
format
(
_
(
""
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>6}"
.
format
(
_
(
"CPU%"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>6}"
.
format
(
_
(
"MEM%"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>6}"
.
format
(
_
(
"VIRT"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>6}"
.
format
(
_
(
"RES"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>6}"
.
format
(
_
(
"PID"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
" {0:10}"
.
format
(
_
(
"USER"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>3}"
.
format
(
_
(
"NI"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
" {0:1}"
.
format
(
_
(
"S"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>9}"
.
format
(
_
(
"TIME+"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>6}"
.
format
(
_
(
"IOr/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
"{0:>6}"
.
format
(
_
(
"IOw/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
" {0:8}"
.
format
(
_
(
"Command"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# Trying to display proc time
tag_proc_time
=
True
# Loop over processes (sorted by args.process_sorted_by)
for
p
in
sorted
(
self
.
stats
,
key
=
lambda
process
:
process
[
'cpu_percent'
],
reverse
=
True
):
ret
.
append
(
self
.
curse_new_line
())
# Name
msg
=
"{0:15}"
.
format
(
p
[
'name'
][:
15
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# CPU
msg
=
"{0:>6}"
.
format
(
format
(
p
[
'cpu_percent'
],
'>5.1f'
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# MEM
msg
=
"{0:>6}"
.
format
(
format
(
p
[
'memory_percent'
],
'>5.1f'
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# 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
))
# PID
msg
=
"{0:>6}"
.
format
(
p
[
'pid'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# USER
msg
=
" {0:9}"
.
format
(
p
[
'username'
][:
9
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# NICE
msg
=
" {0:>3}"
.
format
(
p
[
'nice'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# STATUS
msg
=
" {0:>1}"
.
format
(
p
[
'status'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# TIME+
if
(
tag_proc_time
):
try
:
dtime
=
timedelta
(
seconds
=
sum
(
p
[
'cpu_times'
]))
except
Exception
:
# Catched on some Amazon EC2 server
# See https://github.com/nicolargo/glances/issues/87
tag_proc_time
=
False
else
:
msg
=
"{0}:{1}.{2}"
.
format
(
str
(
dtime
.
seconds
//
60
%
60
),
str
(
dtime
.
seconds
%
60
).
zfill
(
2
),
str
(
dtime
.
microseconds
)[:
2
].
zfill
(
2
))
else
:
msg
=
" "
msg
=
"{0:>9}"
.
format
(
msg
)
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# IO read
io_rs
=
(
p
[
'io_counters'
][
0
]
-
p
[
'io_counters'
][
2
])
/
p
[
'time_since_update'
]
msg
=
"{0:>6}"
.
format
(
self
.
auto_unit
(
io_rs
,
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# IO write
io_ws
=
(
p
[
'io_counters'
][
1
]
-
p
[
'io_counters'
][
3
])
/
p
[
'time_since_update'
]
msg
=
"{0:>6}"
.
format
(
self
.
auto_unit
(
io_ws
,
low_precision
=
False
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
msg
=
" {0}"
.
format
(
p
[
'cmdline'
])
ret
.
append
(
self
.
curse_add_line
(
msg
,
optional
=
True
))
# Return the message with decoration
return
ret
glances/plugins/glances_sensors.py
浏览文件 @
d947d6e0
...
...
@@ -27,35 +27,7 @@ except:
pass
from
glances_plugin
import
GlancesPlugin
,
getTimeSinceLastUpdate
class
Plugin
(
GlancesPlugin
):
"""
Glances's sensors Plugin
stats is a list
"""
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
# Init the sensor class
self
.
glancesgrabsensors
=
glancesGrabSensors
()
def
update
(
self
):
"""
Update Sensors stats
"""
self
.
stats
=
self
.
glancesgrabsensors
.
get
()
def
get_stats
(
self
):
# Return the stats object for the RPC API
# !!! Sort it by label name (why do it here ? Better in client side ?)
self
.
stats
=
sorted
(
self
.
stats
,
key
=
lambda
sensors
:
sensors
[
'label'
])
return
GlancesPlugin
.
get_stats
(
self
)
from
glances_hddtemp
import
Plugin
as
HddTempPlugin
class
glancesGrabSensors
:
...
...
@@ -102,4 +74,74 @@ class glancesGrabSensors:
def
quit
(
self
):
if
self
.
initok
:
sensors
.
cleanup
()
\ No newline at end of file
sensors
.
cleanup
()
class
Plugin
(
GlancesPlugin
):
"""
Glances's sensors Plugin
stats is a list
"""
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
# Init the sensor class
self
.
glancesgrabsensors
=
glancesGrabSensors
()
# Instance for the CorePlugin in order to display the core number
self
.
hddtemp_plugin
=
HddTempPlugin
()
# We want to display the stat in the curse interface
self
.
display_curse
=
True
# Set the message position
# It is NOT the curse position but the Glances column/line
# Enter -1 to right align
self
.
column_curse
=
0
# Enter -1 to diplay bottom
self
.
line_curse
=
5
def
update
(
self
):
"""
Update Sensors stats
"""
self
.
stats
=
self
.
glancesgrabsensors
.
get
()
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
# Init the return message
ret
=
[]
# Build the string message
# Header
msg
=
"{0:8}"
.
format
(
_
(
"SENSORS"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
"{0:>16}"
.
format
(
_
(
"Temp °C"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Sensors list (sorted by name): Sensors
sensor_list
=
sorted
(
self
.
stats
,
key
=
lambda
sensors
:
sensors
[
'label'
])
for
i
in
sensor_list
:
# New line
ret
.
append
(
self
.
curse_new_line
())
msg
=
"{0:<15}"
.
format
(
i
[
'label'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>8}"
.
format
(
i
[
'value'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Sensors list (sorted by name): HDDTemp
self
.
hddtemp_plugin
.
update
()
sensor_list
=
sorted
(
self
.
hddtemp_plugin
.
stats
,
key
=
lambda
sensors
:
sensors
[
'label'
])
for
i
in
sensor_list
:
# New line
ret
.
append
(
self
.
curse_new_line
())
msg
=
"{0:<15}"
.
format
(
"Disk "
+
i
[
'label'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>8}"
.
format
(
i
[
'value'
])
ret
.
append
(
self
.
curse_add_line
(
msg
))
return
ret
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录