Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
b091bdbb
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 搜索 >>
提交
b091bdbb
编写于
2月 11, 2018
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a new output mode to stdout #1168
上级
0d029220
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
119 addition
and
2 deletion
+119
-2
NEWS
NEWS
+3
-0
docs/cmds.rst
docs/cmds.rst
+4
-0
docs/man/glances.1
docs/man/glances.1
+6
-1
docs/quickstart.rst
docs/quickstart.rst
+13
-0
glances/main.py
glances/main.py
+5
-0
glances/outputs/glances_stdout.py
glances/outputs/glances_stdout.py
+82
-0
glances/standalone.py
glances/standalone.py
+6
-1
未找到文件。
NEWS
浏览文件 @
b091bdbb
...
...
@@ -20,6 +20,7 @@ Enhancements and new features:
* Take advantage of the PSUtil issue #1025 (Add process_iter(attrs, ad_value)) #1105
* Nice Process Priority Configuration #1218
* Display debug message if dep lib is not found #1224
* Add a new output mode to stdout #1168
Bugs corrected:
...
...
@@ -56,6 +57,8 @@ News command line options:
Disable a list of comma separated plugins
--export exporter1,exporter2
Export stats to a comma separated exporters
--stdout plugin1,plugin2.attribute
Display stats to stdout
News configuration keys in the glances.conf file:
...
...
docs/cmds.rst
浏览文件 @
b091bdbb
...
...
@@ -30,6 +30,10 @@ Command-Line Options
disable PLUGIN (comma separed list)
.. option:: --stdout PLUGINS_STATS
display stats to stdout (comma separated list of plugins/plugins.attribute)
.. option:: --export EXPORT
enable EXPORT module (comma separed list)
...
...
docs/man/glances.1
浏览文件 @
b091bdbb
.\" Man page generated from reStructuredText.
.
.TH "GLANCES" "1" "
Jan 18, 2018" "3.0_DEV
" "Glances"
.TH "GLANCES" "1" "
Feb 11, 2018" "3.0.dev0
" "Glances"
.SH NAME
glances \- An eye on your system
.
...
...
@@ -78,6 +78,11 @@ disable PLUGIN (comma separed list)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-stdout PLUGINS_STATS
display stats to stdout (comma separated list of plugins/plugins.attribute)
.UNINDENT
.INDENT 0.0
.TP
.B \-\-export EXPORT
enable EXPORT module (comma separed list)
.UNINDENT
...
...
docs/quickstart.rst
浏览文件 @
b091bdbb
...
...
@@ -24,6 +24,19 @@ Glances should start (press 'q' or 'ESC' to exit):
.. image:: _static/screenshot-wide.png
It is also possible to display stats directly to stdout using:
.. code-block:: console
$ glances --stdout cpu.user,mem.used,load
cpu.user: 30.7
mem.used: 3278204928
load: {'cpucore': 4, 'min1': 0.21, 'min5': 0.4, 'min15': 0.27}
cpu.user: 3.4
mem.used: 3275251712
load: {'cpucore': 4, 'min1': 0.19, 'min5': 0.39, 'min15': 0.27}
...
Client/Server Mode
------------------
...
...
glances/main.py
浏览文件 @
b091bdbb
...
...
@@ -91,6 +91,9 @@ Examples of use:
Start the client browser (browser mode):
$ glances --browser
Display stats to stdout:
$ glances --stdout cpu.user,mem.used,load
Disable some plugins (any modes):
$ glances --disable-plugin network,ports
"""
...
...
@@ -210,6 +213,8 @@ Examples of use:
dest
=
'process_filter'
,
help
=
'set the process filter pattern (regular expression)'
)
parser
.
add_argument
(
'--process-short-name'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'process_short_name'
,
help
=
'force short name for processes name'
)
parser
.
add_argument
(
'--stdout'
,
default
=
None
,
dest
=
'stdout'
,
help
=
'display stats to stdout (comma separated list of plugins / plugins.attribute)'
)
if
not
WINDOWS
:
parser
.
add_argument
(
'--hide-kernel-threads'
,
action
=
'store_true'
,
default
=
False
,
dest
=
'no_kernel_threads'
,
help
=
'hide kernel threads in process list (not available on Windows)'
)
...
...
glances/outputs/glances_stdout.py
0 → 100644
浏览文件 @
b091bdbb
# -*- coding: utf-8 -*-
#
# This file is part of Glances.
#
# Copyright (C) 2018 Nicolargo <nicolas@nicolargo.com>
#
# Glances is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Glances is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
"""Stdout interface class."""
import
time
from
glances.logger
import
logger
class
GlancesStdout
(
object
):
"""
This class manages the Stdout display.
"""
def
__init__
(
self
,
config
=
None
,
args
=
None
):
# Init
self
.
config
=
config
self
.
args
=
args
# Build the list of plugin and/or plugin.attribute to display
self
.
plugins_list
=
self
.
build_list
()
def
build_list
(
self
):
"""Return a list of tuples taken from self.args.stdout
[(plugin, attribute), ... ]"""
ret
=
[]
for
p
in
self
.
args
.
stdout
.
split
(
','
):
if
'.'
in
p
:
p
,
a
=
p
.
split
(
'.'
)
else
:
a
=
None
ret
.
append
((
p
,
a
))
return
ret
def
end
(
self
):
pass
def
update
(
self
,
stats
,
duration
=
3
):
"""Display stats to stdout.
Refresh every duration second.
"""
for
plugin
,
attribute
in
self
.
plugins_list
:
# Check if the plugin exist and is enable
if
plugin
in
stats
.
getPluginsList
()
and
\
stats
.
get_plugin
(
plugin
).
is_enable
():
stat
=
stats
.
get_plugin
(
plugin
).
get_export
()
else
:
continue
# Display stats
if
attribute
is
not
None
:
# With attribute
try
:
print
(
"{}.{}: {}"
.
format
(
plugin
,
attribute
,
stat
[
attribute
]))
except
KeyError
as
err
:
logger
.
error
(
"Can not display stat {}.{} ({})"
.
format
(
plugin
,
attribute
,
err
))
else
:
# Without attribute
print
(
"{}: {}"
.
format
(
plugin
,
stat
))
# Wait until next refresh
time
.
sleep
(
duration
)
glances/standalone.py
浏览文件 @
b091bdbb
...
...
@@ -26,6 +26,7 @@ from glances.logger import logger
from
glances.processes
import
glances_processes
from
glances.stats
import
GlancesStats
from
glances.outputs.glances_curses
import
GlancesCursesStandalone
from
glances.outputs.glances_stdout
import
GlancesStdout
from
glances.outdated
import
Outdated
from
glances.timer
import
Counter
...
...
@@ -68,9 +69,13 @@ class GlancesStandalone(object):
self
.
stats
.
update
()
if
self
.
quiet
:
logger
.
info
(
"Quiet mode is ON
: N
othing will be displayed"
)
logger
.
info
(
"Quiet mode is ON
, n
othing will be displayed"
)
# In quiet mode, nothing is displayed
glances_processes
.
max_processes
=
0
elif
args
.
stdout
:
logger
.
info
(
"Stdout mode is ON, following stats will be displayed: {}"
.
format
(
args
.
stdout
))
# Init screen
self
.
screen
=
GlancesStdout
(
config
=
config
,
args
=
args
)
else
:
# Default number of processes to displayed is set to 50
glances_processes
.
max_processes
=
50
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录