Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # set colors
- color_red='\033[0;31m'
- color_green='\033[0;32m'
- color_yellow='\033[0;33m'
- color_gray='\033[0;37m'
- # set datadir
- litecoin_dir="/home/litecoin/.litecoin"
- lnd_dir="/home/litecoin/.lnd"
- # get uptime & load
- load=$(w | grep "load average:" | cut -c11-)
- # get CPU temp
- cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
- temp=$((cpu/1000))
- # get memory
- ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
- ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")
- if [ ${ram_avail} -lt 100 ]; then
- color_ram="${color_red}\e[7m"
- else
- color_ram=${color_green}
- fi
- # get storage
- sd_free_ratio=$(printf "%d" "$(df -h | grep "/$" | awk '{ print $4/$2*100 }')") 2>/dev/null
- sd=$(printf "%s (%s%%)" "$(df -h | grep '/$' | awk '{ print $4 }')" "${sd_free_ratio}")
- if [ ${sd_free_ratio} -lt 10 ]; then
- color_sd="${color_red}"
- else
- color_sd=${color_green}
- fi
- # get network traffic
- network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
- network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
- # litecoin blockchain
- ltc_path=$(command -v litecoin-cli)
- if [ -n ${ltc_path} ]; then
- ltc_title="Litecoin"
- chain="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.chain')"
- if [ -n $chain ]; then
- ltc_title="${ltc_title} (${chain}net)"
- # get sync status
- block_chain="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.headers')"
- block_verified="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.blocks')"
- block_diff=$(expr ${block_chain} - ${block_verified})
- progress="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.verificationprogress')"
- sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
- if [ ${block_diff} -eq 0 ]; then # fully synced
- sync="OK"
- sync_color="${color_green}"
- sync_behind=" "
- elif [ ${block_diff} -eq 1 ]; then # fully synced
- sync="OK"
- sync_color="${color_green}"
- sync_behind="-1 block"
- elif [ ${block_diff} -le 10 ]; then # <= 2 blocks behind
- sync="Catching up"
- sync_color="${color_red}"
- sync_behind="-${block_diff} blocks"
- else
- sync="In progress"
- sync_color="${color_red}"
- sync_behind="${sync_percentage}"
- fi
- # get last known block
- last_block="$(litecoin-cli -datadir=${litecoin_dir} getblockcount)"
- if [ ! -z "${last_block}" ]; then
- ltc_line2="${ltc_line2} ${color_gray}(block ${last_block})"
- fi
- # get mem pool transactions
- mempool="$(litecoin-cli -datadir=${litecoin_dir} getmempoolinfo | jq -r '.size')"
- else
- ltc_line2="${color_red}NOT RUNNING\t\t"
- fi
- fi
- printf "
- ${color_green} .~~. .~~. ${color_yellow}%s: ${color_gray}Litecoin Core
- ${color_green} '. \ ' ' / .' ${color_yellow}%s
- ${color_red} .~ .~~~..~. ${color_gray}%s, CPU Temp %s°C
- ${color_red} : .~.'~'.~. :
- ${color_red} ~ ( ) ( ) ~ ${color_yellow}%-24s %-24s %-20s
- ${color_red} ( : '~'.~.'~' : ) ${color_gray}Memory ${color_ram}%-16s${color_gray}Sync ${sync_color}%-14s${color_gray} ${alias_color}%s
- ${color_red} ~ .~ ( ) ~. ~ ${color_gray}SSD ${color_sd}%-16s${color_gray} %-14s ${external_color}%s
- ${color_red} ( : '~' : ) ${color_gray}HDD ${color_hdd}%-16s${color_gray}Public ${public_color}%-14s ${color_gray}%s/%s Channels
- ${color_red} '~ .~~~. ~' ${color_gray}Traffic ▲ %-12s %-20s Ł %12s sat
- ${color_red} '~' ${color_gray} ▼ %-12s Mempool %-14s 🗲 %12s sat
- ${color_red} ${color_yellow}%s
- %s %s
- " \
- "Raspberry Pi" \
- "-------------------------------------------------------------------" \
- "${load}" "${temp}" \
- "Resources free" "${ltc_title}" \
- "${ram}" "${sync}" \
- "${sd}" "${sync_behind}" \
- "${hdd}" "${public}" \
- "${network_tx}" \
- "${network_rx}" "${mempool} tx" \
- ""
- echo "$(tput -T xterm sgr0)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement