aboutsummaryrefslogtreecommitdiff
path: root/xenserver/etc_profile.d_openvswitch.sh
blob: 63b254359fc1ab3337c1c6aeae3de1c584cdc425 (plain)
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
# Copyright (C) 2009, 2010, 2011 Nicira, Inc.
#
# Copying and distribution of this file, with or without modification,
# are permitted in any medium without royalty provided the copyright
# notice and this notice are preserved.  This file is offered as-is,
# without warranty of any kind.

alias vswitch='service openvswitch'
alias openvswitch='service openvswitch'

function watchdp {
	watch ovs-dpctl show "$@"
}

function watchdpflows {
	local grep=""
	local dp=$1
	shift
	if [ $# -gt 0 ]; then
		grep="| grep $@"
	fi
	watch "ovs-dpctl dump-flows $dp $grep"
}

function watchflows {
	local grep=""
	local dp=$1
	shift
	bridge=$(ovs-dpctl show $dp | grep 'port 0:' | cut -d' ' -f 3)
	if [ $# -gt 0 ]; then
		grep="| grep $@"
	fi
	watch "ovs-ofctl dump-flows unix:/var/run/$bridge.mgmt $grep"
}

function monitorlogs {
    local grep=""
    if [ $# -gt 0 ]; then
        grep="| grep --line-buffered '^==> .* <==$"
        for i in "$@"; do
            grep="$grep\|$i"
        done
        grep="$grep'"
    fi
    cmd="tail -F /var/log/messages /var/log/openvswitch/ovs-vswitchd.log /var/log/openvswitch/ovsdb-server /var/log/xensource.log $grep | tee /var/log/monitorlogs.out"
    printf "cmd: $cmd\n"
    eval "$cmd"
}