Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
e798fb4f
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 搜索 >>
提交
e798fb4f
编写于
7月 13, 2021
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add API doc for CPU (not completed)
上级
d650913c
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
56 addition
and
3 deletion
+56
-3
glances/__init__.py
glances/__init__.py
+1
-1
glances/main.py
glances/main.py
+2
-0
glances/plugins/glances_cpu.py
glances/plugins/glances_cpu.py
+43
-1
glances/plugins/glances_plugin.py
glances/plugins/glances_plugin.py
+5
-1
glances/standalone.py
glances/standalone.py
+5
-0
未找到文件。
glances/__init__.py
浏览文件 @
e798fb4f
...
...
@@ -110,7 +110,7 @@ def start(config, args):
# Start the main loop
logger
.
debug
(
"Glances started in {} seconds"
.
format
(
start_duration
.
get
()))
if
args
.
stdout_issue
:
if
args
.
stdout_issue
or
args
.
stdout_fields
:
# Serve once for issue/test mode
mode
.
serve_issue
()
else
:
...
...
glances/main.py
浏览文件 @
e798fb4f
...
...
@@ -230,6 +230,8 @@ Examples of use:
dest
=
'stdout_csv'
,
help
=
'display stats to stdout, csv format (comma separated list of plugins/plugins.attribute)'
)
parser
.
add_argument
(
'--issue'
,
default
=
None
,
action
=
'store_true'
,
dest
=
'stdout_issue'
,
help
=
'test all plugins and exit (please copy/paste the output if you open an issue)'
)
parser
.
add_argument
(
'--fields'
,
'--api-doc'
,
default
=
None
,
action
=
'store_true'
,
dest
=
'stdout_fields'
,
help
=
'display fields descriptions'
)
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/plugins/glances_cpu.py
浏览文件 @
e798fb4f
...
...
@@ -29,6 +29,47 @@ from glances.plugins.glances_plugin import GlancesPlugin
import
psutil
# Fields description
# {'total': 19.7, 'user': 3.4, 'nice': 0.0, 'system': 2.6, 'idle': 93.0, 'iowait': 0.1, 'irq': 0.0, 'softirq': 0.8, 'steal': 0.0, 'guest': 0.0, 'guest_nice': 0.0, 'time_since_update': 2.1306779384613037, 'cpucore': 4, 'ctx_switches': 11636, 'interrupts': 4463, 'soft_interrupts': 3227, 'syscalls': 0}
fields_description
=
{
'total'
:
{
'description'
:
'Sum of all CPU percentages (except idle).'
,
'unit'
:
'percent'
},
'system'
:
{
'description'
:
'percent time spent in kernel space. System CPU time is the
\
time spent running code in the Operating System kernel.'
,
'unit'
:
'percent'
},
'user'
:
{
'description'
:
'CPU percent time spent in user space.
\
User CPU time is the time spent on the processor running your program
\'
s code (or code in libraries).'
,
'unit'
:
'percent'
},
'iowait'
:
{
'description'
:
'*(Linux)*: percent time spent by the CPU waiting for I/O
\
operations to complete.'
,
'unit'
:
'percent'
},
'idle'
:
{
'description'
:
'percent of CPU used by any program. Every program or task
\
that runs on a computer system occupies a certain amount of processing
\
time on the CPU. If the CPU has completed all tasks it is idle.'
,
'unit'
:
'percent'
},
'irq'
:
{
'description'
:
'*(Linux and BSD)*: percent time spent servicing/handling
\
hardware/software interrupts. Time servicing interrupts (hardware +
\
software).'
,
'unit'
:
'percent'
},
'nice'
:
{
'description'
:
'*(Unix)*: percent time occupied by user level processes with
\
a positive nice value. The time the CPU has spent running users
\'
\
processes that have been *niced*.'
,
'unit'
:
'percent'
},
'steal'
:
{
'description'
:
'*(Linux)*: percentage of time a virtual CPU waits for a real
\
CPU while the hypervisor is servicing another virtual processor.'
,
'unit'
:
'percent'
},
'ctx_sw'
:
{
'description'
:
'number of context switches (voluntary + involuntary) per
\
second. A context switch is a procedure that a computer
\'
s CPU (central
\
processing unit) follows to change from one task (or process) to
\
another while ensuring that the tasks do not conflict.'
,
'unit'
:
'percent'
},
'inter'
:
{
'description'
:
'number of interrupts per second.'
,
'unit'
:
'percent'
},
'sw_int'
:
{
'description'
:
'number of software interrupts per second. Always set to
\
0 on Windows and SunOS.'
,
'unit'
:
'percent'
},
}
# SNMP OID
# percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
# percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
...
...
@@ -64,7 +105,8 @@ class Plugin(GlancesPlugin):
"""Init the CPU plugin."""
super
(
Plugin
,
self
).
__init__
(
args
=
args
,
config
=
config
,
items_history_list
=
items_history_list
)
items_history_list
=
items_history_list
,
fields_description
=
fields_description
)
# We want to display the stat in the curse interface
self
.
display_curse
=
True
...
...
glances/plugins/glances_plugin.py
浏览文件 @
e798fb4f
...
...
@@ -44,7 +44,8 @@ class GlancesPlugin(object):
args
=
None
,
config
=
None
,
items_history_list
=
None
,
stats_init_value
=
{}):
stats_init_value
=
{},
fields_description
=
None
):
"""Init the plugin of plugins class.
All Glances' plugins should inherit from this class. Most of the
...
...
@@ -107,6 +108,9 @@ class GlancesPlugin(object):
# Set the initial refresh time to display stats the first time
self
.
refresh_timer
=
Timer
(
0
)
# Init stats description
self
.
fields_description
=
fields_description
# Init the stats
self
.
stats_init_value
=
stats_init_value
self
.
stats
=
None
...
...
glances/standalone.py
浏览文件 @
e798fb4f
...
...
@@ -30,6 +30,7 @@ from glances.outputs.glances_curses import GlancesCursesStandalone
from
glances.outputs.glances_stdout
import
GlancesStdout
from
glances.outputs.glances_stdout_csv
import
GlancesStdoutCsv
from
glances.outputs.glances_stdout_issue
import
GlancesStdoutIssue
from
glances.outputs.glances_stdout_fields
import
GlancesStdoutFieldsDescription
from
glances.outdated
import
Outdated
from
glances.timer
import
Counter
...
...
@@ -87,6 +88,10 @@ class GlancesStandalone(object):
logger
.
info
(
"Issue mode is ON"
)
# Init screen
self
.
screen
=
GlancesStdoutIssue
(
config
=
config
,
args
=
args
)
elif
args
.
stdout_fields
:
logger
.
info
(
"Fields descriptions mode is ON"
)
# Init screen
self
.
screen
=
GlancesStdoutFieldsDescription
(
config
=
config
,
args
=
args
)
elif
args
.
stdout
:
logger
.
info
(
"Stdout mode is ON, following stats will be displayed: {}"
.
format
(
args
.
stdout
))
# Init screen
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录