2018-08-08 15:15:02 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# .. vim: foldmarker=[[[,]]]:foldmethod=marker
|
|
|
|
|
|
|
|
# {{ ansible_managed }}
|
|
|
|
|
|
|
|
# Colors definition [[[
|
|
|
|
BLACK='\033[49;30m'
|
|
|
|
BLACKB='\033[49;90m'
|
|
|
|
RED='\033[0;31m'
|
|
|
|
REDB='\033[1;31m'
|
|
|
|
GREEN='\033[0;32m'
|
|
|
|
YELLOW='\033[0;33m'
|
|
|
|
BLUE='\033[94;49m'
|
|
|
|
MAGENTA='\033[0;35m'
|
|
|
|
CYAN='\033[36;49m'
|
|
|
|
WHITE='\033[0;37m'
|
|
|
|
BOLD='\033[1m'
|
|
|
|
RESET='\033[0m'
|
|
|
|
# ]]]
|
|
|
|
# Vars definition [[[
|
2023-02-08 16:10:56 +01:00
|
|
|
ROOT_PART_USAGE=$(df --local | grep -m1 "/$" | awk '{print $5}')
|
2018-08-08 15:15:02 +02:00
|
|
|
# ]]]
|
|
|
|
|
|
|
|
#+++++++++++++++++++: Disk Usage :+++++++++++++++++++
|
|
|
|
printf '%b' "${RESET}"
|
|
|
|
printf "${BLACKB}%33s${RESET}" | tr ' ' -
|
|
|
|
printf '%b' " ${CYAN}Disk Usage${RESET} "
|
|
|
|
printf "${BLACKB}%34s${RESET}\\n" | tr ' ' -
|
|
|
|
|
|
|
|
# Root partition
|
|
|
|
## Replaced by rootfs in few kernel version
|
|
|
|
PRINTF_ROOT_NAME=$(printf '%-22s' "/")
|
|
|
|
printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_ROOT_NAME}${RESET}${BLACKB}= ${CYAN}${ROOT_PART_USAGE}${RESET}\\n"
|
|
|
|
|
|
|
|
# Other partition
|
|
|
|
for PART_NAME in /boot /home /opt /srv /tmp /tmp /usr /var /var/lib/docker /var/lib/vz; do
|
|
|
|
## "/...$" : $ to grep only the mount point and not sub-directories (/var: OK; /mnt/temp: nOK)
|
2023-02-08 16:10:56 +01:00
|
|
|
if (df --local | grep "${PART_NAME}$" > /dev/null); then
|
|
|
|
PART_USAGE=$(df --local | grep "${PART_NAME}$" | awk '{print $5}')
|
2018-08-08 15:15:02 +02:00
|
|
|
PRINTF_PART_NAME=$(printf '%-22s' "${PART_NAME}")
|
|
|
|
printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET}${BLACKB}= ${CYAN}${PART_USAGE}${RESET}\\n"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
## IF ZFS [[[
|
|
|
|
#+++++++++++++++++++: ZFS Usage :+++++++++++++++++++
|
|
|
|
if [ "$(command -v zpool)" ]; then
|
|
|
|
printf '%b' "${RESET}"
|
|
|
|
printf "${BLACKB}%32s${RESET}" | tr ' ' -
|
|
|
|
printf '%b' " ${CYAN}${BOLD}ZFS${RESET} ${CYAN}Partition${RESET} "
|
|
|
|
printf "${BLACKB}%33s${RESET}\\n" | tr ' ' -
|
|
|
|
|
2023-02-08 16:10:56 +01:00
|
|
|
NUMBER_PART=$(df --local --print-type | grep -c zfs)
|
2018-08-08 15:15:02 +02:00
|
|
|
LINE=1
|
|
|
|
|
|
|
|
while [ "${LINE}" -le "${NUMBER_PART}" ]; do
|
2023-02-08 16:10:56 +01:00
|
|
|
DISK_USAGE=$(df --local --print-type | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}')
|
|
|
|
PART_NAME=$(df --local --print-type | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}')
|
2018-08-08 15:15:02 +02:00
|
|
|
PRINTF_PART_NAME=$(printf '%-23s' "${PART_NAME}")
|
|
|
|
printf '%b' "${BLACKB}+ ${WHITE}${PRINTF_PART_NAME}${RESET} ${CYAN}${DISK_USAGE}${RESET}\\n"
|
|
|
|
LINE=$((LINE+1))
|
|
|
|
# Bash ONLY: (( LINE++ ))
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
## FI ZFS ]]]
|
|
|
|
|
|
|
|
printf '%b' "${RESET}"
|