Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
b0b1e0f1
提交
b0b1e0f1
authored
5月 16, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2681 from ipfs/feature/spruce-upstat
Add helptext, default logic to `ipfs stats`
上级
bdb11564
8ee399fb
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
47 行增加
和
14 行删除
+47
-14
stat.go
core/commands/stat.go
+47
-14
没有找到文件。
core/commands/stat.go
浏览文件 @
b0b1e0f1
...
...
@@ -18,8 +18,10 @@ import (
var
StatsCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Query IPFS statistics."
,
ShortDescription
:
``
,
Tagline
:
"Query ipfs statistics."
,
Synopsis
:
"ipfs stats <command>"
,
ShortDescription
:
`'ipfs stats' is a set of commands to help look at statistics for your ipfs node.`
,
LongDescription
:
`'ipfs stats' is a set of commands to help look at statistics for your ipfs node.`
,
},
Subcommands
:
map
[
string
]
*
cmds
.
Command
{
...
...
@@ -30,13 +32,48 @@ var StatsCmd = &cmds.Command{
var
statBwCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Print ipfs bandwidth information."
,
ShortDescription
:
``
,
Synopsis
:
"ipfs stats bw [--peer <peerId> | -p] [--proto <protocol> | -t] [--poll] [--interval <timeInterval> | -i]"
,
ShortDescription
:
`'ipfs stats bw' prints bandwidth information for the ipfs daemon.
It displays: TotalIn, TotalOut, RateIn, RateOut.
`
,
LongDescription
:
`'ipfs stats bw' prints bandwidth information for the ipfs daemon.
It displays: TotalIn, TotalOut, RateIn, RateOut.
By default, overall bandwidth and all protocols are shown. To limit bandwidth to
a particular peer, use the 'peer' option along with that peer's multihash id. To
specify a specific protocol, use the 'proto' option. The 'peer' and 'proto'
options cannot be specified simultaneously. The protocols that be queried using
this method are outlined in the specification: https://github.com/ipfs/specs/blob/master/libp2p/7-properties.md#757-protocol-multicodecs
Example protocol options:
- /ipfs/id/1.0.0
- /ipfs/bitswap
- /ipfs/dht
Example:
> ipfs stats bw -t /ipfs/bitswap
Bandwidth
TotalIn: 5.0MB
TotalOut: 0B
RateIn: 343B/s
RateOut: 0B/s
> ipfs stats bw -p QmepgFW7BHEtU4pZJdxaNiv75mKLLRQnPi1KaaXmQN4V1a
Bandwidth
TotalIn: 4.9MB
TotalOut: 12MB
RateIn: 0B/s
RateOut: 0B/s
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
StringOption
(
"peer"
,
"p"
,
"Specify a peer to print bandwidth for."
),
cmds
.
StringOption
(
"proto"
,
"t"
,
"Specify a protocol to print bandwidth for."
),
cmds
.
BoolOption
(
"poll"
,
"Print bandwidth at an interval. Default: false."
),
cmds
.
StringOption
(
"interval"
,
"i"
,
"Time interval to wait between updating output, if 'poll' is true."
),
cmds
.
BoolOption
(
"poll"
,
"Print bandwidth at an interval."
)
.
Default
(
false
),
cmds
.
StringOption
(
"interval"
,
"i"
,
`Time interval to wait between updating output, if 'poll' is true.
This accepts durations such as "300s", "1.5h" or "2h45m". Valid time units are:
"ns", "us" (or "µs"), "ms", "s", "m", "h".`
)
.
Default
(
"1s"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
...
...
@@ -78,19 +115,15 @@ var statBwCmd = &cmds.Command{
pid
=
checkpid
}
interval
:=
time
.
Second
timeS
,
found
,
err
:=
req
.
Option
(
"interval"
)
.
String
()
timeS
,
_
,
err
:=
req
.
Option
(
"interval"
)
.
String
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
if
found
{
v
,
err
:=
time
.
ParseDuration
(
timeS
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
interval
=
v
interval
,
err
:=
time
.
ParseDuration
(
timeS
)
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
}
doPoll
,
_
,
err
:=
req
.
Option
(
"poll"
)
.
Bool
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论