-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathovs-collect
executable file
·68 lines (58 loc) · 2.09 KB
/
ovs-collect
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
## -*- mode: bash; indent-tabs-mode: nil; perl-indent-level: 4 -*-
## vim: autoindent tabstop=4 shiftwidth=4 expandtab softtabstop=4 filetype=bash
interval=$1; shift
ovs_dir="/var/run/openvswitch"
vswitchd_pid=$(pgrep ovs-vswitchd)
re='^[1-9][0-9]*$'
if [[ ! "$interval" =~ $re ]]; then
echo "Interval must a be a positive interger, exiting"
exit 1
fi
if [ ! -e $ovs_dir ]; then
echo "ERROR: could not find $ovs_dir"
exit 1
fi
declare -A cmd_opts
cmd_opts["ovs-vsctl"]="show"
cmd_opts["ovs-ofctl"]="show"
for cmd in ${!cmd_opts[@]}; do
echo "cmd: $cmd"
ver=$($cmd --version)
rc=$?
if [ $rc -gt 0 ]; then
echo "Could not run $cmd"
exit 1
fi
done
bridges=$(ovs-vsctl --db=unix:"$ovs_dir"/db.sock list-br)
echo "bridges: $bridges"
echo
echo "$ovs_dir:"
/bin/ls -l "$ovs_dir"
echo
ofctl_cmds=("dump-ports --names" "dump-flows")
appctl_cmds=("dpctl/dump-flows --more --names" "dpctl/ct-stats-show" "dpctl/show --statistics"\
"coverage/show" "memory/show" "upcall/show" "dpif-netdev/pmd-perf-show")
target="--target "$ovs_dir"/ovs-vswitchd.$vswitchd_pid.ctl"
while true; do
for bridge in $bridges; do
for ofctl_cmd in "${ofctl_cmds[@]}"; do
ofctl_file=ofctl-`echo $ofctl_cmd | awk '{print $1}' | sed -e sX/X-X`.txt
echo >>$ofctl_file
echo "DATE:$(date +%s.%N)" >>$ofctl_file
echo "[ovs-ofctl $ofctl_cmd $bridge]" >>$ofctl_file
ovs-ofctl -O OpenFlow15 $ofctl_cmd unix:"$ovs_dir"/$bridge.mgmt >>$ofctl_file
done
done
## see https://www.openvswitch.org/support/dist-docs/ovs-vswitchd.8.html "DATAPATH FLOW TABLE DEBUGGING COMMANDS"
ovs-appctl $target dpif-netdev/pmd-stats-clear 2>&1 >> pmd-stats-clear.stdouterr.txt
sleep $interval
for appctl_cmd in "${appctl_cmds[@]}"; do
appctl_file=appctl-`echo $appctl_cmd | awk '{print $1}' | sed -e sX/X-X`.txt
echo >>$appctl_file
echo "DATE:$(date +%s.%N)" >>$appctl_file
echo ovs-appctl $target $appctl_cmd '>>'$appctl_file
ovs-appctl $target $appctl_cmd >>$appctl_file
done
done