Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add inspector command for system inspection #2663

Merged
merged 11 commits into from
May 2, 2019
Merged

Conversation

frrist
Copy link
Member

@frrist frrist commented Apr 24, 2019

Description

This PR makes progress towards completing #2652 by adding the following commands:

USAGE
  go-filecoin inspect - Show info about the filecoin node

  go-filecoin inspect

SUBCOMMANDS
  go-filecoin inspect config  - Print in memory config information.
  go-filecoin inspect disk    - Print filesystem usage information.
  go-filecoin inspect memory  - Print memory usage information.
  go-filecoin inspect runtime - Print runtime diagnostic information.

Use 'go-filecoin inspect --help' for more information about this command.

Disk: Prints out information about the filesystem

$ go-filecoin inspect disk
{
  "FSType": "61267",
  "Free": 860286201856,
  "Total": 809074733056
}

Memory: Prints out information about system memory.

$ go-filecoin inspect memory
{
  "Swap": 0,
  "Virtual": 10323220000
}

Runtime: Prints out information about your golang runtime.

$ go-filecoin inspect runtime
{
  "Arch": "amd64",
  "Compiler": "gc",
  "GoMaxProcs": 8,
  "NumCGoCalls": 11,
  "NumGoRoutines": 90,
  "NumProc": 8,
  "OS": "linux",
  "Version": "go1.12.1"
}

Environment: Prints out information about your filecoin nodes environment.

$ go-filecoin inspect environment
{
  "FIL_API": "",
  "FIL_PATH": "",
  "GOPATH": "/home/frrist"
}

Config: Prints out information about your filecoin nodes in memory config.

go-filecoin inspect config
{
  "api": {
    "accessControlAllowCredentials": false,
    "accessControlAllowMethods": [
      "GET",
      "POST",
      "PUT"
    ],
....omitted....
  "wallet": {
    "defaultAddress": "t1azpabiyccur7ojhicilqti3ddjvtkbopa42s7py"
  }
} 

@frrist frrist self-assigned this Apr 24, 2019
return nil
}

func filPath() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blocking: This won't work if a user specified home directory with the --repodir flag, you should parse that arg, import repo and use repo.GetRepoDir(repoDirArgString) function as in other commands. Also this way the env var stuff is taken care of for you.

Copy link
Contributor

@ZenGround0 ZenGround0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved after blocking comment is addressed. The thing that worries me most about this command is the proliferation of abstractions on the CLI. It seems like the existence of this command, particularly the networking subcommand implies we should be rearranging existing commands underneath it like go-filecoin stats, go-filecoin id. In general this set of functionality helps more than it harms as most of the functionality introduced is needed and does not exist in another form on the CLI.

I do not support completing the rest of #2652 as it is written right now (config, network, filecoin) without rethinking existing commands or understanding how the rest of the proposed commands fit into the CLI as a whole. With this in mind I am imagining diag sys becoming the top level command with disk, env, mem, net and runtime subcommands.

@mishmosh
Copy link
Contributor

Are diag and sys fairly universal command names? If not, could they be renamed to be more human-readable?

@frrist frrist force-pushed the feat/filecoin-diag-cmd branch from 45ad752 to bd9059e Compare April 26, 2019 00:27
@frrist frrist changed the title add diag command with subcommand sys WIP add diag command with subcommand sys Apr 26, 2019
@frrist frrist changed the title WIP add diag command with subcommand sys WIP add inspector command for system inspection Apr 26, 2019
@frrist frrist force-pushed the feat/filecoin-diag-cmd branch 2 times, most recently from 2f6d197 to 705f567 Compare April 26, 2019 17:52
@frrist
Copy link
Member Author

frrist commented Apr 26, 2019

@mishmosh I was originally borrowing from the naming convention used by go-ipfs, however I have altered this in attempt to be a bit more descriptive. The PR description now reflects this.

@ZenGround0 I have re-written this inlight of your review to use plumbing, I think stats could be moved under the inspect command -- could you give this a second?

@frrist frrist force-pushed the feat/filecoin-diag-cmd branch 4 times, most recently from 2dd3508 to 6e25c93 Compare April 26, 2019 18:25
@frrist frrist changed the title WIP add inspector command for system inspection add inspector command for system inspection Apr 26, 2019
@ZenGround0 ZenGround0 self-requested a review April 26, 2019 19:33
@frrist frrist force-pushed the feat/filecoin-diag-cmd branch from 6e25c93 to bc64a95 Compare April 26, 2019 20:06
@frrist frrist changed the title add inspector command for system inspection ddd inspector command for system inspection Apr 26, 2019
@frrist frrist changed the title ddd inspector command for system inspection add inspector command for system inspection Apr 26, 2019
Copy link
Contributor

