aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios/networking/networkcapacity.bash
blob: e2d3eb745b01e6e0f12009b24b0a42a46053be8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash

##############################################################################
# Copyright (c) 2016 Huawei Technologies Co.,Ltd and others.
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License, Version 2.0
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################

# Measure network capacity and scale of a host

set -e
OUTPUT_FILE=/tmp/netperf-out.log

# run capacity test
run_capacity()
{
    netstat -s > $OUTPUT_FILE
}

# write the result to stdout in json format
output_json()
{
    CONNECTIONS=$(awk '/active/{print $1}' $OUTPUT_FILE)
    FRAMES=$(awk '/total\ packets\ received/{print $1}' $OUTPUT_FILE)
    echo -e "{ \
        \"Number of connections\":\"$CONNECTIONS\", \
        \"Number of frames received\": \"$FRAMES\" \
    }"
}

main()
{
    run_capacity

    output_json
}

main