rpc, cli: add network in/out connections to getnetworkinfo and -getinfo#19405
rpc, cli: add network in/out connections to getnetworkinfo and -getinfo#19405laanwj merged 3 commits intobitcoin:masterfrom
getnetworkinfo and -getinfo#19405Conversation
Yeah, I've personally always used a stats script that goes through Seems like something that could easily be done client-side in |
|
Concept ACK |
e7c7809 to
9290a98
Compare
|
Re-pushed with release notes.
That's pretty nice. In terms of vertical space for human use, something like that might be better as string values rather than a JSON object We could perhaps create a new CLI |
That PR seems orthogonal, as it proposes to detail the outbounds into various subtypes, but the basic distinction remains between inbound and outbound connections. I reckon that exposing to users and RPC clients the counts of the outbound subtypes in addition to |
9290a98 to
94a792c
Compare
|
Addressed @MarcoFalke's suggestions. Thanks everyone. Rebased per |
|
I have no objection to adding this to getnetworkinfo, but just noting that jq is your friend here: |
|
tACK. Changes seem simple-enough and are working (and passing tests) on MacOS 10.15. Also pleased to learn jnewbery's advanced jq pipe from above :) |
|
ACK 94a792cc19f26754ac5d60a1b733d4b520f7d0c7 Ran unit tests and extended functional tests, all pass. Did not run fuzz tests. Started bitcoind on a clean datadir and ran the bitcoin-cli commands to verify the new output: Tested Tested Verified that the help contains the new fields as well: |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Current status:
Is anything else needed? The changes are simple and have test coverage. |
Github-Pull: bitcoin#19405 Rebased-From: 1c667b4080c6d18ea65c52c252d8d9a551ecd5ae
Github-Pull: bitcoin#19405 Rebased-From: 94a792cc19f26754ac5d60a1b733d4b520f7d0c7
94a792c to
d96c13f
Compare
|
Rebased and re-opened per IRC discussion yesterday with shesek at http://www.erisian.com.au/bitcoin-core-dev/log-2020-08-19.html#l-375. Proposing with both |
d96c13f to
581b343
Compare
|
Rebased. Testing and review welcome! 🥰 |
|
ACK 581b343 Repeated steps from #19405 (comment) on the re-opened and rebased PR. Tests and extended functional tests pass. Tested |
|
@shesek have you had a chance to test and review to see if this works for your purposes? |
|
tACK |
|
tACK |
Thanks @shesek! |
Thanks for reviewing @n-thumann and happy to hear that you tested on an existing datadir, which covers the other side of my test! 👍 |
…networkinfo` and `-getinfo` 581b343 Add in/out connections to cli -getinfo (Jon Atack) d9cc13e UNIX_EPOCH_TIME fixup in rpc getnettotals (Jon Atack) 1ab49b8 Add in/out connections to rpc getnetworkinfo (Jon Atack) Pull request description: This is basic info that is present in the GUI that I've been wishing to have exposed via the RPC and CLI without needing a bash workaround or script. For human users it would also be useful to have it in `-getinfo`. `bitcoin-cli getnetworkinfo` ``` "connections": 15, "connections_in": 6, "connections_out": 9, ``` `bitcoin-cli -getinfo` ``` "connections": { "in": 6, "out": 9, "total": 15 }, ``` Update the tests, RPC help, and release notes for the changes. Also fixup the `getnettotals` timemillis help while touching `rpc/net.cpp`. ----- Reviewers can manually test this PR by [building from source](https://jonatack.github.io/articles/how-to-compile-bitcoin-core-and-run-the-tests), launching bitcoind, and then running `bitcoin-cli -getinfo`, `bitcoin-cli getnetworkinfo`, `bitcoin-cli help getnetworkinfo`, and `bitcoin-cli help getnettotals` (for the UNIX epoch time change). ACKs for top commit: eriknylund: > tACK [581b343](bitcoin@581b343) on master at [a0a422c](bitcoin@a0a422c), ran unit & functional tests and and confirmed changes on an existing datadir ✌️ benthecarman: tACK `581b343` willcl-ark: tACK for 581b343, this time rebased onto master at 862fde8. shesek: tACK `581b343`. This provides what I needed, thanks! n-thumann: tACK 581b343 on master at a0a422c, ran unit & functional tests and and confirmed changes on an existing datadir ✌️ Tree-SHA512: 08dd3ac8fefae401bd8253ff3ac027603c528eeccba53cedcb127771316173a7052fce44af8fa33ac98ebc4cf2a2b11cdefd949995d55e9b9a5942b876d00dc5
bf1f913 cli -netinfo: display multiple levels of details (Jon Atack) 077b3ac cli: change -netinfo optional arg from bool to int (Jon Atack) 4e2f2dd cli: add getpeerinfo last_{block,transaction} to -netinfo (Jon Atack) 644be65 cli: add -netinfo server version check and error message (Jon Atack) ce57bf6 cli: create peer connections report sorted by dir, minping (Jon Atack) f5edd66 cli: create vector of Peer structs for peers data (Jon Atack) 3a0ab93 cli: add NetType enum struct and NetTypeEnumToString() (Jon Atack) c227100 cli: create local addresses, ports, and scores report (Jon Atack) d3f77b7 cli: create inbound/outbound peer connections report (Jon Atack) 19377b2 cli: start dashboard report with chain and version header (Jon Atack) a3653c1 cli: tally peer connections by type (Jon Atack) 54799b6 cli: add ipv6 and onion address type detection helpers (Jon Atack) 12242b1 cli: create initial -netinfo option, NetinfoRequestHandler class (Jon Atack) Pull request description: This PR is inspired by laanwj's python script mentioned in #19405, which it turns out I ended up using every day and extending because I got hooked on using it to monitor Bitcoin peer connections. For the full experience, run `./src/bitcoin-cli -netinfo 4` On Linux, try it with watch `watch ./src/bitcoin-cli -netinfo 4` Help doc ``` $ ./src/bitcoin-cli -help | grep -A3 netinfo -netinfo Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0). ``` ACKs for top commit: vasild: ACK bf1f913 0xB10C: ACK bf1f913 practicalswift: ACK bf1f913 -- patch looks correct and is limited to `src/bitcoin-cli.cpp` Tree-SHA512: b9d18e5cc2ffd2bb9f0295b5ac7609da8a9bbecaf823a26dfa706b5f07d5d1a8343081dad98b16aa9dc8efd8f41bc1a4acdc40259727de622dc7195ccf59c572
bf1f913 cli -netinfo: display multiple levels of details (Jon Atack) 077b3ac cli: change -netinfo optional arg from bool to int (Jon Atack) 4e2f2dd cli: add getpeerinfo last_{block,transaction} to -netinfo (Jon Atack) 644be65 cli: add -netinfo server version check and error message (Jon Atack) ce57bf6 cli: create peer connections report sorted by dir, minping (Jon Atack) f5edd66 cli: create vector of Peer structs for peers data (Jon Atack) 3a0ab93 cli: add NetType enum struct and NetTypeEnumToString() (Jon Atack) c227100 cli: create local addresses, ports, and scores report (Jon Atack) d3f77b7 cli: create inbound/outbound peer connections report (Jon Atack) 19377b2 cli: start dashboard report with chain and version header (Jon Atack) a3653c1 cli: tally peer connections by type (Jon Atack) 54799b6 cli: add ipv6 and onion address type detection helpers (Jon Atack) 12242b1 cli: create initial -netinfo option, NetinfoRequestHandler class (Jon Atack) Pull request description: This PR is inspired by laanwj's python script mentioned in bitcoin#19405, which it turns out I ended up using every day and extending because I got hooked on using it to monitor Bitcoin peer connections. For the full experience, run `./src/bitcoin-cli -netinfo 4` On Linux, try it with watch `watch ./src/bitcoin-cli -netinfo 4` Help doc ``` $ ./src/bitcoin-cli -help | grep -A3 netinfo -netinfo Get network peer connection information from the remote server. An optional integer argument from 0 to 4 can be passed for different peers listings (default: 0). ``` ACKs for top commit: vasild: ACK bf1f913 0xB10C: ACK bf1f913 practicalswift: ACK bf1f913 -- patch looks correct and is limited to `src/bitcoin-cli.cpp` Tree-SHA512: b9d18e5cc2ffd2bb9f0295b5ac7609da8a9bbecaf823a26dfa706b5f07d5d1a8343081dad98b16aa9dc8efd8f41bc1a4acdc40259727de622dc7195ccf59c572
Summary: > Add in/out connections to rpc getnetworkinfo > UNIX_EPOCH_TIME fixup in rpc getnettotals > Add in/out connections to cli -getinfo This is a backport of [[bitcoin/bitcoin#19405 | core#19405]] Test Plan: `ninja check-functional` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D10180
This is basic info that is present in the GUI that I've been wishing to have exposed via the RPC and CLI without needing a bash workaround or script. For human users it would also be useful to have it in
-getinfo.bitcoin-cli getnetworkinfobitcoin-cli -getinfoUpdate the tests, RPC help, and release notes for the changes. Also fixup the
getnettotalstimemillis help while touchingrpc/net.cpp.Reviewers can manually test this PR by building from source, launching bitcoind, and then running
bitcoin-cli -getinfo,bitcoin-cli getnetworkinfo,bitcoin-cli help getnetworkinfo, andbitcoin-cli help getnettotals(for the UNIX epoch time change).