#!/bin/bash

# Require By zhoutianyi in 2020-11-02
# Update: 2021-04-20

# ovs command existence
which ovs-ofctl > /dev/null
if [[ $? -ne 0 ]];then
	exit 0
fi

# br0 existence
if [[ $(ovs-vsctl list-br|grep -cE "^br0$") -eq 0 ]];then
	exit 0
fi

count=$(ovs-ofctl dump-aggregate br0 -Oopenflow13|awk -F "flow_count=" '{print $2}' 2> /dev/null)

echo "[{\"value\":$count,\"tags\":\"\"}]"
