#4399 Add SmartCrtl/HDD-Temp info (#4422)

SmartCrtl/HDD-Temp info in ..
- as part of blitz.datadrive.sh
- background scan & cache values
- LCD info
- debug info
This commit is contained in:
/rootzoll 2024-02-16 15:47:57 +01:00 committed by GitHub
parent 26d5e18e7d
commit 1a092f8ee7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 70 additions and 41 deletions

View file

@ -326,7 +326,7 @@ ${color_yellow} ${color_gray}${network^} Fullnode${LNinfo} ${torIn
${color_yellow} ,/ ${color_yellow}%s
${color_yellow} ,'/ ${color_gray}%s
${color_yellow} ,' / ${color_gray}%s, temp %s°C %s°F
${color_yellow} ,' /_____ ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDDuse ${color_hdd}%s${color_gray}
${color_yellow} ,' /_____ ${color_gray}Free Mem ${color_ram}${ram} ${color_gray} HDD ${color_hdd}%s${color_gray}
${color_yellow},'_____ ,' ${color_gray}SSH admin@${internet_localip}${color_gray} d${internet_rx} u${internet_tx}
${color_yellow} / ,' ${color_gray}${webuiinfo}
${color_yellow} / ,' ${color_gray}${network} ${color_green}${networkVersion}${color_gray}${chain}net ${networkConnectionsInfo}

View file

@ -268,6 +268,27 @@ do
/home/admin/_cache.sh set internet_online "${online}"
fi
###################
# HARDDRIVE
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE2} ]; then
echo "updating: /home/admin/config.scripts/blitz.datadrive.sh status"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
/home/admin/_cache.sh set hdd_mounted "${isMounted}"
/home/admin/_cache.sh set hdd_ssd "${isSSD}"
/home/admin/_cache.sh set hdd_btrfs "${isBTRFS}"
/home/admin/_cache.sh set hdd_raid "${isRaid}"
/home/admin/_cache.sh set hdd_uasp "${hddAdapterUSAP}"
/home/admin/_cache.sh set hdd_capacity_bytes "${hddBytes}"
/home/admin/_cache.sh set hdd_capacity_gb "${hddGigaBytes}"
/home/admin/_cache.sh set hdd_free_bytes "${hddDataFreeBytes}"
/home/admin/_cache.sh set hdd_free_gb "${hddDataFreeGB}"
/home/admin/_cache.sh set hdd_used_info "${hddUsedInfo}"
/home/admin/_cache.sh set hddTemperature "${hddTemperature}"
/home/admin/_cache.sh set hddTBSize "${hddTBSize}"
fi
# exit if still setup or higher system stopped
source <(/home/admin/_cache.sh get setupPhase state)
if [ "${setupPhase}" != "done" ] ||
@ -296,25 +317,6 @@ do
# read/update config values
source /mnt/hdd/raspiblitz.conf
###################
# HARDDRIVE
if [ "${stillvalid}" == "0" ] || [ ${age} -gt ${MINUTE2} ]; then
echo "updating: /home/admin/config.scripts/blitz.datadrive.sh status"
source <(/home/admin/config.scripts/blitz.datadrive.sh status)
/home/admin/_cache.sh set hdd_mounted "${isMounted}"
/home/admin/_cache.sh set hdd_ssd "${isSSD}"
/home/admin/_cache.sh set hdd_btrfs "${isBTRFS}"
/home/admin/_cache.sh set hdd_raid "${isRaid}"
/home/admin/_cache.sh set hdd_uasp "${hddAdapterUSAP}"
/home/admin/_cache.sh set hdd_capacity_bytes "${hddBytes}"
/home/admin/_cache.sh set hdd_capacity_gb "${hddGigaBytes}"
/home/admin/_cache.sh set hdd_free_bytes "${hddDataFreeBytes}"
/home/admin/_cache.sh set hdd_free_gb "${hddDataFreeGB}"
/home/admin/_cache.sh set hdd_used_info "${hddUsedInfo}"
/home/admin/_cache.sh set hdd_blockchain_data "${hddBlocksBitcoin}"
fi
###################
# BITCOIN

