标签:磁盘空间
#!/bin/shos_ver=`uname`
if [ "$os_ver" = "Linux" ]; then
#line_num=`df -h|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$5) {print $6 " " $5}' |wc -l`
line_num=`df -h|grep -v Filesystem|grep -v proc |grep '[[:digit:]]' | awk ' gsub(/%/,"",$(NF-1)){print $NF,$(NF-1)}' |wc -l`
i=0
echo "["
df -h|grep -v Filesystem|grep -v proc |grep '[[:digit:]]' | awk ' gsub(/%/,"",$(NF-1)){print $NF,$(NF-1)}'|while read v_file v_precent
#df -h|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$5) {print $6 " " $5}'|while read v_file v_precent
do
let i=i+1
if [ $i -lt $line_num ]; then
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"
else
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"
fi
done
echo "]"
elif [ "$os_ver" = "AIX" ]; then
i=0
line_num=`df -g|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$4) {print $7 " " $4}' |wc -l`
echo "["
df -g|grep -v Filesystem|grep -v proc|awk ' gsub(/%/,"",$4) {print $7 " " $4}'|while read v_file v_precent
do
let i=i+1
if [ $i -lt $line_num ]; then
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"
else
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"
fi
done
echo "]"
else
line_num=`bdf |grep -v Filesystem|grep '[[:digit:]]' |awk 'gsub(/%/,"",$(NF-1)) {print $NF,$(NF-1)}' |wc -l`
#line_num=`bdf |grep -v Filesystem|awk ' gsub(/%/,"",$5) {print $6 " " $5}' |wc -l`
i=0
echo "["
bdf |grep -v Filesystem|grep '[[:digit:]]' |awk 'gsub(/%/,"",$(NF-1)) {print $NF,$(NF-1)}'|while read v_file v_precent
#bdf |grep -v Filesystem|awk ' gsub(/%/,"",$5) {print $6 " " $5}'|while read v_file v_precent
do
let i=i+1
if [ $i -lt $line_num ]; then
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"},"
else
echo "{\"v_file\":\"$v_file\",\"v_precent\":\"$v_precent\"}"
fi
done
echo "]"
fi
标签:磁盘空间
原文地址:http://blog.51cto.com/11310506/2129041