Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
蜕变的菜鸟
glances
提交
4458ac97
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,发现更多精彩内容 >>
提交
4458ac97
编写于
10月 23, 2016
作者:
N
nicolargo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Export uptime to CSV (issue #890)
上级
80cc297a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
20 addition
and
4 deletion
+20
-4
glances/exports/glances_csv.py
glances/exports/glances_csv.py
+8
-1
glances/exports/glances_export.py
glances/exports/glances_export.py
+2
-1
glances/plugins/glances_uptime.py
glances/plugins/glances_uptime.py
+10
-2
未找到文件。
glances/exports/glances_csv.py
浏览文件 @
4458ac97
...
...
@@ -68,7 +68,8 @@ class Export(GlancesExport):
plugins
=
stats
.
getAllPlugins
()
# Init data with timestamp (issue#708)
csv_header
=
[
'timestamp'
]
if
self
.
first_line
:
csv_header
=
[
'timestamp'
]
csv_data
=
[
time
.
strftime
(
'%Y-%m-%d %H:%M:%S'
)]
# Loop over available plugin
...
...
@@ -90,6 +91,12 @@ class Export(GlancesExport):
for
fieldname
in
fieldnames
)
# Others lines: stats
csv_data
+=
itervalues
(
all_stats
[
i
])
elif
isinstance
(
all_stats
[
i
],
(
int
,
float
,
str
)):
# First line: header
if
self
.
first_line
:
csv_header
.
append
(
str
(
plugin
))
# Others lines: stats
csv_data
.
append
(
str
(
all_stats
[
i
]))
# Export to CSV
if
self
.
first_line
:
...
...
glances/exports/glances_export.py
浏览文件 @
4458ac97
...
...
@@ -64,7 +64,8 @@ class GlancesExport(object):
'system'
,
'uptime'
,
'sensors'
,
'docker'
]
'docker'
,
'uptime'
]
def
get_item_key
(
self
,
item
):
"""Return the value of the item 'key'."""
...
...
glances/plugins/glances_uptime.py
浏览文件 @
4458ac97
...
...
@@ -47,12 +47,20 @@ class Plugin(GlancesPlugin):
self
.
align
=
'right'
# Init the stats
self
.
uptime
=
datetime
.
now
()
self
.
reset
()
def
reset
(
self
):
"""Reset/init the stats."""
self
.
stats
=
{}
def
get_export
(
self
):
"""Overwrite the default export method.
Export uptime in seconds.
"""
return
self
.
uptime
.
seconds
@
GlancesPlugin
.
_check_decorator
@
GlancesPlugin
.
_log_result_decorator
def
update
(
self
):
...
...
@@ -62,10 +70,10 @@ class Plugin(GlancesPlugin):
if
self
.
input_method
==
'local'
:
# Update stats using the standard system lib
uptime
=
datetime
.
now
()
-
datetime
.
fromtimestamp
(
psutil
.
boot_time
())
self
.
uptime
=
datetime
.
now
()
-
datetime
.
fromtimestamp
(
psutil
.
boot_time
())
# Convert uptime to string (because datetime is not JSONifi)
self
.
stats
=
str
(
uptime
).
split
(
'.'
)[
0
]
self
.
stats
=
str
(
self
.
uptime
).
split
(
'.'
)[
0
]
elif
self
.
input_method
==
'snmp'
:
# Update stats using SNMP
uptime
=
self
.
get_stats_snmp
(
snmp_oid
=
snmp_oid
)[
'_uptime'
]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录