#!/bin/bash

if [ $# != 2 ] ; then
	echo "Catch SNMP package of EMS"
	echo "Usage: catch param/subs/csta/cdr fileName"
	exit
fi

case $1 in
"param")
	port=4958;;
"subs")
	port=4959;;
"csta")
	port=4954;;
"cdr")
	port=4968;;
"heartbeat")
	port=4957;;
*)
	echo "Error kind $1"
	exit
esac

echo "Catch ... After finishing, you can get the package from /usr/local/apache/htdocs/"
`tcpdump -x port $port -s1500 -v -w /usr/local/apache/htdocs/$2.cap`
parse_snmp /usr/local/apache/htdocs/$2.cap > /usr/local/apache/htdocs/$2_out.txt

