Files
_dotfiles/.config/i3blocks/tahoe-lafs/tahoe-lafs
2024-06-12 13:49:42 +02:00

23 lines
538 B
Bash
Executable File

#!/usr/bin/env bash
NODE_URL=${BLOCK_INSTANCE%/}
DISK_AVAIL=$(curl -s "$NODE_URL/statistics?t=json" 2>/dev/null| jq -r '.stats."storage_server.disk_avail"')
if [[ -n "$DISK_AVAIL" ]] && [[ "$DISK_AVAIL" != "null" ]]; then
DISK_AVAIL=$(echo "$DISK_AVAIL" | awk '
{
GB=$1/1024/1024/1024
if(GB<1000){
printf "%.1fG\n", GB
}
else{
printf "%.1fT\n", GB/1024
}
}')
echo "tahoe: $DISK_AVAIL"
else
echo "tahoe down"
echo "tahoe down"
echo "#FF0000"
fi