Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
b9a2246e
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 搜索 >>
提交
b9a2246e
编写于
12月 23, 2011
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
version 1.3.3
上级
8a43abdb
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
115 addition
and
44 deletion
+115
-44
NEWS
NEWS
+9
-0
README
README
+3
-3
README-fr
README-fr
+4
-4
README.md
README.md
+3
-3
configure.ac
configure.ac
+1
-1
setup.py
setup.py
+2
-2
src/glances.py
src/glances.py
+93
-31
未找到文件。
NEWS
浏览文件 @
b9a2246e
Version 1.3.3
=============
* Automaticaly swith between process short and long name
* Center the host / system information
* Always put the hour/date in the bottom/right
* Correct a bug if there is a lot of Disk/IO
* Add control about available libstatgrab functions
Version 1.3.2
=============
...
...
README
浏览文件 @
b9a2246e
...
...
@@ -20,12 +20,12 @@ Packages exist for Arch, Fedora, Redhat ...
Get the latest version:
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
2
.tar.gz
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
3
.tar.gz
Glances use a standard GNU style installer:
$ tar zxvf glances-1.3.
2
.tar.gz
$ cd glances-1.3.
2
$ tar zxvf glances-1.3.
3
.tar.gz
$ cd glances-1.3.
3
$ ./configure
$ make
$ sudo make install
...
...
README-fr
浏览文件 @
b9a2246e
...
...
@@ -27,14 +27,14 @@ Le projet Glances est hébergé sur GitHUB: https://github.com/nicolargo/glances
Pour l'installer, il suffit de suivre les instructions suivantes depuis un
terminal.
Récupération de la dernière version (1.3.
2
):
Récupération de la dernière version (1.3.
3
):
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
2
.tar.gz
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
3
.tar.gz
Procédez ensuite à l'installation:
$ tar zxvf glances-1.3.
2
.tar.gz
$ cd glances-1.3.
2
$ tar zxvf glances-1.3.
3
.tar.gz
$ cd glances-1.3.
3
$ ./configure
$ make
$ sudo make install
...
...
README.md
浏览文件 @
b9a2246e
...
...
@@ -20,12 +20,12 @@ Packages exist for Arch, Fedora, Redhat ...
Get the latest version:
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
2
.tar.gz
$ wget https://github.com/downloads/nicolargo/glances/glances-1.3.
3
.tar.gz
Glances use a standard GNU style installer:
$ tar zxvf glances-1.3.
2
.tar.gz
$ cd glances-1.3.
2
$ tar zxvf glances-1.3.
3
.tar.gz
$ cd glances-1.3.
3
$ ./configure
$ make
$ sudo make install
...
...
configure.ac
浏览文件 @
b9a2246e
dnl Process this file with autoconf to produce a configure script.
dnl Created by Anjuta application wizard.
AC_INIT(Glances, 1.3.
2
, , glances)
AC_INIT(Glances, 1.3.
3
, , glances)
AC_CONFIG_HEADERS([config.h])
...
...
setup.py
浏览文件 @
b9a2246e
...
...
@@ -11,8 +11,8 @@ def read(fname):
return
open
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
fname
)).
read
()
setup
(
name
=
'Glances'
,
version
=
'1.3.
2
'
,
download_url
=
'https://github.com/downloads/nicolargo/glances/glances-1.3.
2
.tar.gz'
,
version
=
'1.3.
3
'
,
download_url
=
'https://github.com/downloads/nicolargo/glances/glances-1.3.
3
.tar.gz'
,
url
=
'https://github.com/nicolargo/glances'
,
description
=
'CLI curses-based monitoring tool'
,
author
=
'Nicolas Hennion'
,
...
...
src/glances.py
浏览文件 @
b9a2246e
...
...
@@ -34,7 +34,7 @@ import multiprocessing
#==================
# The glances version id
__version__
=
"1.3.
2
"
__version__
=
"1.3.
3
"
# Class
#======
...
...
@@ -136,20 +136,54 @@ class glancesStats():
"""
# Get informations from libstatgrab and others...
self
.
host
=
statgrab
.
sg_get_host_info
()
# TODO: platform.platform(True) instead of statgrab.sg_get_host_info()
self
.
system
=
statgrab
.
sg_get_host_info
()
self
.
cpu
=
statgrab
.
sg_get_cpu_percents
()
self
.
load
=
statgrab
.
sg_get_load_stats
()
self
.
mem
=
statgrab
.
sg_get_mem_stats
()
self
.
memswap
=
statgrab
.
sg_get_swap_stats
()
self
.
networkinterface
=
statgrab
.
sg_get_network_iface_stats
()
self
.
network
=
statgrab
.
sg_get_network_io_stats_diff
()
self
.
diskio
=
statgrab
.
sg_get_disk_io_stats_diff
()
# Replace the bugged self.fs = statgrab.sg_get_fs_stats()
self
.
fs
=
self
.
glancesgrabfs
.
get
()
self
.
processcount
=
statgrab
.
sg_get_process_count
()
self
.
process
=
statgrab
.
sg_get_process_stats
()
try
:
self
.
host
=
statgrab
.
sg_get_host_info
()
except
:
self
.
host
=
{}
self
.
system
=
self
.
host
try
:
self
.
cpu
=
statgrab
.
sg_get_cpu_percents
()
except
:
self
.
cpu
=
{}
try
:
self
.
load
=
statgrab
.
sg_get_load_stats
()
except
:
self
.
load
=
{}
try
:
self
.
mem
=
statgrab
.
sg_get_mem_stats
()
except
:
self
.
mem
=
{}
try
:
self
.
memswap
=
statgrab
.
sg_get_swap_stats
()
except
:
self
.
memswap
=
{}
try
:
self
.
networkinterface
=
statgrab
.
sg_get_network_iface_stats
()
except
:
self
.
networkinterface
=
{}
try
:
self
.
network
=
statgrab
.
sg_get_network_io_stats_diff
()
except
:
self
.
network
=
{}
try
:
self
.
diskio
=
statgrab
.
sg_get_disk_io_stats_diff
()
except
:
self
.
diskio
=
{}
try
:
self
.
fs
=
statgrab
.
sg_get_fs_stats
()
except
:
# Replace the bugged self.fs = statgrab.sg_get_fs_stats()
self
.
fs
=
self
.
glancesgrabfs
.
get
()
try
:
self
.
processcount
=
statgrab
.
sg_get_process_count
()
except
:
self
.
processcount
=
{}
try
:
self
.
process
=
statgrab
.
sg_get_process_stats
()
except
:
self
.
process
=
{}
# Get the current date/time
self
.
now
=
datetime
.
datetime
.
now
()
# Get the number of core (CPU)
...
...
@@ -428,9 +462,9 @@ class glancesScreen():
screen
.
displayCpu
(
stats
.
getCpu
())
screen
.
displayLoad
(
stats
.
getLoad
(),
stats
.
getCore
())
screen
.
displayMem
(
stats
.
getMem
(),
stats
.
getMemSwap
())
net_count
=
screen
.
displayNetwork
(
stats
.
getNetwork
(),
stats
.
getNetworkInterface
())
disk
_count
=
screen
.
displayDiskIO
(
stats
.
getDiskIO
(),
net_count
)
screen
.
displayFs
(
stats
.
getFs
(),
net_count
+
disk_count
)
net
work
_count
=
screen
.
displayNetwork
(
stats
.
getNetwork
(),
stats
.
getNetworkInterface
())
disk
io_count
=
screen
.
displayDiskIO
(
stats
.
getDiskIO
(),
self
.
network_y
+
network_count
+
3
)
screen
.
displayFs
(
stats
.
getFs
(),
self
.
network_y
+
network_count
+
diskio_count
+
6
)
screen
.
displayProcess
(
stats
.
getProcessCount
(),
stats
.
getProcessList
(
screen
.
getProcessSortedBy
()))
screen
.
displayCaption
()
screen
.
displayNow
(
stats
.
getNow
())
...
...
@@ -462,26 +496,32 @@ class glancesScreen():
def
displayHost
(
self
,
host
):
# Host information
if
(
not
host
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
host_y
)
and
(
screen_x
>
self
.
host_x
+
79
)):
host_msg
=
"Glances v"
+
self
.
__version
+
" running on "
+
host
[
'hostname'
]
#+" "+str(pressed_key)
self
.
term_window
.
addnstr
(
self
.
host_y
,
self
.
host_x
+
40
-
len
(
host_msg
)
/
2
,
host_msg
,
80
,
self
.
title_color
if
self
.
hascolors
else
0
)
self
.
term_window
.
addnstr
(
self
.
host_y
,
self
.
host_x
+
int
(
screen_x
/
2
)
-
len
(
host_msg
)
/
2
,
host_msg
,
80
,
self
.
title_color
if
self
.
hascolors
else
0
)
def
displaySystem
(
self
,
system
):
# System information
if
(
not
system
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
system_y
)
and
(
screen_x
>
self
.
system_x
+
79
)):
system_msg
=
system
[
'os_name'
]
+
" "
+
system
[
'platform'
]
+
" "
+
system
[
'os_version'
]
self
.
term_window
.
addnstr
(
self
.
system_y
,
self
.
system_x
+
40
-
len
(
system_msg
)
/
2
,
system_msg
,
80
)
self
.
term_window
.
addnstr
(
self
.
system_y
,
self
.
system_x
+
int
(
screen_x
/
2
)
-
len
(
system_msg
)
/
2
,
system_msg
,
80
)
def
displayCpu
(
self
,
cpu
):
# CPU %
if
(
not
cpu
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
cpu_y
+
6
)
...
...
@@ -500,6 +540,8 @@ class glancesScreen():
def
displayLoad
(
self
,
load
,
core
):
# Load %
if
(
not
load
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
load_y
+
5
)
...
...
@@ -516,6 +558,8 @@ class glancesScreen():
def
displayMem
(
self
,
mem
,
memswap
):
# MEM
if
(
not
mem
or
not
memswap
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
mem_y
+
5
)
...
...
@@ -544,9 +588,11 @@ class glancesScreen():
Return the number of interfaces
"""
# Network interfaces bitrate
if
(
not
network
or
not
networkinterface
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
network_y
+
3
)
if
((
screen_y
>
self
.
network_y
+
len
(
network
)
+
2
)
and
(
screen_x
>
self
.
network_x
+
28
)):
# Get the speed of the network interface
# TODO: optimize...
...
...
@@ -562,7 +608,7 @@ class glancesScreen():
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
10
,
"Rx/ps"
,
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
20
,
"Tx/ps"
,
8
)
# Adapt the maximum interface to the screen
for
i
in
range
(
0
,
min
(
6
+
(
screen_y
-
self
.
term_h
)
/
3
,
len
(
network
))):
for
i
in
range
(
0
,
min
(
screen_y
-
self
.
network_y
-
3
,
len
(
network
))):
elapsed_time
=
max
(
1
,
network
[
i
][
'systime'
])
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
i
,
self
.
network_x
,
network
[
i
][
'interface_name'
]
+
':'
,
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
i
,
self
.
network_x
+
10
,
self
.
__autoUnit
(
network
[
i
][
'rx'
]
/
elapsed_time
*
8
)
+
"b"
,
8
,
self
.
__getColor
(
network
[
i
][
'rx'
]
/
elapsed_time
*
8
,
speed
[
network
[
i
][
'interface_name'
]]))
...
...
@@ -573,17 +619,19 @@ class glancesScreen():
def
displayDiskIO
(
self
,
diskio
,
offset_y
=
0
):
# Disk input/output rate
if
(
not
diskio
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
self
.
diskio_y
=
offset_y
+
12
if
((
screen_y
>
self
.
diskio_y
+
3
)
self
.
diskio_y
=
offset_y
if
((
screen_y
>
self
.
diskio_y
+
len
(
diskio
)
+
2
)
and
(
screen_x
>
self
.
diskio_x
+
28
)):
self
.
term_window
.
addnstr
(
self
.
diskio_y
,
self
.
diskio_x
,
"Disk I/O"
,
8
,
self
.
title_color
if
self
.
hascolors
else
curses
.
A_UNDERLINE
)
self
.
term_window
.
addnstr
(
self
.
diskio_y
,
self
.
diskio_x
+
10
,
"In/ps"
,
8
)
self
.
term_window
.
addnstr
(
self
.
diskio_y
,
self
.
diskio_x
+
20
,
"Out/ps"
,
8
)
# Adapt the maximum disk to the screen
disk
=
0
for
disk
in
range
(
0
,
min
(
int
(
8
+
(
screen_y
-
self
.
term_h
)
/
3
)
,
len
(
diskio
))):
for
disk
in
range
(
0
,
min
(
screen_y
-
self
.
diskio_y
-
3
,
len
(
diskio
))):
elapsed_time
=
max
(
1
,
diskio
[
disk
][
'systime'
])
self
.
term_window
.
addnstr
(
self
.
diskio_y
+
1
+
disk
,
self
.
diskio_x
,
diskio
[
disk
][
'disk_name'
]
+
':'
,
8
)
self
.
term_window
.
addnstr
(
self
.
diskio_y
+
1
+
disk
,
self
.
diskio_x
+
10
,
self
.
__autoUnit
(
diskio
[
disk
][
'write_bytes'
]
/
elapsed_time
)
+
"B"
,
8
)
...
...
@@ -594,25 +642,30 @@ class glancesScreen():
def
displayFs
(
self
,
fs
,
offset_y
=
0
):
# Filesystem stats
if
(
not
fs
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
self
.
fs_y
=
offset_y
+
15
if
((
screen_y
>
self
.
fs_y
+
5
)
self
.
fs_y
=
offset_y
if
((
screen_y
>
self
.
fs_y
+
len
(
fs
)
+
2
)
and
(
screen_x
>
self
.
fs_x
+
28
)):
self
.
term_window
.
addnstr
(
self
.
fs_y
,
self
.
fs_x
,
"Mount"
,
8
,
self
.
title_color
if
self
.
hascolors
else
curses
.
A_UNDERLINE
)
self
.
term_window
.
addnstr
(
self
.
fs_y
,
self
.
fs_x
+
10
,
"Total"
,
8
)
self
.
term_window
.
addnstr
(
self
.
fs_y
,
self
.
fs_x
+
20
,
"Used"
,
8
)
# Adapt the maximum disk to the screen
mounted
=
0
for
mounted
in
range
(
0
,
min
(
int
(
8
+
(
screen_y
-
self
.
term_h
)
/
3
)
,
len
(
fs
))):
for
mounted
in
range
(
0
,
min
(
screen_y
-
self
.
fs_y
-
3
,
len
(
fs
))):
self
.
term_window
.
addnstr
(
self
.
fs_y
+
1
+
mounted
,
self
.
fs_x
,
fs
[
mounted
][
'mnt_point'
],
8
)
self
.
term_window
.
addnstr
(
self
.
fs_y
+
1
+
mounted
,
self
.
fs_x
+
10
,
self
.
__autoUnit
(
fs
[
mounted
][
'size'
]),
8
)
self
.
term_window
.
addnstr
(
self
.
fs_y
+
1
+
mounted
,
self
.
fs_x
+
20
,
self
.
__autoUnit
(
fs
[
mounted
][
'used'
]),
8
,
self
.
__getColor
(
fs
[
mounted
][
'used'
],
fs
[
mounted
][
'size'
]))
return
mounted
return
0
def
displayProcess
(
self
,
processcount
,
processlist
):
# Process
if
(
not
processcount
or
not
processlist
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
process_y
+
3
)
...
...
@@ -643,11 +696,18 @@ class glancesScreen():
self
.
term_window
.
addnstr
(
self
.
process_y
+
3
,
self
.
process_x
+
10
,
"Size MB"
+
sortchar
,
8
)
self
.
term_window
.
addnstr
(
self
.
process_y
+
3
,
self
.
process_x
+
20
,
"Res MB"
,
8
)
self
.
term_window
.
addnstr
(
self
.
process_y
+
3
,
self
.
process_x
+
30
,
"Name"
,
8
)
for
processes
in
range
(
0
,
min
(
9
+
(
screen_y
-
self
.
term_h
)
,
len
(
processlist
))):
for
processes
in
range
(
0
,
min
(
screen_y
-
self
.
term_h
+
self
.
process_y
,
len
(
processlist
))):
self
.
term_window
.
addnstr
(
self
.
process_y
+
4
+
processes
,
self
.
process_x
,
"%.1f"
%
processlist
[
processes
][
'cpu_percent'
],
8
,
self
.
__getColor
(
processlist
[
processes
][
'cpu_percent'
]))
self
.
term_window
.
addnstr
(
self
.
process_y
+
4
+
processes
,
self
.
process_x
+
10
,
str
((
processlist
[
processes
][
'proc_size'
])
/
1048576
),
8
)
self
.
term_window
.
addnstr
(
self
.
process_y
+
4
+
processes
,
self
.
process_x
+
20
,
str
((
processlist
[
processes
][
'proc_resident'
])
/
1048576
),
8
)
self
.
term_window
.
addnstr
(
self
.
process_y
+
4
+
processes
,
self
.
process_x
+
30
,
processlist
[
processes
][
'process_name'
],
20
+
(
screen_x
-
self
.
process_x
))
maxprocessname
=
screen_x
-
self
.
process_x
-
30
# If screen space is available then display long name
if
((
len
(
processlist
[
processes
][
'proctitle'
])
>
maxprocessname
)
or
(
len
(
processlist
[
processes
][
'proctitle'
])
==
0
)):
processname
=
processlist
[
processes
][
'process_name'
]
else
:
processname
=
processlist
[
processes
][
'proctitle'
]
self
.
term_window
.
addnstr
(
self
.
process_y
+
4
+
processes
,
self
.
process_x
+
30
,
processname
,
maxprocessname
)
def
displayCaption
(
self
):
...
...
@@ -664,12 +724,14 @@ class glancesScreen():
def
displayNow
(
self
,
now
):
# Display the current date and time (now...) - Center
if
(
not
now
):
return
0
screen_x
=
self
.
screen
.
getmaxyx
()[
1
]
screen_y
=
self
.
screen
.
getmaxyx
()[
0
]
if
((
screen_y
>
self
.
now_y
)
and
(
screen_x
>
self
.
now_x
)):
now_msg
=
now
.
strftime
(
"%Y-%m-%d %H:%M:%S"
)
self
.
term_window
.
addnstr
(
max
(
self
.
now_y
,
screen_y
-
1
),
self
.
now_x
-
len
(
now_msg
),
now_msg
,
len
(
now_msg
))
self
.
term_window
.
addnstr
(
max
(
self
.
now_y
,
screen_y
-
1
),
max
(
self
.
now_x
,
screen_x
-
1
)
-
len
(
now_msg
),
now_msg
,
len
(
now_msg
))
# Global def
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录