Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
2e0968e3
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,发现更多精彩内容 >>
提交
2e0968e3
编写于
12月 05, 2011
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add caption
上级
f0f484ed
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
62 addition
and
104 deletion
+62
-104
NEWS
NEWS
+3
-0
README
README
+0
-83
README.md
README.md
+14
-9
src/glances.py
src/glances.py
+45
-12
未找到文件。
NEWS
浏览文件 @
2e0968e3
Version 1.1
===========
* Add disk IO monitoring
* Add caption
* Correct a bug when computing the bitrate with the option -t
* Catch CTRL-C before init the screen (Bug #2)
* Check if mem.total = 0 before division (Bug #1)
README
已删除
100644 → 0
浏览文件 @
f0f484ed
Glances -- Eye on your system
=============================
## Description
Glances is a CLI curses based monitoring tools for both GNU/Linux and BSD.
Glances uses the libstatgrab library to get informations from your system.
Glances is developped in Python and uses the python-statgrab lib.
![screenshot](https://github.com/nicolargo/glances/raw/master/screenshot.png)
## Installation
Glances use a standard GNU style installer:
$ tar zxvf glances-v1.0.tar.gz
$ cd glances
$ ./configure
$ make
$ sudo make install
Pre-requisites:
* Python 2.6+ (not tested with Python 3)
* python-statgrab 0.5+ (did not work with python-statgrab 0.5)
Notes: The Debian Squeeze repos only include the python-statgrab 0.4.
You had to install the version 0.5 using the following commands:
$ sudo apt-get install libstatgrab-dev
$ wget http://ftp.uk.i-scream.org/sites/ftp.i-scream.org/pub/i-scream/pystatgrab/pystatgrab-0.5.tar.gz
$ tar zxvf pystatgrab-0.5.tar.gz
$ cd pystatgrab-0.5/
$ ./setup.py build
$ sudo ./setup.py install
## Running
Easy:
$ glances.py
## User guide
By default, stats are refrsh every second, to change this setting, you can
use the -t option. For exemple to set the refrech rate to 5 seconds:
$ glances.py -t 5
Importants stats are colored:
* GREEN: stat counter is < 50%
* BLUE: stat counter is > 50% and < 70%
* MAGENTA: stat counter is > 70% and < 90%
* RED: stat counter is > 90%
When Glances is running, you can press:
* 'a' to set the automatic mode. The process list is sorted automatically
If CPU > 70%, sort by process CPU consomption
If MEM > 70%, sort by process size
* 'c' the processes list is sorted by CPU consomption
* 'm' the processes list is sorted by process size
* 'q' Exit
## Limitation
The current version of the python-statgrab API can not retrieve the file
system statistics.
https://bugs.launchpad.net/ubuntu/+source/libstatgrab/+bug/886783
## Todo
You are welcome to contribute to this software.
* Packaging for Debian, Ubuntu, Fedora, Redhat, BSD...
* Check the needed Python library in the configure.ac
* Add file system stats when the python-statgrab is corrected
* Add a user guide window
README.md
浏览文件 @
2e0968e3
...
...
@@ -8,7 +8,7 @@ Glances is a CLI curses based monitoring tools for both GNU/Linux and BSD.
Glances uses the libstatgrab library to get informations from your system.
Glances is developped in Python and uses the python-statgrab lib.
[
screenshot
](
https://github.com/nicolargo/glances/raw/master/screenshot.png
)
!
[
screenshot
](
https://github.com/nicolargo/glances/raw/master/screenshot.png
)
## Installation
...
...
@@ -21,6 +21,7 @@ Glances use a standard GNU style installer:
$ sudo make install
Pre-requisites:
*
Python 2.6+ (not tested with Python 3)
*
python-statgrab 0.5+ (did not work with python-statgrab 0.5)
...
...
@@ -48,19 +49,23 @@ use the -t option. For exemple to set the refrech rate to 5 seconds:
$ glances.py -t 5
Importants stats are colored:
GREEN: stat counter is < 50%
BLUE: stat counter is > 50% and < 70%
MAGENTA: stat counter is > 70% and < 90%
RED: stat counter is > 90%
*
GREEN: stat counter is < 50%
*
BLUE: stat counter is > 50% and < 70%
*
MAGENTA: stat counter is > 70% and < 90%
*
RED: stat counter is > 90%
When Glances is running, you can press:
'a' to set the automatic mode. The process list is sorted automatically
*
'a' to set the automatic mode. The process list is sorted automatically
If CPU > 70%, sort by process CPU consomption
If MEM > 70%, sort by process size
'c' the processes list is sorted by CPU consomption
'm' the processes list is sorted by process size
'q' Exit
*
'c' the processes list is sorted by CPU consomption
*
'm' the processes list is sorted by process size
*
'q' Exit
## Limitation
...
...
src/glances.py
浏览文件 @
2e0968e3
...
...
@@ -67,10 +67,11 @@ class glancesStats():
self
.
mem
=
statgrab
.
sg_get_mem_stats
()
self
.
memswap
=
statgrab
.
sg_get_swap_stats
()
self
.
network
=
statgrab
.
sg_get_network_io_stats_diff
()
self
.
processcount
=
statgrab
.
sg_get_process_count
()
self
.
process
=
statgrab
.
sg_get_process_stats
()
self
.
diskio
=
statgrab
.
sg_get_disk_io_stats_diff
()
# BUG: https://bugs.launchpad.net/ubuntu/+source/libstatgrab/+bug/886783
# TODO: self.fs = statgrab.sg_get_fs_stats()
self
.
processcount
=
statgrab
.
sg_get_process_count
()
self
.
process
=
statgrab
.
sg_get_process_stats
()
self
.
now
=
datetime
.
datetime
.
now
()
...
...
@@ -112,6 +113,10 @@ class glancesStats():
return
self
.
network
def
getDiskIO
(
self
):
return
self
.
diskio
def
getProcessCount
(
self
):
return
self
.
processcount
...
...
@@ -157,8 +162,10 @@ class glancesScreen():
self
.
load_x
=
20
;
self
.
load_y
=
3
self
.
mem_x
=
41
;
self
.
mem_y
=
3
self
.
network_x
=
0
;
self
.
network_y
=
9
self
.
process_x
=
30
;
self
.
process_y
=
9
self
.
now_x
=
0
;
self
.
now_y
=
23
self
.
diskio_x
=
0
;
self
.
diskio_y
=
16
self
.
process_x
=
30
;
self
.
process_y
=
9
self
.
now_x
=
79
;
self
.
now_y
=
23
# Align right
self
.
caption_x
=
0
;
self
.
caption_y
=
23
# Init the curses screen
self
.
screen
=
curses
.
initscr
()
...
...
@@ -345,13 +352,29 @@ class glancesScreen():
def
displayNetwork
(
self
,
network
):
# Network interfaces bitrate
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
,
"Net Kbps"
,
8
,
self
.
title_color
if
self
.
hascolors
else
curses
.
A_UNDERLINE
)
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
10
,
"Rx"
,
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
20
,
"Tx"
,
8
)
for
interface
in
range
(
0
,
len
(
network
)):
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
,
"Net rate"
,
8
,
self
.
title_color
if
self
.
hascolors
else
curses
.
A_UNDERLINE
)
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
10
,
"Rx Kbps"
,
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
,
self
.
network_x
+
20
,
"Tx Kbps"
,
8
)
# A maximum of 5 interfaces could be monitored
for
interface
in
range
(
0
,
min
(
4
,
len
(
network
))):
elapsed_time
=
max
(
1
,
network
[
interface
][
'systime'
])
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
interface
,
self
.
network_x
,
network
[
interface
][
'interface_name'
]
+
':'
,
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
interface
,
self
.
network_x
+
10
,
str
(
network
[
interface
][
'rx'
]
/
1000
),
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
interface
,
self
.
network_x
+
20
,
str
(
network
[
interface
][
'tx'
]
/
1000
),
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
interface
,
self
.
network_x
+
10
,
str
(
network
[
interface
][
'rx'
]
/
elapsed_time
/
1000
),
8
)
self
.
term_window
.
addnstr
(
self
.
network_y
+
1
+
interface
,
self
.
network_x
+
20
,
str
(
network
[
interface
][
'tx'
]
/
elapsed_time
/
1000
),
8
)
def
displayDiskIO
(
self
,
diskio
):
# Disk input/output rate
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 KBps"
,
8
)
self
.
term_window
.
addnstr
(
self
.
diskio_y
,
self
.
diskio_x
+
20
,
"Out KBps"
,
8
)
# A maximum of 5 disks could be monitored
for
disk
in
range
(
0
,
min
(
4
,
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
,
str
(
diskio
[
disk
][
'read_bytes'
]
/
elapsed_time
/
1000
),
8
)
self
.
term_window
.
addnstr
(
self
.
diskio_y
+
1
+
disk
,
self
.
diskio_x
+
20
,
str
(
diskio
[
disk
][
'write_bytes'
]
/
elapsed_time
/
1000
),
8
)
def
displayProcess
(
self
,
processcount
,
processlist
):
# Process
...
...
@@ -384,11 +407,19 @@ class glancesScreen():
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
)
def
displayCaption
(
self
):
# Caption
self
.
term_window
.
addnstr
(
self
.
caption_y
,
self
.
caption_x
,
"<50%"
,
4
,
self
.
default_color
)
self
.
term_window
.
addnstr
(
self
.
caption_y
,
self
.
caption_x
+
4
,
">50%"
,
4
,
self
.
if50pc_color
)
self
.
term_window
.
addnstr
(
self
.
caption_y
,
self
.
caption_x
+
8
,
">70%"
,
4
,
self
.
if70pc_color
)
self
.
term_window
.
addnstr
(
self
.
caption_y
,
self
.
caption_x
+
12
,
">90%"
,
4
,
self
.
if90pc_color
)
def
displayNow
(
self
,
now
):
# Display the current date and time (now...)
# Display the current date and time (now...)
- Center
now_msg
=
now
.
strftime
(
"%Y-%m-%d %H:%M:%S"
)
self
.
term_window
.
addnstr
(
self
.
now_y
,
self
.
now_x
+
40
-
len
(
now_msg
)
/
2
,
now_msg
,
80
)
self
.
term_window
.
addnstr
(
self
.
now_y
,
self
.
now_x
-
len
(
now_msg
),
now_msg
,
len
(
now_msg
)
)
# Global def
...
...
@@ -464,7 +495,9 @@ def main():
screen
.
displayLoad
(
stats
.
getLoad
())
screen
.
displayMem
(
stats
.
getMem
(),
stats
.
getMemSwap
())
screen
.
displayNetwork
(
stats
.
getNetwork
())
screen
.
displayDiskIO
(
stats
.
getDiskIO
())
screen
.
displayProcess
(
stats
.
getProcessCount
(),
stats
.
getProcessList
(
screen
.
getProcessSortedBy
()))
screen
.
displayCaption
()
screen
.
displayNow
(
stats
.
getNow
())
# Update and sleep... bzzz... bzzz...
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录