Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
ce89d5f4
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 搜索 >>
提交
ce89d5f4
编写于
1月 02, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add system uptime and redesign system information
上级
e57f9c96
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
59 addition
and
16 deletion
+59
-16
NEWS
NEWS
+1
-0
docs/glances-doc.rst
docs/glances-doc.rst
+4
-4
glances/glances.py
glances/glances.py
+54
-12
未找到文件。
NEWS
浏览文件 @
ce89d5f4
Version 1.7.4
=============
* Add system uptime (#276)
* You can hide disk from the IOdisk view using the conf file
* You can hide network interface from the Network view using the conf file
* ...
...
...
docs/glances-doc.rst
浏览文件 @
ce89d5f4
...
...
@@ -2,11 +2,11 @@
Glances
=======
This manual describes *Glances* version 1.7.
3
.
This manual describes *Glances* version 1.7.
4
.
Copyright © 2012-201
3
Nicolas Hennion <nicolas@nicolargo.com>
Copyright © 2012-201
4
Nicolas Hennion <nicolas@nicolargo.com>
November 2013
January 2014
.. contents:: Table of Contents
...
...
@@ -202,7 +202,7 @@ Header
.. image:: images/header.png
The header shows the
OS name, release version, platform architecture and the hostna
me.
The header shows the
hostname, OS name, release version, platform architecture and system upti
me.
On Linux, it shows also the kernel version.
CPU
...
...
glances/glances.py
浏览文件 @
ce89d5f4
...
...
@@ -1698,6 +1698,15 @@ class GlancesStats:
self
.
processcount
=
processcount
self
.
process
=
process
# Uptime
try
:
# For PsUtil >= 0.7.0
self
.
uptime
=
datetime
.
now
()
-
datetime
.
fromtimestamp
(
psutil
.
get_boot_time
())
except
:
self
.
uptime
=
datetime
.
now
()
-
datetime
.
fromtimestamp
(
psutil
.
BOOT_TIME
)
# Convert uptime to string (because datetime is not JSONifi)
self
.
uptime
=
str
(
self
.
uptime
).
split
(
'.'
)[
0
]
# Get the current date/time
self
.
now
=
datetime
.
now
()
...
...
@@ -1835,6 +1844,9 @@ class GlancesStats:
def
getNow
(
self
):
return
self
.
now
def
getUptime
(
self
):
return
self
.
uptime
class
GlancesStatsServer
(
GlancesStats
):
...
...
@@ -1868,6 +1880,7 @@ class GlancesStatsServer(GlancesStats):
self
.
all_stats
[
"process"
]
=
self
.
process
if
process_tag
else
[]
self
.
all_stats
[
"core_number"
]
=
self
.
core_number
self
.
all_stats
[
"psutil_version"
]
=
self
.
psutil_version
self
.
all_stats
[
"uptime"
]
=
self
.
uptime
# Get the current date/time
self
.
now
=
datetime
.
now
()
...
...
@@ -1920,6 +1933,10 @@ class GlancesStatsClient(GlancesStats):
self
.
process
=
input_stats
[
"process"
]
self
.
core_number
=
input_stats
[
"core_number"
]
self
.
psutil_version
=
input_stats
[
"psutil_version"
]
try
:
self
.
uptime
=
input_stats
[
"uptime"
]
except
Exception
:
self
.
uptime
=
None
# Get the current date/time
self
.
now
=
datetime
.
now
()
...
...
@@ -1943,6 +1960,8 @@ class glancesScreen:
self
.
term_h
=
24
self
.
system_x
=
0
self
.
system_y
=
0
self
.
uptime_x
=
79
self
.
uptime_y
=
0
self
.
cpu_x
=
0
self
.
cpu_y
=
2
self
.
load_x
=
17
...
...
@@ -2469,7 +2488,7 @@ class glancesScreen:
if
not
self
.
help_tag
:
# Display stats
self
.
displaySystem
(
stats
.
getHost
(),
stats
.
getSystem
())
self
.
displaySystem
(
stats
.
getHost
(),
stats
.
getSystem
()
,
stats
.
getUptime
()
)
cpu_offset
=
self
.
displayCpu
(
stats
.
getCpu
(),
stats
.
getPerCpu
(),
processlist
)
self
.
displayLoad
(
stats
.
getLoad
(),
stats
.
getCore
(),
processlist
,
cpu_offset
)
self
.
displayMem
(
stats
.
getMem
(),
stats
.
getMemSwap
(),
processlist
,
cpu_offset
)
...
...
@@ -2529,26 +2548,44 @@ class glancesScreen:
# Wait 100ms...
curses
.
napms
(
100
)
def
displaySystem
(
self
,
host
,
system
):
def
displaySystem
(
self
,
host
,
system
,
uptime
):
# System information
if
not
host
or
not
system
:
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
# Host + OS informations
if
host
[
'os_name'
]
==
"Linux"
:
system_msg
=
_
(
"{0} {1} with {2} {3} on {4}"
).
format
(
system_msg
=
_
(
"{0} ({1} {2} / {3} {4})"
).
format
(
host
[
'hostname'
],
system
[
'linux_distro'
],
system
[
'platform'
],
system
[
'os_name'
],
system
[
'os_version'
],
host
[
'hostname'
])
system
[
'os_name'
],
system
[
'os_version'
])
else
:
system_msg
=
_
(
"{0} {1} {2} on {3}"
).
format
(
system_msg
=
_
(
"{0} ({1} {2} {3})"
).
format
(
host
[
'hostname'
],
system
[
'os_name'
],
system
[
'os_version'
],
system
[
'platform'
],
host
[
'hostname'
])
if
(
screen_y
>
self
.
system_y
and
screen_x
>
self
.
system_x
+
len
(
system_msg
)):
center
=
(
screen_x
//
2
)
-
len
(
system_msg
)
//
2
self
.
term_window
.
addnstr
(
self
.
system_y
,
self
.
system_x
+
center
,
system_msg
,
80
,
curses
.
A_UNDERLINE
)
system
[
'platform'
])
# System uptime
if
uptime
:
uptime_msg
=
_
(
"Uptime: {0}"
).
format
(
uptime
)
else
:
uptime_msg
=
""
# Display
if
(
screen_y
>
self
.
system_y
):
if
(
screen_x
>
self
.
system_x
+
len
(
system_msg
)
+
len
(
uptime_msg
)):
center
=
((
screen_x
-
len
(
uptime_msg
))
//
2
)
-
len
(
system_msg
)
//
2
self
.
term_window
.
addnstr
(
self
.
system_y
,
self
.
system_x
+
center
,
system_msg
,
80
,
curses
.
A_UNDERLINE
)
self
.
term_window
.
addnstr
(
self
.
uptime_y
,
screen_x
-
len
(
uptime_msg
),
uptime_msg
,
80
)
return
len
(
system_msg
)
+
len
(
uptime_msg
)
elif
(
screen_x
>
self
.
system_x
+
len
(
system_msg
)):
center
=
(
screen_x
//
2
)
-
len
(
system_msg
)
//
2
self
.
term_window
.
addnstr
(
self
.
system_y
,
self
.
system_x
+
center
,
system_msg
,
80
,
curses
.
A_UNDERLINE
)
return
len
(
system_msg
)
else
:
return
0
def
displayCpu
(
self
,
cpu
,
percpu
,
proclist
):
# Get screen size
...
...
@@ -4223,6 +4260,11 @@ class GlancesInstance():
self
.
__update__
()
return
json
.
dumps
(
stats
.
getNow
().
strftime
(
_
(
"%Y-%m-%d %H:%M:%S"
)))
def
getUptime
(
self
):
# Update and return system uptime
self
.
__update__
()
return
json
.
dumps
(
stats
.
getUptime
().
strftime
(
_
(
"%Y-%m-%d %H:%M:%S"
)))
def
__getTimeSinceLastUpdate
(
self
,
IOType
):
assert
(
IOType
in
[
'net'
,
'disk'
,
'process_disk'
])
return
getTimeSinceLastUpdate
(
IOType
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录