View file

@ -209,16 +209,17 @@ if [ "$1" = "status" ]; then
fi
# try to detect if its an SSD
isSMART=$(sudo smartctl -a /dev/${hdd} | grep -c "Rotation Rate:")
isSMART=$(sudo smartctl -a /dev/${hdd} | grep -c "Serial Number:")
echo "isSMART=${isSMART}"
if [ ${isSMART} -gt 0 ]; then
#detect using smartmontools (preferred)
isSSD=$(sudo smartctl -a /dev/${hdd} | grep 'Rotation Rate:' | grep -c "Solid State")
else
#detect using using fall back method
isSSD=$(cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
fi
isSSD=1
isRotational=$(echo "${smartCtlA}" | grep -c "Rotation Rate:")
if [ ${isRotational} -gt 0 ]; then
isSSD=$(echo "${smartCtlA}" | grep "Rotation Rate:" | grep -c "Solid State Device")
fi
echo "isSSD=${isSSD}"
hddTemp=""
echo "hddTemperature="
echo "hddTemperatureStr='?°C'"
# display results from hdd & partition detection
echo "hddCandidate='${hdd}'"
@ -448,15 +449,16 @@ if [ "$1" = "status" ]; then
fi
echo "hddRaspiVersion='${hddRaspiVersion}'"
smartCtlA=$(sudo smartctl -a /dev/${hdd} | tr -d '"')
# try to detect if its an SSD
isSMART=$(sudo smartctl -a /dev/${hdd} | grep -c "Rotation Rate:")
isSMART=$(echo "${smartCtlA}" | grep -c "Serial Number:")
echo "isSMART=${isSMART}"
if [ ${isSMART} -gt 0 ]; then
#detect using smartmontools (preferred)
isSSD=$(sudo smartctl -a /dev/${hdd} | grep 'Rotation Rate:' | grep -c "Solid State")
else
#detect using using fall back method
isSSD=$(cat /sys/block/${hdd}/queue/rotational 2>/dev/null | grep -c 0)
isSSD=1
isRotational=$(echo "${smartCtlA}" | grep -c "Rotation Rate:")
if [ ${isRotational} -gt 0 ]; then
isSSD=$(echo "${smartCtlA}" | grep "Rotation Rate:" | grep -c "Solid State Device")
fi
echo "isSSD=${isSSD}"
@ -465,6 +467,13 @@ if [ "$1" = "status" ]; then
echo "hddCandidate='${hdd}'"
echo "hddPartitionCandidate='${hddDataPartition}'"
# check temp if possible
hddTemp=$(echo "${smartCtlA}" | grep "^Temperature" | head -n 1 | grep -o '[0-9]\+')
if [ hddTemp = "" ]; then
hddTemp=$(echo "${smartCtlA}" | grep "^194" | tr -s ' ' | cut -d" " -f 10 | grep -o '[0-9]\+')
fi
echo "hddTemperature=${hddTemp}"
# check if blockchain data is available
hddBlocksBitcoin=$(ls /mnt/hdd/bitcoin/blocks/blk00000.dat 2>/dev/null | grep -c '.dat')
echo "hddBlocksBitcoin=${hddBlocksBitcoin}"
@ -482,6 +491,7 @@ if [ "$1" = "status" ]; then
sizeDataPartition=$(lsblk -o NAME,SIZE -b | grep "${hddDataPartition}" | awk '$1=$1' | cut -d " " -f 2)
hddGigaBytes=$(echo "scale=0; ${sizeDataPartition}/1024/1024/1024" | bc -l)
fi
hddBytes=${sizeDataPartition}
echo "hddBytes=${sizeDataPartition}"
echo "hddGigaBytes=${hddGigaBytes}"
@ -498,21 +508,36 @@ if [ "$1" = "status" ]; then
datadrive=$(df -h | grep "/dev/${hdd}${nvp}1" | sed -e's/ */ /g' | cut -d" " -f 5)
storageDrive=$(df -h | grep "/dev/${hdd}${nvp}2" | sed -e's/ */ /g' | cut -d" " -f 5)
hdd_data_free1Kblocks=$(df -h -k /dev/${hdd}${nvp}1 | grep "/dev/${hdd}${nvp}1" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
hddUsedInfo="${datadrive} & ${storageDrive}"
hddUsedInfo="${datadrive} ${storageDrive}"
elif [ "${isZFS}" -gt 0 ]; then
# ZFS calculations
hdd_used_space=$(($(zpool list -pH | awk '{print $3}')/1024/1024/1024))
hdd_used_ratio=$((100 * hdd_used_space / hddGigaBytes))
hdd_data_free1Kblocks=$(($(zpool list -pH | awk '{print $4}') / 1024))
hddUsedInfo="${hdd_used_space} (${hdd_used_ratio}%)"
hddUsedInfo="${hdd_used_ratio}%"
else
# EXT4 calculations
hdd_used_space=$(df -h | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 3 2>/dev/null)
hdd_used_ratio=$(df -h | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 5 | tr -dc '0-9' 2>/dev/null)
hdd_data_free1Kblocks=$(df -h -k /dev/${hddDataPartitionExt4} | grep "/dev/${hddDataPartitionExt4}" | sed -e's/ */ /g' | cut -d" " -f 4 | tr -dc '0-9')
hddUsedInfo="${hdd_used_space} (${hdd_used_ratio}%)"
hddUsedInfo="${hdd_used_ratio}%"
fi
echo "hddUsedInfo='${hddUsedInfo}'"
hddTBSize="<1TB"
if [ ${hddBytes} -gt 800000000000 ]; then
hddTBSize="1TB"
fi
if [ ${hddBytes} -gt 1800000000000 ]; then
hddTBSize="2TB"
fi
if [ ${hddBytes} -gt 2300000000000 ]; then
hddTBSize=">2TB"
fi
if [ "${hddTemp}" != "" ]; then
hddUsedInfo="${hdd_used_ratio}% ${hddTemp}°C"
fi
echo "hddTBSize='${hddTBSize}'"
echo "hddUsedInfo='${hddTBSize} ${hddUsedInfo}'"
hddDataFreeBytes=$((${hdd_data_free1Kblocks} * 1024))
hddDataFreeGB=$((${hdd_data_free1Kblocks} / (1024 * 1024)))
echo "hddDataFreeBytes=${hddDataFreeBytes}"

View file

@ -444,7 +444,9 @@ sudo du -sh /var/log
echo
echo "*** DATADRIVE ***"
source <(sudo /home/admin/config.scripts/blitz.datadrive.sh status)
sudo /home/admin/config.scripts/blitz.datadrive.sh status
sudo smartctl -a /dev/${datadisk}
echo
echo "*** NETWORK ***"

View file

@ -6,7 +6,7 @@
source /home/admin/raspiblitz.info 2>/dev/null
# get values from cache
source <(/home/admin/_cache.sh get codeVersion internet_localip blitzapi)
source <(/home/admin/_cache.sh get codeVersion internet_localip blitzapi hdd_used_info system_temp_celsius)
# 1st PARAMETER: eventID
# fixed ID string for a certain event
@ -34,7 +34,7 @@ if [ "${mode}" != "lcd" ] && [ "${mode}" != "ssh" ]; then
fi
# default backtitle for dialog
backtitle="RaspiBlitz ${codeVersion} / ${eventID} / ${internet_localip}"
backtitle="${codeVersion} ${eventID} / ${internet_localip} ${system_temp_celsius}°C ${hdd_used_info}"
################################################
# 1) WELL DEFINED EVENTS