Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
b229d0a5
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,发现更多精彩内容 >>
提交
b229d0a5
编写于
8月 27, 2019
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'issue1534' into develop
上级
f0e8ef44
377d039d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
29 addition
and
4 deletion
+29
-4
glances/__init__.py
glances/__init__.py
+4
-1
glances/plugins/glances_sensors.py
glances/plugins/glances_sensors.py
+9
-0
glances/standalone.py
glances/standalone.py
+7
-2
glances/stats.py
glances/stats.py
+9
-1
未找到文件。
glances/__init__.py
浏览文件 @
b229d0a5
...
...
@@ -43,7 +43,7 @@ except ImportError:
from
glances.logger
import
logger
from
glances.main
import
GlancesMain
from
glances.globals
import
WINDOWS
from
glances.timer
import
Counter
# Check locale
try
:
locale
.
setlocale
(
locale
.
LC_ALL
,
''
)
...
...
@@ -89,6 +89,8 @@ def start(config, args):
# Load mode
global
mode
start_duration
=
Counter
()
if
core
.
is_standalone
():
from
glances.standalone
import
GlancesStandalone
as
GlancesMode
elif
core
.
is_client
():
...
...
@@ -106,6 +108,7 @@ def start(config, args):
mode
=
GlancesMode
(
config
=
config
,
args
=
args
)
# Start the main loop
logger
.
debug
(
"Glances started in {} seconds"
.
format
(
start_duration
.
get
()))
mode
.
serve_forever
()
# Shutdown
...
...
glances/plugins/glances_sensors.py
浏览文件 @
b229d0a5
...
...
@@ -24,6 +24,7 @@ import warnings
from
glances.logger
import
logger
from
glances.compat
import
iteritems
from
glances.timer
import
Counter
from
glances.plugins.sensors.glances_batpercent
import
Plugin
as
BatPercentPlugin
from
glances.plugins.sensors.glances_hddtemp
import
Plugin
as
HddTempPlugin
from
glances.plugins.glances_plugin
import
GlancesPlugin
...
...
@@ -51,16 +52,24 @@ class Plugin(GlancesPlugin):
config
=
config
,
stats_init_value
=
[])
start_duration
=
Counter
()
# Init the sensor class
start_duration
.
reset
()
self
.
glancesgrabsensors
=
GlancesGrabSensors
()
logger
.
debug
(
"Generic sensor plugin init duration: {} seconds"
.
format
(
start_duration
.
get
()))
# Instance for the HDDTemp Plugin in order to display the hard disks
# temperatures
start_duration
.
reset
()
self
.
hddtemp_plugin
=
HddTempPlugin
(
args
=
args
,
config
=
config
)
logger
.
debug
(
"HDDTemp sensor plugin init duration: {} seconds"
.
format
(
start_duration
.
get
()))
# Instance for the BatPercent in order to display the batteries
# capacities
start_duration
.
reset
()
self
.
batpercent_plugin
=
BatPercentPlugin
(
args
=
args
,
config
=
config
)
logger
.
debug
(
"Battery sensor plugin init duration: {} seconds"
.
format
(
start_duration
.
get
()))
# We want to display the stat in the curse interface
self
.
display_curse
=
True
...
...
glances/standalone.py
浏览文件 @
b229d0a5
...
...
@@ -46,7 +46,10 @@ class GlancesStandalone(object):
self
.
refresh_time
=
args
.
time
# Init stats
start_duration
=
Counter
()
start_duration
.
reset
()
self
.
stats
=
GlancesStats
(
config
=
config
,
args
=
args
)
logger
.
debug
(
"Plugins initialisation duration: {} seconds"
.
format
(
start_duration
.
get
()))
# Modules (plugins and exporters) are loaded at this point
# Glances can display the list if asked...
...
...
@@ -71,7 +74,9 @@ class GlancesStandalone(object):
glances_processes
.
disable_kernel_threads
()
# Initial system informations update
start_duration
.
reset
()
self
.
stats
.
update
()
logger
.
debug
(
"First stats update duration: {} seconds"
.
format
(
start_duration
.
get
()))
if
self
.
quiet
:
logger
.
info
(
"Quiet mode is ON, nothing will be displayed"
)
...
...
@@ -117,12 +122,12 @@ class GlancesStandalone(object):
# Update stats
self
.
stats
.
update
()
logger
.
debug
(
'Stats updated
in
{} seconds'
.
format
(
counter
.
get
()))
logger
.
debug
(
'Stats updated
duration:
{} seconds'
.
format
(
counter
.
get
()))
# Export stats
counter_export
=
Counter
()
self
.
stats
.
export
(
self
.
stats
)
logger
.
debug
(
'Stats exported
in
{} seconds'
.
format
(
counter_export
.
get
()))
logger
.
debug
(
'Stats exported
duration:
{} seconds'
.
format
(
counter_export
.
get
()))
# Patch for issue1326 to avoid < 0 refresh
adapted_refresh
=
self
.
refresh_time
-
counter
.
get
()
...
...
glances/stats.py
浏览文件 @
b229d0a5
...
...
@@ -25,8 +25,9 @@ import sys
import
threading
import
traceback
from
glances.globals
import
exports_path
,
plugins_path
,
sys_path
from
glances.logger
import
logger
from
glances.globals
import
exports_path
,
plugins_path
,
sys_path
from
glances.timer
import
Counter
class
GlancesStats
(
object
):
...
...
@@ -136,13 +137,17 @@ class GlancesStats(object):
def
load_plugins
(
self
,
args
=
None
):
"""Load all plugins in the 'plugins' folder."""
start_duration
=
Counter
()
for
item
in
os
.
listdir
(
plugins_path
):
if
(
item
.
startswith
(
self
.
header
)
and
item
.
endswith
(
".py"
)
and
item
!=
(
self
.
header
+
"plugin.py"
)):
# Load the plugin
start_duration
.
reset
()
self
.
_load_plugin
(
os
.
path
.
basename
(
item
),
args
=
args
,
config
=
self
.
config
)
logger
.
debug
(
"Plugin {} started in {} seconds"
.
format
(
item
,
start_duration
.
get
()))
# Log plugins list
logger
.
debug
(
"Active plugins list: {}"
.
format
(
self
.
getPluginsList
()))
...
...
@@ -224,12 +229,15 @@ class GlancesStats(object):
# If current plugin is disable
# then continue to next plugin
continue
start_duration
=
Counter
()
# Update the stats...
self
.
_plugins
[
p
].
update
()
# ... the history
self
.
_plugins
[
p
].
update_stats_history
()
# ... and the views
self
.
_plugins
[
p
].
update_views
()
# logger.debug("Plugin {} update duration: {} seconds".format(p,
# start_duration.get()))
def
export
(
self
,
input_stats
=
None
):
"""Export all the stats.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录