Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
59f55fa7
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 搜索 >>
提交
59f55fa7
编写于
11月 01, 2012
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add funcs to RPC instance
上级
d3201707
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
53 addition
and
29 deletion
+53
-29
glances/glances.py
glances/glances.py
+53
-29
未找到文件。
glances/glances.py
浏览文件 @
59f55fa7
...
...
@@ -2,10 +2,9 @@
#
# Glances is a simple textual monitoring tool
#
# Pre-requisites: Python 2.6+ and PsUtil 0.4.0+ (for full functions)
#
# Copyright (C) Nicolargo 2012 <nicolas@nicolargo.com>
#
# Glances is distributed
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
...
...
@@ -20,7 +19,7 @@
#
__appname__
=
'glances'
__version__
=
"1.
4.2.2
b"
__version__
=
"1.
5
b"
__author__
=
"Nicolas Hennion <nicolas@nicolargo.com>"
__licence__
=
"LGPL"
...
...
@@ -341,7 +340,6 @@ class glancesStats:
procstat
[
'cmdline'
]
=
" "
.
join
(
procstat
[
'cmdline'
])
return
procstat
def
__get_process_stats__
(
self
,
proc
):
"""
...
...
@@ -1227,7 +1225,7 @@ class glancesScreen:
self
.
__colors_list
[
alert
])
except
:
#~ alert = self.__getCpuAlert(percpu[i]['idle'])
logs
.
add
(
alert
,
"CPU-%d idle"
%
i
,
percpu
[
i
][
'idle'
],
proclist
)
#~
logs.add(alert, "CPU-%d idle" % i, percpu[i]['idle'], proclist)
self
.
term_window
.
addnstr
(
self
.
cpu_y
+
3
,
self
.
cpu_x
+
10
+
i
*
10
,
"%.1f"
%
percpu
[
i
][
'idle'
],
8
)
...
...
@@ -1270,11 +1268,10 @@ class glancesScreen:
self
.
__colors_list
[
alert
])
except
:
#~ alert = self.__getCpuAlert(cpu['idle'])
logs
.
add
(
alert
,
"CPU idle"
,
cpu
[
'idle'
],
proclist
)
#~
logs.add(alert, "CPU idle", cpu['idle'], proclist)
self
.
term_window
.
addnstr
(
self
.
cpu_y
+
3
,
self
.
cpu_x
+
10
,
"%.1f"
%
cpu
[
'idle'
],
8
)
# Return the X offset to display Load and Mem
return
offset_x
...
...
@@ -1761,7 +1758,12 @@ class glancesScreen:
# IO
if
tag_io
:
if
processlist
[
processes
][
'io_counters'
]
==
{}:
pass
self
.
term_window
.
addnstr
(
self
.
process_y
+
3
+
processes
,
process_x
+
62
,
_
(
"A_DENY"
),
8
)
self
.
term_window
.
addnstr
(
self
.
process_y
+
3
+
processes
,
process_x
+
72
,
_
(
"A_DENY"
),
8
)
else
:
# Processes are only refresh every 2 refresh_time
#~ elapsed_time = max(1, self.__refresh_time) * 2
...
...
@@ -1812,6 +1814,7 @@ class glancesScreen:
"""
Show the help panel
"""
if
not
self
.
help_tag
:
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
...
...
@@ -1821,11 +1824,17 @@ class glancesScreen:
# Console 80x24 is mandatory to display the help message
self
.
erase
()
self
.
term_window
.
addnstr
(
self
.
help_y
,
self
.
help_x
,
_
(
"Glances {0} with PsUtil {1}"
).
format
(
self
.
__version
,
psutil
.
__version__
),
79
,
self
.
title_color
if
self
.
hascolors
else
0
)
try
:
self
.
term_window
.
addnstr
(
self
.
help_y
,
self
.
help_x
,
_
(
"Glances {0} with PsUtil {1}"
).
format
(
self
.
__version
,
psutil
.
__version__
),
79
,
self
.
title_color
if
self
.
hascolors
else
0
)
except
:
self
.
term_window
.
addnstr
(
self
.
help_y
,
self
.
help_x
,
_
(
"Glances {0}"
).
format
(
self
.
__version
),
79
,
self
.
title_color
if
self
.
hascolors
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
2
,
self
.
help_x
,
_
(
"Captions: "
),
79
)
...
...
@@ -1847,21 +1856,19 @@ class glancesScreen:
self
.
term_window
.
addnstr
(
self
.
help_y
+
5
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"a"
),
_
(
"Sort processes automatically "
"(need PsUtil 0.2.0+)"
),
width
=
width
),
_
(
"a"
),
_
(
"Sort processes automatically"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_get_cpu_percent_tag
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
6
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"b"
),
_
(
"Switch between bit/s or byte/s for network IO
"
),
_
(
"b"
),
_
(
"Switch between bit/s or byte/s for network IO"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_get_cpu_percent_tag
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
7
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"c"
),
_
(
"Sort processes by CPU% "
"(need PsUtil 0.2.0+)"
),
width
=
width
),
_
(
"c"
),
_
(
"Sort processes by CPU%"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_get_cpu_percent_tag
else
0
)
self
.
term_window
.
addnstr
(
...
...
@@ -1875,26 +1882,22 @@ class glancesScreen:
self
.
term_window
.
addnstr
(
self
.
help_y
+
10
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"d"
),
_
(
"Show/hide disk I/O stats "
"(need PsUtil 0.4.0+)"
),
width
=
width
),
_
(
"d"
),
_
(
"Show/hide disk I/O stats"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_disk_io_tag
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
11
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"f"
),
_
(
"Show/hide file system stats "
"(need PsUtil 0.3.0+)"
),
width
=
width
),
_
(
"f"
),
_
(
"Show/hide file system stats"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_fs_usage_tag
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
12
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"n"
),
_
(
"Show/hide network stats "
"(need PsUtil 0.3.0+)"
),
width
=
width
),
_
(
"n"
),
_
(
"Show/hide network stats"
),
width
=
width
),
79
,
self
.
ifCRITICAL_color2
if
not
psutil_network_io_tag
else
0
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
13
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
_
(
"l"
),
_
(
"Show/hide log messages (only available "
"if display > 24 lines)"
),
width
=
width
),
79
)
_
(
"l"
),
_
(
"Show/hide log messages"
),
width
=
width
),
79
)
self
.
term_window
.
addnstr
(
self
.
help_y
+
14
,
self
.
help_x
,
"{0:^{width}} {1}"
.
format
(
...
...
@@ -2119,13 +2122,34 @@ class GlancesInstance():
"""
def
init
(
self
):
# Return the Glances version
return
__version__
def
get
(
self
):
def
get
All
(
self
):
# Update and return all the stats
stats
.
update
()
return
json
.
dumps
(
stats
.
getAll
())
def
getCpu
(
self
):
# Update and return CPU stats
stats
.
update
()
return
json
.
dumps
(
stats
.
getCpu
())
def
getLoad
(
self
):
# Update and return LOAD stats
stats
.
update
()
return
json
.
dumps
(
stats
.
getLoad
())
def
getMem
(
self
):
# Update and return MEM stats
stats
.
update
()
return
json
.
dumps
(
stats
.
getMem
())
def
getMemSwap
(
self
):
# Update and return MEMSWAP stats
stats
.
update
()
return
json
.
dumps
(
stats
.
getMemSwap
())
class
GlancesServer
():
"""
...
...
@@ -2134,7 +2158,7 @@ class GlancesServer():
def
__init__
(
self
,
bind_address
,
bind_port
=
61209
,
RequestHandler
=
GlancesHandler
):
self
.
server
=
SimpleXMLRPCServer
((
bind_address
,
bind_port
),
requestHandler
=
RequestHandler
)
requestHandler
=
RequestHandler
)
self
.
server
.
register_introspection_functions
()
self
.
server
.
register_instance
(
GlancesInstance
())
return
...
...
@@ -2159,7 +2183,7 @@ class GlancesClient():
return
__version__
[:
3
]
==
self
.
client
.
init
()[:
3
]
def
client_get
(
self
):
return
json
.
loads
(
self
.
client
.
get
())
return
json
.
loads
(
self
.
client
.
get
All
())
# Global def
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录