forked from colin/disk-space-report
Update disk-check.sh
This commit is contained in:
parent
3b9c70433a
commit
fa251952e2
|
@ -33,7 +33,7 @@ estimate_tmp_size() {
|
||||||
# Function to estimate the size of unused Docker volumes
|
# Function to estimate the size of unused Docker volumes
|
||||||
estimate_docker_volumes_size() {
|
estimate_docker_volumes_size() {
|
||||||
echo "Estimating the size of unused Docker volumes:"
|
echo "Estimating the size of unused Docker volumes:"
|
||||||
docker volume ls -qf dangling=true | xargs -I {} docker volume inspect --format '{{ .Mountpoint }}' {} | xargs -I {} du -sh {} | awk '{ sum += $1 } END { print sum "B" }'
|
docker volume ls -qf dangling=true | xargs -I {} docker volume inspect --format '{{ .Mountpoint }}' {} | xargs -I {} sudo du -sh {} | awk '{ sum += $1 } END { print sum "B" }'
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,4 +47,45 @@ check_docker_logs() {
|
||||||
echo
|
echo
|
||||||
echo "Consider setting up logrotate to manage Docker logs."
|
echo "Consider setting up logrotate to manage Docker logs."
|
||||||
echo "To truncate all Docker logs, run:"
|
echo "To truncate all Docker logs, run:"
|
||||||
echo 'sudo find /var/lib/docker/containers/ -type f -name "*.
|
echo 'sudo find /var/lib/docker/containers/ -type f -name "*.log" -exec truncate -s 0 {} \;'
|
||||||
|
echo
|
||||||
|
else
|
||||||
|
echo "No large Docker logs found."
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to list directories consuming more than a specified size
|
||||||
|
list_large_directories() {
|
||||||
|
local directory=$1
|
||||||
|
local size_limit=$2
|
||||||
|
echo "Directories in $directory consuming more than ${size_limit}GB:"
|
||||||
|
sudo du -ah $directory 2>/dev/null | awk -v limit=$size_limit '{
|
||||||
|
size=$1; unit=substr(size, length(size));
|
||||||
|
size_val=substr(size, 1, length(size)-1);
|
||||||
|
if ((unit=="G" && size_val+0 > limit) || (unit=="T" && size_val*1024 > limit)) {
|
||||||
|
print
|
||||||
|
}
|
||||||
|
}'
|
||||||
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
# Estimate storage savings
|
||||||
|
echo "Estimating potential storage savings..."
|
||||||
|
estimate_apt_cache_size
|
||||||
|
estimate_old_packages_size
|
||||||
|
estimate_journal_size
|
||||||
|
estimate_tmp_size
|
||||||
|
estimate_docker_volumes_size
|
||||||
|
|
||||||
|
# Check Docker logs
|
||||||
|
check_docker_logs
|
||||||
|
|
||||||
|
# List large directories
|
||||||
|
echo "Listing directories consuming more than 5GB and 10GB:"
|
||||||
|
list_large_directories / 5
|
||||||
|
list_large_directories /home 5
|
||||||
|
list_large_directories / 10
|
||||||
|
list_large_directories /home 10
|
||||||
|
|
||||||
|
echo "Storage savings estimation and large directory listing completed."
|
||||||
|
|
Loading…
Reference in New Issue