527bfcf9259eba3f823331ec5931fb3a5fda6aea
[sliver-openvswitch.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 alias vswitch='service vswitch'
9
10 function watchconf {
11     watch cat /etc/ovs-vswitchd.conf
12 }
13
14 function watchdp {
15         watch ovs-dpctl show "$@"
16 }
17
18 function watchdpflows {
19         local grep=""
20         local dp=$1
21         shift
22         if [ $# -gt 0 ]; then
23                 grep="| grep $@"
24         fi
25         watch "ovs-dpctl dump-flows $dp $grep"
26 }
27
28 function watchflows {
29         local grep=""
30         local dp=$1
31         shift
32         bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3)
33         if [ $# -gt 0 ]; then
34                 grep="| grep $@"
35         fi
36         watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep"
37 }
38
39 function monitorlogs {
40     local grep=""
41     if [ $# -gt 0 ]; then
42         grep="| grep --line-buffered '^==> .* <==$"
43         for i in "$@"; do
44             grep="$grep\|$i"
45         done
46         grep="$grep'"
47     fi
48     cmd="tail -F /var/log/messages /var/log/ovs-vswitchd.log /var/log/xensource.log $grep | tee /var/log/monitorlogs.out"
49     printf "cmd: $cmd\n"
50     eval "$cmd"
51 }