From 3983cf67212038f6c0c752dcbbe56d00137d8cfb Mon Sep 17 00:00:00 2001 From: pyr0ball Date: Wed, 8 Mar 2023 12:57:30 -0800 Subject: [PATCH] refactored disk info --- lib/skel/.bashrc.d/11-quickinfo.bashrc | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/lib/skel/.bashrc.d/11-quickinfo.bashrc b/lib/skel/.bashrc.d/11-quickinfo.bashrc index 61d60a3..8c6da2b 100644 --- a/lib/skel/.bashrc.d/11-quickinfo.bashrc +++ b/lib/skel/.bashrc.d/11-quickinfo.bashrc @@ -291,7 +291,22 @@ for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do macs=(${macs[@]} "$(cat /sys/class/net/${device}/address)") done -# Begin echo out of formatted table with agregated information +################################ + +# Disk array setup +declare -a logicals=() +declare -a mounts=() +declare -a usages=() +declare -a freespaces=() +diskinfo=$(/bin/df -h | grep "$allowed_disk_prefixes" | grep -v "$disallowed_disks") +logicals=($(cut -d ' ' -f1 <<< "${diskinfo}")) +mounts=($(awk '{print $6}' <<< "${diskinfo}")) +usages=($(awk '{print $5}' <<< "${diskinfo}")) +freespaces=($(awk '{print $4}' <<< "${diskinfo}")) + +################################ + +# Begin echo out of formatted table with aggregated information boxtop boxline "" @@ -299,7 +314,7 @@ boxline "${bld}${unl}Location:${dfl} ${grn}${unl}$location${dfl}" boxline "" # Echo out network arrays for((i=0; i<"${#adapters[@]}"; i++ )); do - boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl} | ${blu}${macs[$i]}${dfl}" + boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl}\t| ${blu}${macs[$i]}${dfl}" done boxline " WAN IP: ${ylw}${wan_ip}${dfl}" boxline "" @@ -310,9 +325,10 @@ boxline "${bld}${unl}System Status${dfl}" boxline " System Load: ${load_averages}" boxline " CPU Temp: ${lbl}${cputemp}${dfl} | Utilization: ${lrd}${cpu_util}%${dfl}" boxline " Memory used/total: ${mem_usage}" -boxline " Disk Usage:" -for i in $(/bin/df -h | grep "$allowed_disk_prefixes" | grep -v "$disallowed_disks" | awk '{print $1}') ; do -boxline " `/bin/df -h | grep $i | awk '{print $5}'` $i: `/bin/df -h | grep $i | awk '{print $6}'`" +boxline " ${unl}Disk Info:${dfl}" +boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Logical)${dfl}" +for((i=0; i<"${#logicals[@]}"; i++ )); do + boxline "\t$(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})" done boxline "" if [[ $(echo ${packages} | grep -c ^0\ updates) != 1 ]] || [ -z "${supdates}" ] || [ -z "${release_upgrade}" ] ; then