- 论坛徽章:
- 0
|
COLSEP="|||"
getHostType(){
hosttype=`uname -s`
echo $hosttype
}
refreshlast(){
netstat -i | sed -n '2,$p'
}
CURR_STAT=/tmp/netstatis.tmp
#add for table
TABLE_FILE="./sys_netfluxs.table"
if [ ! -f $TABLE_FILE ]
then
case `getHostType` in
HP-UX)
echo 'ID'$COLSEP'01.01.09.01'$COLSEP'01.01.09.02'$COLSEP'01.01.09.05'$COLSEP'01.01.09.06'$COLSEP'01.01.09.07' >> $TABLE_FILE
;;
SunOS)
echo 'ID'$COLSEP'01.02.09.01'$COLSEP'01.02.09.02'$COLSEP'01.02.09.05'$COLSEP'01.02.09.06'$COLSEP'01.02.09.07' >> $TABLE_FILE
;;
AIX)
echo 'ID'$COLSEP'01.07.09.01'$COLSEP'01.07.09.02'$COLSEP'01.07.09.05'$COLSEP'01.07.09.06'$COLSEP'01.07.09.07' >> $TABLE_FILE
;;
SCO_SV)
echo 'ID'$COLSEP'01.05.09.01'$COLSEP'01.05.09.02'$COLSEP'01.05.09.05'$COLSEP'01.05.09.06'$COLSEP'01.05.09.07' >> $TABLE_FILE
;;
Linux)
IO_RESULT=`sed '1,2d;s@^[^a-z]*@@;s@ @' /proc/net/dev | awk '{print $0}'`
echo "$IO_RESULT" | awk 'BEGIN{print "ID'$COLSEP'01.03.04.01'$COLSEP'01.03.04.02'$COLSEP'01.03.04.03'$COLSEP'01.03.04.04'$COLSEP'01.03.04.05'$COLSEP'01.03.04.06'$COLSEP'01.03.04.07'$COLSEP'01.03.04.08"}{if(NR>0) print ""$1"'$COLSEP'"$2"'$COLSEP'"$3"'$COLSEP'"$4"'$COLSEP'"$5"'$COLSEP'"$10"'$COLSEP'"$11"'$COLSEP'"$12"'$COLSEP'"$13""}'
exit
;;
esac
fi
#add end
refreshlast > $CURR_STAT
grep -v '^$' $CURR_STAT | while read line
do
NAME=`echo $line | awk '{print $1}'`
IN_S=`echo $line | awk '{print $5}'`
OUT_S=`echo $line | awk '{print $7}'`
IERR=`echo $line | awk '{print $6}'`
OERR=`echo $line | awk '{print $8}'`
OCOL=`echo $line | awk '{print $9}'`
echo "$NAME$COLSEP$IN_S$COLSEP$OUT_S$COLSEP$IERR$COLSEP$OERR$COLSEP$OCOL" >> $TABLE_FILE
#add end
done
#add for table
if [ -f $TABLE_FILE ]
then
cat $TABLE_FILE
rm $TABLE_FILE
else :
fi
#add end |
|