- 论坛徽章:
- 0
|
db2 list applications 显示的连接ip是十六进制的,有时候需要根据ip杀连接,实在是麻烦,所以我自己写了两个bash函数:
hex2dec()
{
echo $((16#${1:0:2})).$((16#${1:2:2})).$((16#${1:4:2})).$((16#${1:6:2}))
}
db2who()
{
db2 list applications | awk '{print $4}'| awk -F'.' '/^C/{print $1}' > ./tmp1.txt
for i in `cat ./tmp1.txt`
do
hex2dec $i >> ./tmp2.txt
done
unset i
sort -d ./tmp2.txt | uniq -c
echo "Total :" `cat ./tmp2.txt | wc -l`
rm ./tmp1.txt ./tmp2.txt
}
dec2hex()
{
i=`echo $1 | awk -F'.' '{printf "%02X %02X %02X %02X", $1, $2, $3, $4}'`
echo $i| sed 's/ //g'
unset i
}
db2kick()
{
HEX=`dec2hex $1`
db2 list applications | grep $HEX | awk '{print $3}' > ./tmp1.txt
for i in `cat ./tmp1.txt`
do
db2 "force application($i)"
done
unset i
unset HEX
rm ./tmp1.txt
}
我对db2和shell都只有粗浅的了解,不知各位有没有更好的解决办法,写这种函数也挺难看的
[ 本帖最后由 xn_sung 于 2007-8-31 18:36 编辑 ] |
|