Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
deaa17a7
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 搜索 >>
提交
deaa17a7
编写于
12月 18, 2016
作者:
A
Alessio Sergi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use str.format() automatic numbering
We don't support Python 2.6 any longer.
上级
781dfeef
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
26 addition
and
27 deletion
+26
-27
glances/exports/glances_cassandra.py
glances/exports/glances_cassandra.py
+2
-3
glances/main.py
glances/main.py
+3
-3
glances/outputs/glances_curses.py
glances/outputs/glances_curses.py
+2
-2
glances/plugins/glances_docker.py
glances/plugins/glances_docker.py
+5
-5
glances/plugins/glances_help.py
glances/plugins/glances_help.py
+3
-3
glances/plugins/glances_ip.py
glances/plugins/glances_ip.py
+1
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+5
-5
glances/plugins/glances_ports.py
glances/plugins/glances_ports.py
+4
-4
setup.py
setup.py
+1
-1
未找到文件。
glances/exports/glances_cassandra.py
浏览文件 @
deaa17a7
...
...
@@ -112,9 +112,8 @@ class Export(GlancesExport):
session
.
set_keyspace
(
self
.
keyspace
)
logger
.
info
(
"Stats will be exported to Cassandra cluster {0} ({1}) in keyspace {2}"
.
format
(
cluster
.
metadata
.
cluster_name
,
cluster
.
metadata
.
all_hosts
(),
self
.
keyspace
))
"Stats will be exported to Cassandra cluster {} ({}) in keyspace {}"
.
format
(
cluster
.
metadata
.
cluster_name
,
cluster
.
metadata
.
all_hosts
(),
self
.
keyspace
))
# Table
try
:
...
...
glances/main.py
浏览文件 @
deaa17a7
...
...
@@ -163,7 +163,7 @@ Start the client browser (browser mode):\n\
parser
.
add_argument
(
'--export-graph'
,
action
=
'store_true'
,
default
=
None
,
dest
=
'export_graph'
,
help
=
'export stats to graphs'
)
parser
.
add_argument
(
'--path-graph'
,
default
=
tempfile
.
gettempdir
(),
dest
=
'path_graph'
,
help
=
'set the export path for graphs (default is {
0
})'
.
format
(
tempfile
.
gettempdir
()))
dest
=
'path_graph'
,
help
=
'set the export path for graphs (default is {})'
.
format
(
tempfile
.
gettempdir
()))
parser
.
add_argument
(
'--export-csv'
,
default
=
None
,
dest
=
'export_csv'
,
help
=
'export stats to a CSV file'
)
parser
.
add_argument
(
'--export-influxdb'
,
action
=
'store_true'
,
default
=
False
,
...
...
@@ -372,10 +372,10 @@ Start the client browser (browser mode):\n\
if
args
.
export_graph
and
args
.
path_graph
is
not
None
:
if
not
os
.
access
(
args
.
path_graph
,
os
.
W_OK
):
logger
.
critical
(
"Graphs output path {
0} do no
t exist or is not writable"
.
format
(
args
.
path_graph
))
"Graphs output path {
} doesn'
t exist or is not writable"
.
format
(
args
.
path_graph
))
sys
.
exit
(
2
)
logger
.
debug
(
"Graphs output path is set to {
0
}"
.
format
(
args
.
path_graph
))
"Graphs output path is set to {}"
.
format
(
args
.
path_graph
))
# For export graph, history is mandatory
if
args
.
export_graph
and
args
.
disable_history
:
...
...
glances/outputs/glances_curses.py
浏览文件 @
deaa17a7
...
...
@@ -744,10 +744,10 @@ class _GlancesCurses(object):
# Generate history graph
if
self
.
graph_tag
and
self
.
args
.
export_graph
:
self
.
display_popup
(
'Generate graphs history in {
0
}
\n
Please wait...'
.
format
(
'Generate graphs history in {}
\n
Please wait...'
.
format
(
self
.
glances_graph
.
get_output_folder
()))
self
.
display_popup
(
'Generate graphs history in {
0}
\n
Done: {1
} graphs generated'
.
format
(
'Generate graphs history in {
}
\n
Done: {
} graphs generated'
.
format
(
self
.
glances_graph
.
get_output_folder
(),
self
.
glances_graph
.
generate_graph
(
stats
)))
elif
self
.
reset_history_tag
and
self
.
args
.
export_graph
:
...
...
glances/plugins/glances_docker.py
浏览文件 @
deaa17a7
...
...
@@ -265,7 +265,7 @@ class Plugin(GlancesPlugin):
cpu_new
[
'nb_core'
]
=
len
(
all_stats
[
'cpu_stats'
][
'cpu_usage'
][
'percpu_usage'
]
or
[])
except
KeyError
as
e
:
# all_stats do not have CPU information
logger
.
debug
(
"Can
not grab CPU usage for container {0} ({1
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
"Can
not grab CPU usage for container {} ({
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
all_stats
)
else
:
# Previous CPU stats stored in the cpu_old variable
...
...
@@ -336,7 +336,7 @@ class Plugin(GlancesPlugin):
netcounters
=
all_stats
[
"networks"
]
except
KeyError
as
e
:
# all_stats do not have NETWORK information
logger
.
debug
(
"Can
not grab NET usage for container {0} ({1
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
"Can
not grab NET usage for container {} ({
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
all_stats
)
# No fallback available...
return
network_new
...
...
@@ -360,14 +360,14 @@ class Plugin(GlancesPlugin):
# XML/RPC API, which would otherwise be overly difficult work
# for users of the API
try
:
network_new
[
'time_since_update'
]
=
getTimeSinceLastUpdate
(
'docker_net_{
0
}'
.
format
(
container_id
))
network_new
[
'time_since_update'
]
=
getTimeSinceLastUpdate
(
'docker_net_{}'
.
format
(
container_id
))
network_new
[
'rx'
]
=
netcounters
[
"eth0"
][
"rx_bytes"
]
-
self
.
netcounters_old
[
container_id
][
"eth0"
][
"rx_bytes"
]
network_new
[
'tx'
]
=
netcounters
[
"eth0"
][
"tx_bytes"
]
-
self
.
netcounters_old
[
container_id
][
"eth0"
][
"tx_bytes"
]
network_new
[
'cumulative_rx'
]
=
netcounters
[
"eth0"
][
"rx_bytes"
]
network_new
[
'cumulative_tx'
]
=
netcounters
[
"eth0"
][
"tx_bytes"
]
except
KeyError
as
e
:
# all_stats do not have INTERFACE information
logger
.
debug
(
"Can
not grab network interface usage for container {0} ({1
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
"Can
not grab network interface usage for container {} ({
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
all_stats
)
# Save stats to compute next bitrate
...
...
@@ -394,7 +394,7 @@ class Plugin(GlancesPlugin):
iocounters
=
all_stats
[
"blkio_stats"
]
except
KeyError
as
e
:
# all_stats do not have io information
logger
.
debug
(
"Can
not grab block IO usage for container {0} ({1
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
"Can
not grab block IO usage for container {} ({
})"
.
format
(
container_id
,
e
))
logger
.
debug
(
all_stats
)
# No fallback available...
return
io_new
...
...
glances/plugins/glances_help.py
浏览文件 @
deaa17a7
...
...
@@ -50,11 +50,11 @@ class Plugin(GlancesPlugin):
pass
def
generate_view_data
(
self
):
self
.
view_data
[
'version'
]
=
'{
0} {1
}'
.
format
(
'Glances'
,
__version__
)
self
.
view_data
[
'psutil_version'
]
=
' with PSutil {
0
}'
.
format
(
psutil_version
)
self
.
view_data
[
'version'
]
=
'{
} {
}'
.
format
(
'Glances'
,
__version__
)
self
.
view_data
[
'psutil_version'
]
=
' with PSutil {}'
.
format
(
psutil_version
)
try
:
self
.
view_data
[
'configuration_file'
]
=
'Configuration file: {
0
}'
.
format
(
self
.
config
.
loaded_config_file
)
self
.
view_data
[
'configuration_file'
]
=
'Configuration file: {}'
.
format
(
self
.
config
.
loaded_config_file
)
except
AttributeError
:
pass
...
...
glances/plugins/glances_ip.py
浏览文件 @
deaa17a7
...
...
@@ -186,7 +186,7 @@ class PublicIpAddress(object):
try
:
response
=
urlopen
(
url
,
timeout
=
self
.
timeout
).
read
().
decode
(
'utf-8'
)
except
Exception
as
e
:
logger
.
debug
(
"IP plugin - Can
not open URL {0} ({1
})"
.
format
(
url
,
e
))
logger
.
debug
(
"IP plugin - Can
not open URL {} ({
})"
.
format
(
url
,
e
))
queue_target
.
put
(
None
)
else
:
# Request depend on service
...
...
glances/plugins/glances_plugin.py
浏览文件 @
deaa17a7
...
...
@@ -114,14 +114,14 @@ class GlancesPlugin(object):
"""Init the stats history (dict of GlancesAttribute)."""
if
self
.
_history_enable
():
init_list
=
[
a
[
'name'
]
for
a
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Stats history activated for plugin {
0} (items: {1
})"
.
format
(
self
.
plugin_name
,
init_list
))
logger
.
debug
(
"Stats history activated for plugin {
} (items: {
})"
.
format
(
self
.
plugin_name
,
init_list
))
return
GlancesHistory
()
def
reset_stats_history
(
self
):
"""Reset the stats history (dict of GlancesAttribute)."""
if
self
.
_history_enable
():
reset_list
=
[
a
[
'name'
]
for
a
in
self
.
get_items_history_list
()]
logger
.
debug
(
"Reset history for plugin {
0} (items: {1
})"
.
format
(
self
.
plugin_name
,
reset_list
))
logger
.
debug
(
"Reset history for plugin {
} (items: {
})"
.
format
(
self
.
plugin_name
,
reset_list
))
self
.
stats_history
.
reset
()
def
update_stats_history
(
self
):
...
...
@@ -202,7 +202,7 @@ class GlancesPlugin(object):
try
:
return
self
.
_json_dumps
({
item
:
s
[
item
]})
except
KeyError
as
e
:
logger
.
error
(
"Cannot get item history {
0} ({1
})"
.
format
(
item
,
e
))
logger
.
error
(
"Cannot get item history {
} ({
})"
.
format
(
item
,
e
))
return
None
elif
isinstance
(
s
,
list
):
try
:
...
...
@@ -210,7 +210,7 @@ class GlancesPlugin(object):
# http://stackoverflow.com/questions/4573875/python-get-index-of-dictionary-item-in-list
return
self
.
_json_dumps
({
item
:
map
(
itemgetter
(
item
),
s
)})
except
(
KeyError
,
ValueError
)
as
e
:
logger
.
error
(
"Cannot get item history {
0} ({1
})"
.
format
(
item
,
e
))
logger
.
error
(
"Cannot get item history {
} ({
})"
.
format
(
item
,
e
))
return
None
else
:
return
None
...
...
@@ -429,7 +429,7 @@ class GlancesPlugin(object):
# Read the global section
if
config
.
has_section
(
'global'
):
self
.
_limits
[
'history_size'
]
=
config
.
get_float_value
(
'global'
,
'history_size'
,
default
=
28800
)
logger
.
debug
(
"Load configuration key: {
0} = {1
}"
.
format
(
'history_size'
,
self
.
_limits
[
'history_size'
]))
logger
.
debug
(
"Load configuration key: {
} = {
}"
.
format
(
'history_size'
,
self
.
_limits
[
'history_size'
]))
# Read the plugin specific section
if
config
.
has_section
(
self
.
plugin_name
):
...
...
glances/plugins/glances_ports.py
浏览文件 @
deaa17a7
...
...
@@ -209,7 +209,7 @@ class ThreadScanner(threading.Thread):
try
:
ip
=
socket
.
gethostbyname
(
hostname
)
except
Exception
as
e
:
logger
.
debug
(
"{
0}: Can not convert {1} to IP address ({2
})"
.
format
(
self
.
plugin_name
,
hostname
,
e
))
logger
.
debug
(
"{
}: Cannot convert {} to IP address ({
})"
.
format
(
self
.
plugin_name
,
hostname
,
e
))
return
ip
def
_port_scan_icmp
(
self
,
port
):
...
...
@@ -230,7 +230,7 @@ class ThreadScanner(threading.Thread):
else
:
port
[
'status'
]
=
False
except
Exception
as
e
:
logger
.
debug
(
"{
0}: Error while pinging host ({2
})"
.
format
(
self
.
plugin_name
,
port
[
'host'
],
e
))
logger
.
debug
(
"{
}: Error while pinging host {} ({
})"
.
format
(
self
.
plugin_name
,
port
[
'host'
],
e
))
return
ret
...
...
@@ -243,7 +243,7 @@ class ThreadScanner(threading.Thread):
socket
.
setdefaulttimeout
(
port
[
'timeout'
])
_socket
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
except
Exception
as
e
:
logger
.
debug
(
"{
0
}: Error while creating scanning socket"
.
format
(
self
.
plugin_name
))
logger
.
debug
(
"{}: Error while creating scanning socket"
.
format
(
self
.
plugin_name
))
# Scan port
ip
=
self
.
_resolv_name
(
port
[
'host'
])
...
...
@@ -251,7 +251,7 @@ class ThreadScanner(threading.Thread):
try
:
ret
=
_socket
.
connect_ex
((
ip
,
int
(
port
[
'port'
])))
except
Exception
as
e
:
logger
.
debug
(
"
{0}: Error while scanning port {1} ({2
})"
.
format
(
self
.
plugin_name
,
port
,
e
))
logger
.
debug
(
"
0}: Error while scanning port {} ({
})"
.
format
(
self
.
plugin_name
,
port
,
e
))
else
:
if
ret
==
0
:
port
[
'status'
]
=
counter
.
get
()
...
...
setup.py
浏览文件 @
deaa17a7
...
...
@@ -62,7 +62,7 @@ class tests(Command):
glances_version
=
get_version
()
if
sys
.
version_info
<
(
2
,
7
)
or
(
3
,
0
)
<=
sys
.
version_info
<
(
3
,
3
):
print
(
'Glances {
0
} require at least Python 2.7 or 3.3 to run.'
.
format
(
glances_version
))
print
(
'Glances {} require at least Python 2.7 or 3.3 to run.'
.
format
(
glances_version
))
print
(
'Please install Glances 2.6.2 on your system.'
)
sys
.
exit
(
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录