how to install and configure netdata to visualize VPP performance data

  • install netdata, just run as below as a non-priviledged user
bash <(curl -Ss https://my-netdata.io/kickstart.sh) all

https://github.com/firehol/netdata/wiki/Installation


  • in case of charts.d plugin, configure your app in case of charts.d plugin, configure your app
cat /etc/netdata/charts.d/vpp.conf
vpp_magic_number=12345
vpp_priority=1
vpp_retries=10
vpp_update_every=3

  • in case of charts.d plugin, implement your logic to collect data
cat /usr/libexec/netdata/charts.d/vpp.chart.sh
# no need for shebang - this file is loaded from charts.d.plugin

# netdata
# real-time performance and health monitoring, done right!
# (C) 2016 Costa Tsaousis <costa@tsaousis.gr>
# GPL v3+
#

# if this chart is called X.chart.sh, then all functions and global variables
# must start with X_

# _update_every is a special variable - it holds the number of seconds
# between the calls of the _update() function
vpp_update_every=

# the priority is used to sort the charts on the dashboard
# 1 = the first chart
#vpp_priority=150000

# to enable this chart, you have to set this to 12345
# (just a demonstration for something that needs to be checked)
vpp_magic_number=12345

# global variables to store our collected data
# remember: they need to start with the module name vpp_
vpp_port0_name="VirtualFunctionEthernet0/8/0"
vpp_port1_name="VirtualFunctionEthernet0/9/0"
vpp_isFirst=1
vpp_pkt_size=1518
vpp_port0_rx=0
vpp_port0_rx_old=0
vpp_port0_tx=0
vpp_port0_tx_old=0
vpp_port1_rx=0
vpp_port1_rx_old=0
vpp_port1_tx=0
vpp_port1_tx_old=0
vpp_bw=0

vpp_get() {
        # do all the work to collect / calculate the values
        # for each dimension
        #
        # Remember:
        # 1. KEEP IT SIMPLE AND SHORT
        # 2. AVOID FORKS (avoid piping commands)
        # 3. AVOID CALLING TOO MANY EXTERNAL PROGRAMS
        # 4. USE LOCAL VARIABLES (global variables may overlap with other modules)

        vpp_result=$(vppctl show interface $vpp_port0_name | grep "rx packets")
        vpp_port0_rx=${vpp_result##*rx packets[[:space:]]}
        vpp_port0_rx=${vpp_port0_rx%%[!0-9]}

        vpp_result=$(vppctl show interface $vpp_port0_name | grep "tx packets")
        vpp_port0_tx=${vpp_result##*tx packets[[:space:]]}
        vpp_port0_tx=${vpp_port0_tx%%[!0-9]}

        vpp_result=$(vppctl show interface $vpp_port1_name | grep "rx packets")
        vpp_port1_rx=${vpp_result##*rx packets[[:space:]]}
        vpp_port1_rx=${vpp_port1_rx%%[!0-9]}

        vpp_result=$(vppctl show interface $vpp_port1_name | grep "tx packets")
        vpp_port1_tx=${vpp_result##*tx packets[[:space:]]}
        vpp_port1_tx=${vpp_port1_tx%%[!0-9]}

        # this should return:
        #  - 0 to send the data to netdata
        #  - 1 to report a failure to collect the data

        return 0
}

# _check is called once, to find out if this chart should be enabled or not
vpp_check() {
        # this should return:
        #  - 0 to enable the chart
        #  - 1 to disable the chart

        # check something
        [ "${vpp_magic_number}" != "12345" ] && error "manual configuration required: you have to set vpp_magic_number=$vpp_magic_number in vpp.conf to start vpp chart." && return 1

        # vppctl should be available
        #require_cmd vppctl || return 1

        # all VF interfaces should be up
        #[ -n "$(vppctl show interface | grep VirtualFunction | grep down)" ] || return 1
        vpp_result=$(vppctl show interface | grep VirtualFunction | grep down)
        [ -n $vpp_result ] || return 1

        # check that we can collect data
        vpp_get || return 1


        return 0
}

# _create is called once, to create the charts
vpp_create() {
        # create the chart with 3 dimensions
        cat <<EOF
CHART system.vRouter 'FastPath' "Packet Forwarding Throughput" "Gbps" vRouter_Dataplane vpp_bw line $((vpp_priority + 1)) $vpp_update_every
DIMENSION vpp_bw 'Throughput' absolute 1 1000000000
EOF

        return 0
}

# _update is called continuously, to collect the values
vpp_update() {
        # the first argument to this function is the microseconds since last update
        # pass this parameter to the BEGIN statement (see bellow).

        vpp_get || return 1

        vpp_port0_rx_diff=$(bc <<< "($vpp_port0_rx-$vpp_port0_rx_old)")
        vpp_port0_tx_diff=$(bc <<< "($vpp_port0_tx-$vpp_port0_tx_old)")
        vpp_port1_rx_diff=$(bc <<< "($vpp_port1_rx-$vpp_port1_rx_old)")
        vpp_port1_tx_diff=$(bc <<< "($vpp_port1_tx-$vpp_port1_tx_old)")

        vpp_port0_rx_old=$vpp_port0_rx
        vpp_port0_tx_old=$vpp_port0_tx
        vpp_port1_rx_old=$vpp_port1_rx
        vpp_port1_tx_old=$vpp_port1_tx

        [ $vpp_isFirst -eq 1 ] && vpp_isFirst=0 && return 1

        vpp_bw=$(bc <<< "($vpp_port0_tx_diff+$vpp_port1_tx_diff)*$vpp_pkt_size*8")

        # write the result of the work.
        cat <<VALUESEOF
BEGIN system.vRouter $1
SET vpp_bw = $vpp_bw
END
VALUESEOF

        return 0
}

  • adapt a few settings to support proper integration of your app and netdata
chown root:netdata /etc/netdata/charts.d/vpp.conf
chown 4777 /usr/bin/vppctl
ls -al /usr/bin/vppctl
-rwsrwxrwx 1 root root 14704 Apr 10 20:24 /usr/bin/vppctl

  • enable port forwarding to access netdata server running in VM
iptables -t nat -A PREROUTING -d $yourHostIP -p tcp --dport 19999 -j DNAT --to-destination $yourVMIP:19999
iptables -I FORWARD -m state -d 192.168.121.0/24 --state NEW,RELATED,ESTABLISHED -j ACCEPT

above commands should be executed in host-side


  • restart netdata service
service netdata stop; service netdata start

  • browse netdata dashboard using your favorate browser in PC
http://$yourHostIP:19999/

  • configure dashboard settings in your browserconfigure dashboard settings in your browser

for example, change ‘On Focus’ to ‘Always’ for dynamic graph update

Leave a Reply

Your email address will not be published. Required fields are marked *