OSDN Git Service

trunk整理
[ultramonkey-l7/ultramonkey-l7-v3.git] / test / script / snmpagent / snmpagent-10.sh
1 #!/bin/bash
2
3 # set config file
4 . ${SET_DEFAULT_CONF}
5
6 #copy config file
7 \cp -f materials/snmpagent-1-19-l7vs.cf ${L7VSD_CONF_DIR}/l7vs.cf
8
9 #Start snmptrapd
10 ${SNMPTRAPD} -c ./materials/snmpagent-1-19-snmptrapd.conf -Lf ${L7VS_LOG_DIR}/snmpagent-1-19-snmptrapd.log
11
12 #Run http server
13 RealServer1=RealServer1
14 RealServer1_ADDR=127.0.0.1
15 RealServer1_PORT=50001
16 start_lighttpd -s $RealServer1 -a $RealServer1_ADDR -p $RealServer1_PORT
17 if [ $? -ne 0 ]
18 then
19         echo "Test failed: start_lighttpd RealServer1"
20         exit 1
21 fi
22
23
24 #Start L7VAD Service
25 $L7VSD
26 if [ $? -ne 0 ]
27 then
28         echo "Test failed: $L7VSD"
29         exit 1
30 fi
31 usleep 100000
32
33 #Add Virtual Service
34 $L7VSADM -A -t 127.0.0.1:40001 -m ip -Q 50M
35 if [ $? -ne 0 ]
36 then
37         echo "Test failed: $L7VSADM -A -t 127.0.0.1:40001 -m ip"
38         exit 1
39 fi
40
41 #Add Real Service
42 $L7VSADM -a -t 127.0.0.1:40001 -m ip -r 127.0.0.1:50001
43 if [ $? -ne 0 ]
44 then
45         echo "Test failed: $L7VSADM -a -t 127.0.0.1:40001 -m ip -r 127.0.0.1:50001"
46         exit 1
47 fi
48
49 #Make 10M.dat in materials 
50 dd if=/dev/zero of=${TMP_DIR}/10M.dat bs=1024 count=10240
51
52 #Get The File
53 $WGET http://127.0.0.1:40001 --post-file ${TMP_DIR}/10M.dat -t 1
54 if [ $? -ne 0 ]
55 then
56         echo "Test failed: $WGET http://127.0.0.1:40001 --post-file 10M.dat"
57         exit 1
58 fi
59
60 usleep 2000000
61
62 #Check Traplog
63 cat ${L7VS_LOG_DIR}/snmpagent-1-19-snmptrapd.log
64
65 RET=`cat  ${L7VS_LOG_DIR}/snmpagent-1-19-snmptrapd.log | grep -e  "SNMPv2-SMI::enterprises.32132.1.0.2.8 = STRING: \"[0-9]\{4\}/[0-9]\{2\}/[0-9]\{2\} [0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\},TRAP00020008,Warning release: The up-throughput has fell below the release threshold of up-QoS warning."`
66
67 if [ -z "${RET}" ]
68 then
69         echo "Test failed: cat ${L7VS_LOG_DIR}/snmpagent-1-19-snmptrapd.log"
70         exit 1
71 fi
72 exit 0