correlation https://teguhth.blogspot.com/2025/12/script-check-size-database-base-on-size.html
1. check dbsize full
sh cek_teguhth.sh
[root@teguhth-all ceksizemaria]# cat cek_teguhth.sh
#!/bin/bash
BASE_DIR="/var/lib/mysql/teguhth"
echo "Database Directory Size Report"
echo "=============================="
printf "%-25s %10s\n" "FOLDER" "SIZE"
echo "------------------------------"
du -sh ${BASE_DIR}/* 2>/dev/null | sort -h | while read size folder; do
printf "%-25s %10s\n" "$(basename "$folder")" "$size"
done
echo "------------------------------"
echo "TOTAL:"
du -sh "$BASE_DIR" | awk '{print $1}'
[root@teguhth-all ceksizemaria]#
2. check dbsize exclude table pembelian
sh cek_teguhth_nopembelian.sh
[root@teguhth-all ceksizemaria]# cat cek_teguhth_nopembelian.sh
#!/bin/bash
BASE_DIR="/var/lib/mysql/teguhth"
echo "Database Directory Size Report"
echo "=============================="
printf "%-25s %10s\n" "FOLDER" "SIZE"
echo "------------------------------"
du -sh --exclude='pembelian.ibd' ${BASE_DIR}/* 2>/dev/null | sort -h | while read size folder; do
printf "%-25s %10s\n" "$(basename "$folder")" "$size"
done
echo "------------------------------"
echo "TOTAL:"
du -sh --exclude='pembelian.ibd' "$BASE_DIR" | awk '{print $1}'
[root@teguhth-all ceksizemaria]#
3. check dbsize exclude table pembelian & table pasok
sh cek_teguhth_nopem_nopa.sh
[root@teguhth-all ceksizemaria]# cat cek_teguhth_nopem_nopa.sh
#!/bin/bash
BASE_DIR="/var/lib/mysql/teguhth"
echo "Database Directory Size Report"
echo "=============================="
printf "%-25s %10s\n" "FOLDER" "SIZE"
echo "------------------------------"
du -sh --exclude='pasok.ibd' --exclude='pembelian.ibd' \
${BASE_DIR}/* 2>/dev/null | sort -h | while read size folder; do
printf "%-25s %10s\n" "$(basename "$folder")" "$size"
done
echo "------------------------------"
echo "TOTAL:"
du -sh \
--exclude='pasok.ibd' \
--exclude='pembelian.ibd' \
"$BASE_DIR" | awk '{print $1}'
[root@teguhth-all ceksizemaria]#





No comments:
Post a Comment