knowledge base


linux scripts



monitor disk usage with alarm

#find . -maxdepth 1 -exec du -ks {} \; | sort -rn | head -n 15 > /tmp/bigfiles.txt [root@oradb1 samba]# cat /etc/dus.sh #!/bin/bash system=`hostname --fqdn` email=mailadress@domain.net # # WARNING if disk usage is over 90%. # # check /opt/oracle # for dev in `df /opt/oracle | grep -v tmpfs | egrep -o ^/dev/[[:alnum:]]\{3,4\}`; do used=`df /opt/oracle | grep ^$dev | egrep -o [0-9]\{1,2\}% | egrep -o [0-9]\{1,2\}` # the percent of space used is stored in $used if [ $used -ge 90 ]; then echo "!WARNING! Disk usage on oradb1 /opt is $used%." | mail -s "!WARNING! oradb1 disk usage /opt" $email fi done # # check /opt/oracle/fast_recovery_area/LINUX/datafile # for dev in `df /opt/oracle/fast_recovery_area/LINUX/datafile | grep -v tmpfs | egrep -o ^/dev/[[:alnum:]]\{3,4\}`; do used=`df /opt/oracle/fast_recovery_area/LINUX/datafile | grep ^$dev | egrep -o [0-9]\{1,2\}% | egrep -o [0-9]\{1,2\}` # the percent of space used is stored in $used if [ $used -ge 90 ]; then echo "!WARNING! Disk usage on oradb1 /opt/oracle/fast_recovery_area/LINUX/datafile is $used%." | mail -s "!WARNING! oradb1 disk usage fast_recovery_area" $email fi done # # check /samba # for dev in `df /samba | grep -v tmpfs | egrep -o ^/dev/[[:alnum:]]\{3,4\}`; do used=`df /samba | grep ^$dev | egrep -o [0-9]\{1,2\}% | egrep -o [0-9]\{1,2\}` # the percent of space used is stored in $used if [ $used -ge 90 ]; then echo "!WARNING! Disk usage on oradb1 /samba is $used%." | mail -s "!WARNING! oradb1 samba" $email fi done # # check /samba/LV # for dev in `df /samba/LV | grep -v tmpfs | egrep -o ^/dev/[[:alnum:]]\{3,4\}`; do used=`df /samba/LV | grep ^$dev | egrep -o [0-9]\{1,2\}% | egrep -o [0-9]\{1,2\}` # the percent of space used is stored in $used if [ $used -ge 90 ]; then echo "!WARNING! Disk usage on oradb1 /samba/LV (on SRV-FS01) is $used%." | mail -s "!WARNING! oradb1 samba/LV on SRV-FS01" $email fi done