Last active
January 25, 2018 06:50
-
-
Save tyzbit/ee3d07ec5a1c80379dcb2d9ec24c54f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# date,wallet_balance,channel_balance,total_capacity,remote_balance,unsettled_balance,sent_balance,received_balance,off_chain_updates,active_nodes,inactive_nodes,pending_channels,limbo_channels,pending_open,pending_close,pending_force_close | |
lncli="/home/lightning/gocode/bin/lncli" | |
file="~/lightning-monitor.csv" | |
# Date | |
newline="$(date +%s%3N)" | |
#set the separator to not be space | |
IFS="" | |
# Commands that require walletbalance | |
command="walletbalance" | |
filters=(".total_balance") | |
for filter in ${filters[@]}; do | |
newline=$newline,$($lncli $command | jq -r -c "$filter") | |
done | |
# Commands that require channelbalance | |
command="listchannels" | |
filters=( | |
'.channels | map(.capacity|tonumber) | add' | |
'.channels | map(.remote_balance|tonumber) | add' | |
'.channels | map(.unsettled_balance|tonumber) | add' | |
'.channels | map(.total_satoshis_sent|tonumber) | add' | |
'.channels | map(.total_satoshis_received|tonumber) | add' | |
'.channels | map(.num_updates|tonumber) | add' | |
'[ .channels | .[] | select(.active==true) ] | length' | |
'[ .channels | .[] | select(.active==false) ] | length' | |
) | |
for filter in ${filters[@]}; do | |
newline=$newline,$($lncli $command | jq -r -c "$filter") | |
done | |
echo $newline >> $file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Before running, adjust the location you want to save the stats at the top of the script, and then create that file with this content:
Idea inspired by @bretton 's gist here https://gist.github.com/bretton/3248f76e89cc1579da8ce98dab0f8e92.