Bugfix: modify comment bugs in TC055 and TC075
[yardstick.git] / yardstick / benchmark / scenarios / networking / networkcapacity.bash
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
11
12 # Measure network capacity and scale of a host
13
14 set -e
15 OUTPUT_FILE=/tmp/netperf-out.log
16
17 # run capacity test
18 run_capacity()
19 {
20     netstat -s > $OUTPUT_FILE
21 }
22
23 # write the result to stdout in json format
24 output_json()
25 {
26     CONNECTIONS=$(awk '/active/{print $1}' $OUTPUT_FILE)
27     FRAMES=$(awk '/total\ packets\ received/{print $1}' $OUTPUT_FILE)
28     echo -e "{ \
29         \"Number of connections\":\"$CONNECTIONS\", \
30         \"Number of frames received\": \"$FRAMES\" \
31     }"
32 }
33
34 main()
35 {
36     run_capacity
37
38     output_json
39 }
40
41 main