#!/bin/bash
# setting up irq affinity according to /proc/interrupts
get_irq () {
NIC=` ip a |grep -B2 -w inet |grep 'state UP' |awk '{print $2}'|tr -d ':'`
if [ `echo "$NIC"|grep bond |wc -l ` -ne 0 ]; then
NIC=`ip a |grep 'state UP' |grep -v "bond[0-9]:" |awk '{print $2}' |tr -d ':'`
fi
echo > /tmp/irq_info.txt
for i in $NIC; do
irq_num=`cat /proc/interrupts |grep ${i}- | awk '{print $1}'|tr -d ':'`
for n in $irq_num; do
irq_affinity=`cat /proc/irq/$n/smp_affinity`
echo ${i}:${n}:$irq_affinity >> /tmp/irq_info.txt
sed -i "/^$/d" /tmp/irq_info.txt
done
done
echo > /tmp/diff_irq.txt
sed -i '/^$/d' /tmp/diff_irq.txt
for i in $NIC;do
value=` grep $i /tmp/irq_info.txt |head -4|grep -o "..$"`
echo $value >>/tmp/diff_irq.txt
done
answer=`cat /tmp/diff_irq.txt |uniq`
if [ "$answer" == "01 02 04 08" ]
then
echo "good! set irq success!"
exit 0
else
echo "sorry!!! please set irq again~~"
exit 1
fi
#rm -rf /tmp/diff_irq.txt
}
get_irq
阅读(3624) | 评论(0) | 转发(0) |