df 监控磁盘空闲空间
环境:
[oracle@simpleit shell]$ uname -a
Linux simpleit.domain.cn 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:35 EDT 2010 i686 athlon i386 GNU/Linux
[oracle@simpleit shell]$ cat /etc/redhat-release
CentOS release 5.5 (Final)
[oracle@simpleit shell]$ df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 5952284 4627568 1017476 82% /
/dev/sda1 101086 29931 65936 32% /boot
tmpfs 505360 0 505360 0% /dev/shm
[oracle@simpleit shell]$ df -kl
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 5952284 4627568 1017476 82% /
/dev/sda1 101086 29931 65936 32% /boot
tmpfs 505360 0 505360 0% /dev/shm
df displays the amount of disk space
available on the file system containing each file name argument. If no file name is given,
the space available on all currently mounted file systems is shown. Disk space is shown in
1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case
512-byte blocks are used.
-k like --block-size=1K
-l, --local
limit listing to local file systems
一个小脚本:
####################################################################
## disk_free_space.sh ##
## created by Laughing ##
## 2012-01-06 ##
####################################################################
#!/bin/bash
df -kl | grep -iv Filesystem | awk '{ print $6", "$5}' |
while
read LINE;
do
ITEM=`echo $LINE | awk -F ',' '{ print $2 }' | awk -F '%' '{ print $1 }'`
if [ $ITEM -ge 90 ]
then
echo "`date` - ${LINE} space used on `hostname` "
fi
done
[oracle@simpleit shell]$ ./disk_free_space.sh
Sun Dec 18 16:10:25 CST 2011 - /, 82% space used on simpleit.domain.cn
Sun Dec 18 16:10:25 CST 2011 - /boot, 32% space used on simpleit.domain.cn