Import from old repository commit 61ef2b42a9c4ba8e1600f15bb0236765edc2ad45.
[cascardo/ovs.git] / xenserver / etc_profile.d_vswitch.sh
1 # Copyright (C) 2009 Nicira Networks, Inc.
2 #
3 # Copying and distribution of this file, with or without modification,
4 # are permitted in any medium without royalty provided the copyright
5 # notice and this notice are preserved.  This file is offered as-is,
6 # without warranty of any kind.
7
8 PATH=/root/vswitch/bin:$PATH
9 export PATH
10 MANPATH=/root/vswitch/share/man:$MANPATH
11 export MANPATH
12
13 alias vswitch='service vswitch'
14
15 function watchconf {
16     watch cat /etc/ovs-vswitchd.conf
17 }
18
19 function watchdp {
20         watch ovs-dpctl show "$@"
21 }
22
23 function watchdpflows {
24         local grep=""
25         local dp=$1
26         shift
27         if [ $# -gt 0 ]; then
28                 grep="| grep $@"
29         fi
30         watch "ovs-dpctl dump-flows $dp $grep"
31 }
32
33 function watchflows {
34         local grep=""
35         local dp=$1
36         shift
37         bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3)
38         if [ $# -gt 0 ]; then
39                 grep="| grep $@"
40         fi
41         watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep"
42 }
43
44 function monitorlogs {
45     local grep=""
46     if [ $# -gt 0 ]; then
47         grep="| grep --line-buffered '^==> .* <==$"
48         for i in "$@"; do
49             grep="$grep\|$i"
50         done
51         grep="$grep'"
52     fi
53     cmd="tail -F /var/log/messages /var/log/ovs-vswitchd.log /var/log/xensource.log $grep | tee /var/log/monitorlogs.out"
54     printf "cmd: $cmd\n"
55     eval "$cmd"
56 }