Skip to content

Latest commit

 

History

History
54 lines (45 loc) · 2.05 KB

File metadata and controls

54 lines (45 loc) · 2.05 KB

Go Go Report Card

cidtrack

Per CID bandwidth tracking for IPFS daemon.

CIDTrack is a ipfs daemon plugin that counts how many times a block was sent to the network. Currently it's a low level utility that counts raw block usage, without taking care about subblocks (see https://docs.ipfs.io/how-to/work-with-blocks/).

Building

Building is done out of tree (of go-ipfs). Currently you have to checkout go-ipfs and manually update go-bitswap dependency, because change adding WireTap is merged into master but not yet released.

Daemon:

  1. git clone https://github.com/ipfs/go-ipfs.git
  2. cd go-ipfs
  3. go get -v github.com/ipfs/go-bitswap@bc3df6b
  4. go build

Plugin:

  1. git clone https://github.com/tzdybal/cidtrack.git
  2. cd cidtrack
  3. make go.mod IPFS_VERSION=/ABSOLUTE/PATH/TO/go-ipfs
  4. make install

Configuration

By default CIDTracker listen on ":5002" (port 5002 on all addresses). This can be changed using listenAddress configuration, for example:

  "Plugins": {
    "Plugins": {
      "CIDtrack": {
        "Config": {
          "listenAddress": "127.0.0.1:8888"
        }
      }
    }
  }

Usage

Plugin can be accessed via HTTP endpoint, listening on listenAddress, default address (http://127.0.0.1:5002) will be used in examples.

get

http://127.0.0.1:5002/get returns all statistics gathered by CIDTracker. Data is returned as JSON as associative array (object), where key is a CID of block, and valuue is a number of times given block was sent. For example:

curl localhost:5002/get
{"Qma5RSy8wpWUpnXfegzNz6iJnLSwWUQdrpmxEar3sZT5GX":1,"QmapJQeFtp3rtZs3N1nKPxKgcRhGkRjxjNjYkafjoQXJNf":1}

http://127.0.0.1:5002/get/reset returns all stats and then resets/clears all collected data.

reset

http://127.0.0.1:5002/reset resets/clears all collected data (without returning any value).