Have you ever wondered who is hogging all the storage? Below are a few quick scripts you can consolidate in a .sh file that will expose data hoarders and will help you keep your environment nice and tidy!
echo -e "------------------------------------\n
Storage Snapshot on `date`\n
-------------------------------------"
echo "Storage Snapshot"
sudo df -h
echo -e "------------------------------------\n
Top Storage Usage by SAMBA Share /mnt/storage \n
-------------------------------------"
sudo du -hs /mnt/storage/* | sort -hr | head
echo -e "------------------------------------\n
10 Largest Files on SAMBA Share w/ Last Mod Date - /mnt/storage \n
-------------------------------------"
sudo find /mnt/storage -type f -exec du -Sh --time {} + | sort -rh | head
echo -e "------------------------------------\n
Top Storage Usage for SASHOME /home\n
-------------------------------------"
sudo du -hs /home/* | sort -hr | head
echo -e "------------------------------------\n
10 Largest Files in SASHOME w/ Last Mod Date - /home \n
-------------------------------------"
sudo find /home -type f -exec du -Sh --time {} + | sort -rh | head
echo " "echo -e "------------------------------------\n
SAMBA Usage Report \n
-------------------------------------"
sudo smbstatus –b
Email output:
~$ ./storage.sh > ~/storage.txt
~$ mail -s "SAS Storage Snapshot for SASApp on `date`" sasadmins < /home/userid/storage.txt
* sasadmins is an alias set in the /etc/aliases
~$ sudo vi /etc/aliases
add the following:
sasadmins: email1@address, email2@addres...
~$ sudo newaliases – this updates the config so you can use the new alias