Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-unixfs
Commits
d5f0476c
Commit
d5f0476c
authored
Oct 10, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement diagnostics command
parent
280c7e7e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
10 deletions
+52
-10
cmd/ipfs/diag.go
cmd/ipfs/diag.go
+28
-0
core/commands/diag.go
core/commands/diag.go
+22
-0
daemon/daemon.go
daemon/daemon.go
+1
-9
diagnostics/message.pb.go
diagnostics/message.pb.go
+1
-1
No files found.
cmd/ipfs/diag.go
0 → 100644
View file @
d5f0476c
package
main
import
(
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
"github.com/jbenet/go-ipfs/core/commands"
)
var
cmdIpfsDiag
=
&
commander
.
Command
{
UsageLine
:
"diag"
,
Short
:
"Generate a diagnostics report"
,
Long
:
`ipfs diag - Generate a diagnostics report.
Sends out a message to each node in the network recursively
requesting a listing of data about them including number of
connected peers and latencies between them.
`
,
Run
:
diagCmd
,
Flag
:
*
flag
.
NewFlagSet
(
"ipfs-diag"
,
flag
.
ExitOnError
),
}
var
diagCmd
=
makeCommand
(
command
{
name
:
"diag"
,
args
:
0
,
flags
:
nil
,
cmdFn
:
commands
.
Diag
,
})
core/commands/diag.go
0 → 100644
View file @
d5f0476c
package
commands
import
(
"encoding/json"
"io"
"time"
"github.com/jbenet/go-ipfs/core"
)
func
Diag
(
n
*
core
.
IpfsNode
,
args
[]
string
,
opts
map
[
string
]
interface
{},
out
io
.
Writer
)
error
{
info
,
err
:=
n
.
Diagnostics
.
GetDiagnostic
(
time
.
Second
*
20
)
if
err
!=
nil
{
return
err
}
enc
:=
json
.
NewEncoder
(
out
)
err
=
enc
.
Encode
(
info
)
if
err
!=
nil
{
return
err
}
return
nil
}
daemon/daemon.go
View file @
d5f0476c
...
...
@@ -8,7 +8,6 @@ import (
"os"
"path"
"sync"
"time"
core
"github.com/jbenet/go-ipfs/core"
"github.com/jbenet/go-ipfs/core/commands"
...
...
@@ -138,14 +137,7 @@ func (dl *DaemonListener) handleConnection(conn net.Conn) {
case
"resolve"
:
err
=
commands
.
Resolve
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
case
"diag"
:
log
.
Debug
(
"DIAGNOSTIC!"
)
info
,
err
:=
dl
.
node
.
Diagnostics
.
GetDiagnostic
(
time
.
Second
*
20
)
if
err
!=
nil
{
fmt
.
Fprintln
(
conn
,
err
)
return
}
enc
:=
json
.
NewEncoder
(
conn
)
err
=
enc
.
Encode
(
info
)
err
=
commands
.
Diag
(
dl
.
node
,
command
.
Args
,
command
.
Opts
,
conn
)
default
:
err
=
fmt
.
Errorf
(
"Invalid Command: '%s'"
,
command
.
Command
)
}
...
...
diagnostics/message.pb.go
View file @
d5f0476c
...
...
@@ -13,7 +13,7 @@ It has these top-level messages:
*/
package
diagnostic
import
proto
"code.google.com/p/goprotobuf/proto"
import
proto
"
github.com/jbenet/go-ipfs/Godeps/_workspace/src/
code.google.com/p/goprotobuf/proto"
import
math
"math"
// Reference imports to suppress errors if they are not otherwise used.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment