Wednesday, October 7, 2009

last knowledge from nsn

iseng aja sebelum lupa, posting last work at nsn which is creating a sigtran data collector for performance report.its a simple file collector trough FTP from nokia mss server to unix based system using standard shell script and doing some filtering using awk to filter its data,also maps the sigu module mapping to its mss links function.

#!/bin/bash

get_date() {

month=`date +%m`
day=`date +%d`
year=`date +%Y`
month=`expr $month + 0`
day=`expr $day - $1`
if [ $day -lt 1 ]; then
month=`expr $month - 1`
minusfix=`expr 0 - $day`
#echo $minusfix
if [ $month -eq 0 ]; then
month=12
day=31
year=`expr $year - 1`
else
case $month in
1|3|5|7|8|10|12) day=`expr 31 - $minusfix`;;
4|6|9|11) day=`expr 30 - $minusfix`;;
2)
if [ `expr $year % 4` -eq 0 ]; then
if [ `expr $year % 400` -eq 0 ]; then
day=29
elif [ `expr $year % 100` -eq 0 ]; then
day=28
else
day=29
fi
else
=28
fi
;;
esac
fi
fi
case $month in
[0-9]) month="0$month";;
esac
case $day in
[0-9]) day="0$day";;
esac
tgl="$year-$month-$day"
}


sigtran_converter() {

awk -v tes=$3 '{
if ($0 != "" && $0 !~ "CUMULATIVE" && $0 !~ "UNAVAILABLE") {
if ( $0 ~ /ASSOCIATION SET:/ ) {
x=$3
}else if ( $0 ~ /MSCi/ ) {
mss=$2
}else if ( $0 ~ /ASSOCIATION INDEX:/ ) {
c=$3
} else if ( $0 ~ /M3UA LAYER COUNTERS:/ ) {
y="M3UA"
}else if ( $0 ~ /SCTP LAYER COUNTERS:/ ) {
temp1=b","a","mss","x","c","z","w","u","v
y="SCTP"
}else if ( $0 ~ /SAMPLE DATE:/ ) {
a=$8
b=$7
}else if ( $0 ~ /NUMBER OF PACKETS:/ ) {
z=$4
w=$5
}else if ( $0 ~ /NUMBER OF OCTETS:/ ) {
u=$4
v=$5
}else if ( $0 ~ /NUMBER OF DUBLICATED TSN RECEIVED:/ && y !="" && b ~ tes ) {
print temp1","z","w","u","v
}
}
}' $1 > $path/temp/temp.csv

}

format_output() {
echo "Converted M3UAMEAA.TXT of MSS$2"
echo `date`
echo ""
echo "Date,Time,MSS,Assoc Set,Assoc Index,Sigu Unit,M3UA Packet Recieved,M3UA Packet Send,M3UA 0ctet Recieved,M3UA Octet Send,SCTP Packet Recieved,SCTP Packet Send,SCTP 0ctet Recieved,SCTP Octet Send"
while read baris
do
head=`echo $baris | awk -F"," '{print $1","$2}'`
pattern=`echo $baris | awk -F"," '{print $3","$4","$5}'`
tail=`echo $baris | awk -F"," '{print $6","$7","$8","$9","$10","$11","$12","$13}'`
sigu=`grep "$pattern," $path/SIGU.LST | awk -F"," '{print $4}'`
echo $head","$pattern","$sigu","$tail
done < $path/temp/temp.csv echo "" } timestmp=`date +%Y%m%d` path=`pwd` mkdir "temp/" ps -ef | grep "ftp -nv"| grep -v grep | xargs kill -9 get_date 1 while read mss_list do mss=`echo $mss_list|awk '{print $1}'` ip=`echo $mss_list|awk '{print $2}'` username=`echo $mss_list|awk '{print $3}'` password=`echo $mss_list|awk '{print $4}'` ftp -nv << !!! open $ip user $username $password prom asc cd REPORTS lcd $path/temp get M3UAMEAA.TXT bye !!! sigtran_converter $path/temp/M3UAMEAA.TXT $mss $tgl format_output > $path/temp/M3UAMEAA_MSS"$mss"_$timestmp.CSV
mv $path/temp/M3UAMEAA.TXT $path/temp/M3UAMEAA_MSS"$mss"_$timestmp.TXT
gzip -f $path/temp/M3UAMEAA_MSS"$mss"_$timestmp.CSV
gzip -f $path/temp/M3UAMEAA_MSS"$mss"_$timestmp.TXT


cat << !!! >> $path/sigtran_collector.log
`date` M3UAMEAA_MSS`echo $mss`_$timestmp.TXT
!!!

done < $path/ip_mss ftp -nv << !!! open 10.158.235.9 user spots1 Sp0tuser168 prom cd "/Report_from Nokia/MSS_SIGTRAN/" lcd $path/temp bin mput * bye !!! rm -rf $path/temp exit 0


oia,sitran is an signalling traffict that was send over IP network in packets.it uses m3ua protocols.

0 Comment :