68 lines
2.0 KiB
Bash
Executable File
68 lines
2.0 KiB
Bash
Executable File
#!/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 [[[
|
|
ROOT_PART_USAGE=$(df | grep -m1 "/$" | awk '{print $5}')
|
|
# ]]]
|
|
|
|
#+++++++++++++++++++: 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)
|
|
if (df | grep "${PART_NAME}$" > /dev/null); then
|
|
PART_USAGE=$(df | grep "${PART_NAME}$" | awk '{print $5}')
|
|
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 ' ' -
|
|
|
|
NUMBER_PART=$(df -T | grep -c zfs)
|
|
LINE=1
|
|
|
|
while [ "${LINE}" -le "${NUMBER_PART}" ]; do
|
|
DISK_USAGE=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $6}')
|
|
PART_NAME=$(df -T | grep zfs | sed -n "${LINE},${LINE}p" | awk '{print $1}')
|
|
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}"
|