Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
5c4d3eca
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,发现更多精彩内容 >>
提交
5c4d3eca
编写于
2月 11, 2014
作者:
N
Nicolas Hennion
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Manage args between all module
上级
85be3bb6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
94 addition
and
40 deletion
+94
-40
conf/glances-monitor.conf
conf/glances-monitor.conf
+4
-4
glances/__init__.py
glances/__init__.py
+2
-1
glances/core/glances_main.py
glances/core/glances_main.py
+20
-4
glances/core/glances_standalone.py
glances/core/glances_standalone.py
+3
-5
glances/core/glances_stats.py
glances/core/glances_stats.py
+13
-12
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+1
-1
glances/plugins/glances_load.py
glances/plugins/glances_load.py
+1
-1
glances/plugins/glances_mem.py
glances/plugins/glances_mem.py
+1
-1
glances/plugins/glances_memswap.py
glances/plugins/glances_memswap.py
+1
-1
glances/plugins/glances_network.py
glances/plugins/glances_network.py
+43
-5
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+3
-3
glances/plugins/glances_system.py
glances/plugins/glances_system.py
+1
-1
glances/plugins/glances_uptime.py
glances/plugins/glances_uptime.py
+1
-1
未找到文件。
conf/glances-monitor.conf
浏览文件 @
5c4d3eca
...
...
@@ -52,6 +52,10 @@ careful=50
warning
=
70
critical
=
90
[
network
]
# Define the list of hidden network interfaces (comma separeted)
#hide=lo
[
temperature
]
# Temperatures in °C for sensors
# Default values if not defined: 60/70/80
...
...
@@ -89,10 +93,6 @@ mem_critical=90
# Define the list of hidden disks (comma separeted)
#hide=sda2,sda5
[
network
]
# Define the list of hidden network interfaces (comma separeted)
#hide=lo
[
monitor
]
# Define the list of processes to monitor
# *** This section is optional ***
...
...
glances/__init__.py
浏览文件 @
5c4d3eca
...
...
@@ -32,7 +32,8 @@ def main(argv=None):
from
.core.glances_standalone
import
GlancesStandalone
# Init the standalone mode
standalone
=
GlancesStandalone
(
config
=
core
.
config
,
standalone
=
GlancesStandalone
(
config
=
core
.
get_config
(),
args
=
core
.
get_args
(),
refresh_time
=
core
.
refresh_time
,
use_bold
=
core
.
use_bold
)
...
...
glances/core/glances_main.py
浏览文件 @
5c4d3eca
...
...
@@ -78,7 +78,7 @@ class GlancesMain(object):
def
__init__
(
self
):
# Init and manage command line arguments
self
.
init_arg
()
self
.
parse_arg
()
self
.
args
=
self
.
parse_arg
()
# Read the configuration file
if
(
self
.
conf_file_tag
):
...
...
@@ -220,6 +220,7 @@ class GlancesMain(object):
self
.
parser
.
add_argument
(
'-f'
,
'--file'
,
help
=
_
(
'set the html output folder or csv file'
))
def
parse_arg
(
self
):
"""
Parse command line argument
...
...
@@ -227,7 +228,10 @@ class GlancesMain(object):
args
=
self
.
parser
.
parse_args
()
# Change global variables regarding to user args
# Default refresh time is 3 seconds
if
(
args
.
time
is
None
):
args
.
time
=
3
# !!! Change global variables regarding to user args
# !!! To be refactor to use directly the args list in the code
if
(
args
.
time
is
not
None
):
self
.
refresh_time
=
args
.
time
self
.
network_bytepersec_tag
=
args
.
byte
...
...
@@ -263,9 +267,10 @@ class GlancesMain(object):
if
(
args
.
file
is
not
None
):
output_file
=
args
.
file
output_folder
=
args
.
file
# /!!!
return
args
# !!! Debug
# print args
def
__get_password
(
self
,
description
=
''
,
confirm
=
False
):
"""
...
...
@@ -288,26 +293,37 @@ class GlancesMain(object):
sys
.
stdout
.
write
(
_
(
"[Warning] Passwords did not match, please try again...
\n
"
))
return
self
.
__get_password
(
description
=
description
,
confirm
=
confirm
)
def
is_standalone
(
self
):
"""
Return True if Glances is running in standalone mode
"""
return
not
self
.
client_tag
and
not
self
.
server_tag
def
is_client
(
self
):
"""
Return True if Glances is running in client mode
"""
return
self
.
client_tag
and
not
self
.
server_tag
def
is_server
(
self
):
"""
Return True if Glances is running in sserver mode
"""
return
not
self
.
client_tag
and
self
.
server_tag
def
get_config
(
self
):
"""
Return configuration file object
"""
return
self
.
config
def
get_args
(
self
):
"""
Return the arguments
"""
return
self
.
args
\ No newline at end of file
glances/core/glances_standalone.py
浏览文件 @
5c4d3eca
...
...
@@ -37,6 +37,7 @@ class GlancesStandalone():
def
__init__
(
self
,
config
=
None
,
args
=
None
,
refresh_time
=
3
,
use_bold
=
True
):
# Init the limits
...
...
@@ -52,7 +53,7 @@ class GlancesStandalone():
# !!! The first time Glances display wrong CPU information
self
.
stats
.
update
()
self
.
refresh_time
=
refresh_
time
self
.
refresh_time
=
args
.
time
# Init HTML output
# !!! TODO
...
...
@@ -67,10 +68,7 @@ class GlancesStandalone():
# refresh_time=refresh_time)
# Init screen
# !!! TODO
# !!! Is refresh_time mandatory for this class ?
self
.
screen
=
glancesCurses
(
refresh_time
=
refresh_time
,
use_bold
=
use_bold
)
self
.
screen
=
glancesCurses
(
args
=
args
)
def
serve_forever
(
self
):
...
...
glances/core/glances_stats.py
浏览文件 @
5c4d3eca
...
...
@@ -52,7 +52,6 @@ class GlancesStats(object):
Overwrite the getattr in case of attribute is not found
The goal is to dynamicaly generate the following methods:
- getPlugname(): return Plugname stat in JSON format
- cursePlugname(): return Plugname stat in STR (for curses)
"""
# Check if the attribute starts with 'get'
...
...
@@ -67,17 +66,6 @@ class GlancesStats(object):
else
:
# The method get_stats is not found for the plugin
raise
AttributeError
(
item
)
elif
(
item
.
startswith
(
'curse'
)):
# Get the plugin name
plugname
=
item
[
len
(
'curse'
):].
lower
()
# Get the plugin instance
plugin
=
self
.
_plugins
[
plugname
]
if
(
hasattr
(
plugin
,
'get_curse'
)):
# The method get_curse exist, return it
return
getattr
(
plugin
,
'get_curse'
)
else
:
# The method get_curse is not found for the plugin
raise
AttributeError
(
item
)
else
:
# Default behavior
raise
AttributeError
(
item
)
...
...
@@ -130,6 +118,19 @@ class GlancesStats(object):
self
.
__update__
(
input_stats
)
def
get_plugin_list
(
self
):
# Return the plugin list
self
.
_plugins
def
get_plugin
(
self
,
plugin_name
):
# Return the plugin name
if
(
plugin_name
in
self
.
_plugins
):
return
self
.
_plugins
[
plugin_name
]
else
:
return
None
class
GlancesStatsServer
(
GlancesStats
):
def
__init__
(
self
):
...
...
glances/plugins/glances_cpu.py
浏览文件 @
5c4d3eca
...
...
@@ -104,7 +104,7 @@ class Plugin(GlancesPlugin):
return
self
.
stats
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
...
...
glances/plugins/glances_load.py
浏览文件 @
5c4d3eca
...
...
@@ -65,7 +65,7 @@ class Plugin(GlancesPlugin):
return
self
.
stats
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
...
...
glances/plugins/glances_mem.py
浏览文件 @
5c4d3eca
...
...
@@ -101,7 +101,7 @@ class Plugin(GlancesPlugin):
self
.
stats
=
{}
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
...
...
glances/plugins/glances_memswap.py
浏览文件 @
5c4d3eca
...
...
@@ -75,7 +75,7 @@ class Plugin(GlancesPlugin):
self
.
stats
=
{}
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
...
...
glances/plugins/glances_network.py
浏览文件 @
5c4d3eca
...
...
@@ -44,6 +44,15 @@ class Plugin(GlancesPlugin):
def
__init__
(
self
):
GlancesPlugin
.
__init__
(
self
)
# We want to display the stat in the curse interface
self
.
display_curse
=
True
# Set the message position
# It is NOT the curse position but the Glances column/line
# Enter -1 to right align
self
.
column_curse
=
0
# Enter -1 to diplay bottom
self
.
line_curse
=
2
def
update
(
self
):
"""
...
...
@@ -100,8 +109,37 @@ class Plugin(GlancesPlugin):
self
.
stats
=
network
def
get_stats
(
self
):
# Return the stats object for the RPC API
# !!! Sort it by interface name (why do it here ? Better in client side ?)
self
.
stats
=
sorted
(
self
.
stats
,
key
=
lambda
network
:
network
[
'interface_name'
])
return
GlancesPlugin
.
get_stats
(
self
)
def
msg_curse
(
self
,
args
=
None
):
"""
Return the dict to display in the curse interface
"""
# Init the return message
ret
=
[]
# Build the string message
# Header
msg
=
"{0:6}"
.
format
(
_
(
"NETWORK"
))
ret
.
append
(
self
.
curse_add_line
(
msg
,
"TITLE"
))
msg
=
"{0:>7} {1:>7}"
.
format
(
_
(
"Rx/s"
),
_
(
"Tx/s"
))
ret
.
append
(
self
.
curse_add_line
(
msg
))
# Interface list (sorted by name)
for
i
in
sorted
(
self
.
stats
,
key
=
lambda
network
:
network
[
'interface_name'
]):
# Format stats
ifname
=
i
[
'interface_name'
].
split
(
':'
)[
0
]
if
(
args
.
byte
):
rxps
=
self
.
auto_unit
(
int
(
i
[
'rx'
]
//
i
[
'time_since_update'
]))
txps
=
self
.
auto_unit
(
int
(
i
[
'tx'
]
//
i
[
'time_since_update'
]))
else
:
rxps
=
self
.
auto_unit
(
int
(
i
[
'rx'
]
//
i
[
'time_since_update'
]
*
8
))
+
"b"
txps
=
self
.
auto_unit
(
int
(
i
[
'tx'
]
//
i
[
'time_since_update'
]
*
8
))
+
"b"
# !!! TODO: manage the hide tag
# New line
ret
.
append
(
self
.
curse_new_line
())
msg
=
"{0:7}"
.
format
(
ifname
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
msg
=
"{0:>7} {1:>7}"
.
format
(
rxps
,
txps
)
ret
.
append
(
self
.
curse_add_line
(
msg
))
return
ret
glances/plugins/glances_plugin.py
浏览文件 @
5c4d3eca
...
...
@@ -155,14 +155,14 @@ class GlancesPlugin(object):
return
self
.
limits
[
self
.
plugin_name
+
'_'
+
'careful'
]
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
):
"""
Return default string to display in the curse interface
"""
return
[
self
.
curse_add_line
(
str
(
self
.
stats
))
]
def
get_curse
(
self
):
def
get_curse
(
self
,
args
=
None
):
# Return a dict with all the information needed to display the stat
# key | description
#----------------------------
...
...
@@ -183,7 +183,7 @@ class GlancesPlugin(object):
line_curse
=
self
.
line_curse
return
{
'display'
:
display_curse
,
'msgdict'
:
self
.
msg_curse
(),
'msgdict'
:
self
.
msg_curse
(
args
),
'column'
:
column_curse
,
'line'
:
line_curse
}
...
...
glances/plugins/glances_system.py
浏览文件 @
5c4d3eca
...
...
@@ -72,7 +72,7 @@ class Plugin(GlancesPlugin):
self
.
stats
[
'os_version'
]
=
""
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the string to display in the curse interface
"""
...
...
glances/plugins/glances_uptime.py
浏览文件 @
5c4d3eca
...
...
@@ -67,7 +67,7 @@ class Plugin(GlancesPlugin):
self
.
stats
=
str
(
self
.
uptime
).
split
(
'.'
)[
0
]
def
msg_curse
(
self
):
def
msg_curse
(
self
,
args
=
None
):
"""
Return the string to display in the curse interface
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录