@travisperson travisperson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just some linting comments as it's currently broken till #2650 lands

repo repo.Repo
}

// RuntimeInfor contains information about the golang runtime.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RuntimeInfor

}

// RuntimeInfor contains information about the environment filecoin is running in.
type EnvironmentInfo struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EnvironmentInfo contains

}
}

func (g *Service) Environment() *EnvironmentInfo {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a doc comment

repo/fsrepo.go Outdated Show resolved Hide resolved
@frrist frrist force-pushed the feat/filecoin-diag-cmd branch 2 times, most recently from 5f9fa35 to 2d9dc13 Compare April 29, 2019 16:40
@frrist frrist force-pushed the feat/filecoin-diag-cmd branch from 2d9dc13 to fe9b7c3 Compare April 29, 2019 17:17
@frrist frrist requested a review from anorth April 29, 2019 21:08
Copy link
Member

@anorth anorth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! Please follow up with an update to the GitHub bug issue template so we can see this in action.

I think this is a nice clean example of something that does not need to be part of plumbing: it's not a core interface/component to be used by lots of higher level things. The alternative here is to put the inspector service on the command Env directly (runAPIAndWait in daemon.go) and bypass plumbing.

LGTM whether or not you do that here.

@anorth
Copy link
Member

anorth commented May 1, 2019

Do we want an inspect all so there's a one-liner for our bug reports?

@frrist
Copy link
Member Author

frrist commented May 1, 2019

The alternative here is to put the inspector service on the command Env

This is a much better idea imo, I have modified it to do such.

Do we want an inspect all so there's a one-liner for our bug reports?

Done:

go-filecoin inspect all | jq
{
  "Config": {
    "api": {
      "accessControlAllowCredentials": false,
      "accessControlAllowMethods": [
        "GET",
        "POST",
        "PUT"
      ],
      "accessControlAllowOrigin": [
        "http://localhost:8080",
        "https://localhost:8080",
        "http://127.0.0.1:8080",
        "https://127.0.0.1:8080"
      ],
      "address": "/ip4/127.0.0.1/tcp/3453"
    },
    "bootstrap": {
      "addresses": [],
      "minPeerThreshold": 0,
      "period": "1m"
    },
    "datastore": {
      "path": "badger",
      "type": "badgerds"
    },
    "heartbeat": {
      "beatPeriod": "3s",
      "beatTarget": "",
      "nickname": "",
      "reconnectPeriod": "10s"
    },
    "metrics": {
      "prometheusEnabled": false,
      "prometheusEndpoint": "/ip4/0.0.0.0/tcp/9400",
      "reportInterval": "5s"
    },
    "mining": {
      "autoSealIntervalSeconds": 120,
      "minerAddress": "empty",
      "storagePrice": "0"
    },
    "mpool": {
      "maxNonceGap": "100",
      "maxPoolSize": 10000
    },
    "net": "",
    "sectorbase": {
      "rootdir": ""
    },
    "swarm": {
      "address": "/ip4/0.0.0.0/tcp/6000"
    },
    "wallet": {
      "defaultAddress": "t1ciamdwkjhbt7fjqm4chc3logy76cjbjey75qfia"
    }
  },
  "Disk": {
    "FSType": "61267",
    "Free": 856211677184,
    "Total": 805000208384
  },
  "Environment": {
    "FIL_API": "",
    "FIL_PATH": "",
    "GOPATH": "/home/frrist"
  },
  "Memory": {
    "Swap": 0,
    "Virtual": 10331684000
  },
  "Runtime": {
    "Arch": "amd64",
    "Compiler": "gc",
    "GoMaxProcs": 8,
    "NumCGoCalls": 9,
    "NumGoRoutines": 87,
    "NumProc": 8,
    "OS": "linux",
    "Version": "go1.12.1"
  }
}

@frrist
Copy link
Member Author

frrist commented May 1, 2019

Please follow up with an update to the GitHub bug issue template so we can see this in action.

Sounds good, will do this once it merges

@frrist frrist merged commit 92f0b9e into master May 2, 2019
@frrist frrist deleted the feat/filecoin-diag-cmd branch May 2, 2019 21:08
ZenGround0 pushed a commit that referenced this pull request May 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants