Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
598f3c9b
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 搜索 >>
提交
598f3c9b
编写于
11月 02, 2012
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add control when server is down
上级
ac97f1c8
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
16 deletion
+43
-16
glances/glances.py
glances/glances.py
+43
-16
未找到文件。
glances/glances.py
浏览文件 @
598f3c9b
...
...
@@ -406,11 +406,13 @@ class glancesStats:
# Host information
# Only for client
if
(
self
.
client_tag
):
self
.
host
=
input_stats
[
"host"
]
if
input_stats
!=
{}:
self
.
host
=
input_stats
[
"host"
]
# CPU
if
(
self
.
client_tag
):
self
.
cpu
=
input_stats
[
"cpu"
]
if
input_stats
!=
{}:
self
.
cpu
=
input_stats
[
"cpu"
]
else
:
if
not
hasattr
(
self
,
'cputime_old'
):
self
.
cputime_old
=
psutil
.
cpu_times
()
...
...
@@ -465,7 +467,8 @@ class glancesStats:
# PerCPU
if
(
self
.
client_tag
):
self
.
percpu
=
input_stats
[
"percpu"
]
if
input_stats
!=
{}:
self
.
percpu
=
input_stats
[
"percpu"
]
else
:
if
not
hasattr
(
self
,
'percputime_old'
):
self
.
percputime_old
=
psutil
.
cpu_times
(
percpu
=
True
)
...
...
@@ -536,7 +539,8 @@ class glancesStats:
# LOAD
if
(
self
.
client_tag
):
self
.
load
=
input_stats
[
"load"
]
if
input_stats
!=
{}:
self
.
load
=
input_stats
[
"load"
]
else
:
if
hasattr
(
os
,
'getloadavg'
):
getload
=
os
.
getloadavg
()
...
...
@@ -550,8 +554,9 @@ class glancesStats:
# MEM
if
(
self
.
client_tag
):
self
.
mem
=
input_stats
[
"mem"
]
self
.
memswap
=
input_stats
[
"memswap"
]
if
input_stats
!=
{}:
self
.
mem
=
input_stats
[
"mem"
]
self
.
memswap
=
input_stats
[
"memswap"
]
else
:
if
psutil_mem_vm
:
# If PsUtil 0.6+
...
...
@@ -602,7 +607,8 @@ class glancesStats:
# NET
if
(
self
.
client_tag
):
self
.
network
=
input_stats
[
"network"
]
if
input_stats
!=
{}:
self
.
network
=
input_stats
[
"network"
]
else
:
if
psutil_network_io_tag
:
self
.
network
=
[]
...
...
@@ -630,7 +636,8 @@ class glancesStats:
# DISK I/O
if
(
self
.
client_tag
):
self
.
diskio
=
input_stats
[
"diskio"
]
if
input_stats
!=
{}:
self
.
diskio
=
input_stats
[
"diskio"
]
else
:
if
psutil_disk_io_tag
:
self
.
diskio
=
[]
...
...
@@ -660,7 +667,8 @@ class glancesStats:
# FILE SYSTEM
if
(
self
.
client_tag
):
self
.
fs
=
input_stats
[
"fs"
]
if
input_stats
!=
{}:
self
.
fs
=
input_stats
[
"fs"
]
else
:
if
psutil_fs_usage_tag
:
self
.
fs
=
self
.
glancesgrabfs
.
get
()
...
...
@@ -671,8 +679,9 @@ class glancesStats:
# Initialiation of the running processes list
# Data are refreshed every two cycle (refresh_time * 2)
if
(
self
.
client_tag
):
self
.
processcount
=
input_stats
[
"processcount"
]
self
.
process
=
input_stats
[
"process"
]
if
input_stats
!=
{}:
self
.
processcount
=
input_stats
[
"processcount"
]
self
.
process
=
input_stats
[
"process"
]
self
.
process_list_refresh
=
True
else
:
if
self
.
process_list_refresh
:
...
...
@@ -730,7 +739,8 @@ class glancesStats:
# Get the number of core (CPU) (Used to display load alerts)
if
(
self
.
client_tag
):
self
.
core_number
=
input_stats
[
"core_number"
]
if
input_stats
!=
{}:
self
.
core_number
=
input_stats
[
"core_number"
]
else
:
self
.
core_number
=
psutil
.
NUM_CPUS
if
(
self
.
server_tag
):
...
...
@@ -794,6 +804,9 @@ class glancesStats:
Return the sorted process list
"""
if
self
.
process
==
{}:
return
self
.
process
sortedReverse
=
True
if
sortedby
==
'auto'
:
if
psutil_get_cpu_percent_tag
:
...
...
@@ -1816,7 +1829,7 @@ class glancesScreen:
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
(
client_tag
):
msg_client
=
_
(
"Connected to
:
"
)
+
" "
+
format
(
server_ip
)
msg_client
=
_
(
"Connected to"
)
+
" "
+
format
(
server_ip
)
msg_help
=
_
(
"Press 'h' for help"
)
if
(
client_tag
):
if
(
screen_y
>
self
.
caption_y
and
...
...
@@ -2206,14 +2219,28 @@ class GlancesClient():
"""
def
__init__
(
self
,
server_address
,
server_port
=
61209
):
self
.
client
=
xmlrpclib
.
ServerProxy
(
'http://%s:%d'
%
(
server_address
,
server_port
))
try
:
self
.
client
=
xmlrpclib
.
ServerProxy
(
'http://%s:%d'
%
(
server_address
,
server_port
))
except
:
print
_
(
"Error: creating client socket http://%s:%d"
)
%
(
server_address
,
server_port
)
return
def
client_init
(
self
):
return
__version__
[:
3
]
==
self
.
client
.
init
()[:
3
]
try
:
client_version
=
self
.
client
.
init
()[:
3
]
except
:
print
_
(
"Error: Init / Connection to server failed"
)
sys
.
exit
(
-
1
)
else
:
return
__version__
[:
3
]
==
client_version
def
client_get
(
self
):
return
json
.
loads
(
self
.
client
.
getAll
())
try
:
stats
=
json
.
loads
(
self
.
client
.
getAll
())
except
:
return
{}
else
:
return
stats
# Global def
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录