以前写了一个统计dbspace利用率的脚本,加上这两天为了重建数据库写了一个原版复制原来库的dbspace和chunk的脚本,觉得比较有用,贴出来供大家参考,脚本都以onstat -d为基础
#!/bin/ksh
########################################################
#
# Author: 饮鸩止渴@chinaunix.net
# Date : 2004-10-25 pm 16:27
# Version: 1.00
# Description:
# Check for informix database's chunks and make a
# report.
#
########################################################
echo "NUM DBSNAME DBSNUM USEDNUM TOTALSIZE USEDSIZE % "
echo "--- ------------------- ------ ------- --------- --------- ----"
/opt/informix/bin/onstat -d | awk '
#BEGIN {printf "%-4s%-20s%-7s%-8s%-10s%-10s%-5s\n","NUM","DBSNAME","CHKNUM","USEDNUM","TOTALSIZE","USEDSIZE","%"
# printf "--- ------------------- ------ ------- --------- --------- ----\n"
# }
#$5 ~ /nchunks/ && {print $0}
$3 ~ /^0/ {
chk[$2]=$8
if ($7 ~ /T/) chk[$2]=$9
num[$2]=$5
spendnum[$2]=0
total[$2]=0
used[$2]=0
}
$7 ~ /^P/ {
total[$3]+=$5
used[$3]+=($5-$6)
free=$6/$5*100000
if (free < 1000) spendnum[$3]++
}
END {
for (name in chk)
printf "%0-4d%-20s%-7d%-8d%-10d%-10d%-5d\n",name,chk[name],num[name],spendnum[name]+1,total[name],used[name],used[name]/total[name]*100
}
' | sort -n -k1
#######################################################
#
# Last change: 2004-10-25 17:58
#
#######################################################
#!/bin/ksh
########################################################
#
# Author: 饮鸩止渴@chinaunix.net
# Date : 2005-08-11 pm 13:40
# Version: 1.00
# Description:
#
#
########################################################
#echo "--- ------------------- ------ ------- --------- --------- ----"
/opt/informix/bin/onstat -d | awk '
#BEGIN {printf "%-4s%-20s%-7s%-8s%-10s%-10s%-5s\n","NUM","DBSNAME","CHKNUM","USEDNUM","TOTALSIZE","USEDSIZE","%"
# printf "--- ------------------- ------ ------- --------- --------- ----\n"
# }
#$5 ~ /nchunks/ && {print $0}
$3 ~ /^0/ {
chk[$2]=$8
init[$2]=1
if ($7 ~ /T/) chk[$2]=$9
}
$7 ~ /^P/ {
size=$5*2
offsite=$4
phy=$8
name=chk[$3]
if (init[$3]==1){
str="-c -d"
init[$3]++
}
else{
str="-a"
init[$3]++
}
printf "onspaces %s %s -o %d -p %s -s %d\n",str,name,offsite,phy,size
}
'
#######################################################
#
# Last change: 2005-08-11 13:40
#
#######################################################