This project is not being actively supported, the code is not expected to work nor reflects the latests improvements in our tooling stack
A toy project to produce a cool looking CLI dashboard for the NEAR platform.
- clone this repo
- install Sampler with
brew install sampler
- start the dashboard with
npm start
Sampler is a "A tool for shell commands execution, visualization and alerting. Configured with a simple YAML file."
This project provides a near.yml
configuration file for Sampler that renders a dashboard against the NEAR platform by polling data from various NEAR endpoints over HTTP.
It depends on Sampler being installed along with the availability of curl
, awk
and printf
at the terminal.
Caveat: this project was only tested on a 2015 Macbook Pro.
The NEAR platform exposes multiple status endpoints for polling over HTTP for TestNet:
At the terminal you can use this command (wherever curl
is available) to fetch network status
curl -s https://rpc.nearprotocol.com/status
see explainshell for details on the line above
Another utility, jq, is used to process the results that arrive as JSON
curl -s https://rpc.nearprotocol.com/status | jq '.chain_id'
see explainshell for details on the line above
And awk is used to extract data when multiple values are retrieved together and printf us used to format the results for presentation.
curl -s https://rpc.nearprotocol.com/metrics | grep '^block_produced_total' | awk -F ' ' '{ printf(" %d", $2) }'
see explainshell for details on the line above
Note
Another endpoint is available but not currently used by this dashboard
The dashboard is configured using near.yml
. See Sampler documentation for details on the format.
All requests used by the dashboard are also available in the file dev/requests.sh
. This file is executable and running it will generate all the data being used to drive the dashboard, although without the pretty formatting.
A fake /status
endpoint is included for sizing the dashboard to variable size data like number of validators. To use this utility use npm run dev
to start a local server and edit the near.yml
file anywhere you see the /status
endpoint being used. Since the data is polled, any edits to dev/db.json
will appear in the dashboard with the next request.
There are lots of dashboard builders like this:
- Go https://github.com/gizak/termui (used by Sampler)
- Rust https://github.com/fdehau/tui-rs
- JavaScript https://github.com/yaronn/blessed-contrib