daily pastebin goal
55%
SHARE
TWEET

Untitled

a guest Aug 10th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. # set colors
  4. color_red='\033[0;31m'
  5. color_green='\033[0;32m'
  6. color_yellow='\033[0;33m'
  7. color_gray='\033[0;37m'
  8.  
  9. # set datadir
  10. litecoin_dir="/home/litecoin/.litecoin"
  11. lnd_dir="/home/litecoin/.lnd"
  12.  
  13. # get uptime & load
  14. load=$(w | grep "load average:" | cut -c11-)
  15.  
  16. # get CPU temp
  17. cpu=$(cat /sys/class/thermal/thermal_zone0/temp)
  18. temp=$((cpu/1000))
  19.  
  20. # get memory
  21. ram_avail=$(free -m | grep Mem | awk '{ print $7 }')
  22. ram=$(printf "%sM / %sM" "${ram_avail}" "$(free -m | grep Mem | awk '{ print $2 }')")
  23.  
  24. if [ ${ram_avail} -lt 100 ]; then
  25.   color_ram="${color_red}\e[7m"
  26. else
  27.   color_ram=${color_green}
  28. fi
  29.  
  30. # get storage
  31. sd_free_ratio=$(printf "%d" "$(df -h | grep "/$" | awk '{ print $4/$2*100 }')") 2>/dev/null
  32. sd=$(printf "%s (%s%%)" "$(df -h | grep '/$' | awk '{ print $4 }')" "${sd_free_ratio}")
  33. if [ ${sd_free_ratio} -lt 10 ]; then
  34.   color_sd="${color_red}"
  35. else
  36.   color_sd=${color_green}
  37. fi
  38.  
  39. # get network traffic
  40. network_rx=$(ifconfig eth0 | grep 'RX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
  41. network_tx=$(ifconfig eth0 | grep 'TX packets' | awk '{ print $6$7 }' | sed 's/[()]//g')
  42.  
  43. # litecoin blockchain
  44. ltc_path=$(command -v litecoin-cli)
  45. if [ -n ${ltc_path} ]; then
  46.   ltc_title="Litecoin"
  47.   chain="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.chain')"
  48.   if [ -n $chain ]; then
  49.     ltc_title="${ltc_title} (${chain}net)"
  50.  
  51.     # get sync status
  52.     block_chain="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.headers')"
  53.     block_verified="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.blocks')"
  54.     block_diff=$(expr ${block_chain} - ${block_verified})
  55.  
  56.     progress="$(litecoin-cli -datadir=${litecoin_dir} getblockchaininfo | jq -r '.verificationprogress')"
  57.     sync_percentage=$(printf "%.2f%%" "$(echo $progress | awk '{print 100 * $1}')")
  58.  
  59.     if [ ${block_diff} -eq 0 ]; then    # fully synced
  60.       sync="OK"
  61.       sync_color="${color_green}"
  62.       sync_behind=" "
  63.     elif [ ${block_diff} -eq 1 ]; then          # fully synced
  64.       sync="OK"
  65.       sync_color="${color_green}"
  66.       sync_behind="-1 block"
  67.     elif [ ${block_diff} -le 10 ]; then    # <= 2 blocks behind
  68.       sync="Catching up"
  69.       sync_color="${color_red}"
  70.       sync_behind="-${block_diff} blocks"
  71.     else
  72.       sync="In progress"
  73.       sync_color="${color_red}"
  74.       sync_behind="${sync_percentage}"
  75.     fi
  76.  
  77.     # get last known block
  78.     last_block="$(litecoin-cli -datadir=${litecoin_dir} getblockcount)"
  79.     if [ ! -z "${last_block}" ]; then
  80.       ltc_line2="${ltc_line2} ${color_gray}(block ${last_block})"
  81.     fi
  82.  
  83.     # get mem pool transactions
  84.     mempool="$(litecoin-cli -datadir=${litecoin_dir} getmempoolinfo | jq -r '.size')"
  85.  
  86.   else
  87.     ltc_line2="${color_red}NOT RUNNING\t\t"
  88.   fi
  89. fi
  90.  
  91. printf "
  92. ${color_green}    .~~.   .~~.      ${color_yellow}%s: ${color_gray}Litecoin Core
  93. ${color_green}   '. \ ' ' / .'     ${color_yellow}%s
  94. ${color_red}    .~ .~~~..~.      ${color_gray}%s, CPU Temp %s°C
  95. ${color_red}   : .~.'~'.~. :
  96. ${color_red}  ~ (   ) (   ) ~    ${color_yellow}%-24s %-24s %-20s
  97. ${color_red} ( : '~'.~.'~' : )   ${color_gray}Memory   ${color_ram}%-16s${color_gray}Sync    ${sync_color}%-14s${color_gray} ${alias_color}%s
  98. ${color_red}  ~ .~ (   ) ~. ~    ${color_gray}SSD      ${color_sd}%-16s${color_gray}        %-14s ${external_color}%s
  99. ${color_red}   (  : '~' :  )     ${color_gray}HDD      ${color_hdd}%-16s${color_gray}Public  ${public_color}%-14s ${color_gray}%s/%s Channels
  100. ${color_red}    '~ .~~~. ~'      ${color_gray}Traffic  ▲ %-12s  %-20s   Ł %12s sat
  101. ${color_red}        '~'          ${color_gray}         ▼ %-12s  Mempool %-14s 🗲 %12s sat
  102. ${color_red}                     ${color_yellow}%s
  103. %s %s
  104. " \
  105. "Raspberry Pi" \
  106. "-------------------------------------------------------------------" \
  107. "${load}" "${temp}" \
  108. "Resources free" "${ltc_title}" \
  109. "${ram}" "${sync}" \
  110. "${sd}" "${sync_behind}" \
  111. "${hdd}" "${public}" \
  112. "${network_tx}" \
  113. "${network_rx}" "${mempool} tx" \
  114. ""
  115.  
  116. echo "$(tput -T xterm sgr0)"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top