#!/bin/sh
#
#
#    Copyright (c) 1996-2015 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    File name:   flowVision.sh
#    Desc: dumps supportInfo for flowVision


start_dump() {
        ORG_PATH=`echo $PATH`
        export PATH=/fabos/link_bin:/bin:/usr/bin:/sbin:/usr/sbin:/fabos/link_abin:/fabos/link_sbin:/fabos/link_rbin:/fabos/factory:/fabos/xtool:.:/

        #Dump NM Info
        /bin/echo "======== FLOW VISION Data Switch $FABOS_SWITCHNO ========================"
        /bin/echo ""
        /bin/echo "------------ The flows active on this switch---------------------------"
        flow --show
        /bin/echo "------------ All flows active on this switch---------------------------"
        flow --show all
        /bin/echo ""

		switchshow | grep switchMode | grep -q Analytics
		ANALYTICS=$?
		if [ "$ANALYTICS" == 0 ]; then
			/bin/echo "------------ All Analytic IT Flows on this switch---------------------------"
			flow --show sys_mon_analytics -srcdev "*" -dstdev "*"
			/bin/echo ""
			/bin/echo "------------ Analytics resources on chassis ------------------------------"
			flow --show sys_mon_analytics -resource
			/bin/echo ""
			/bin/echo "------------ Flow PID DB related debug info -----------------"
			flow --debug pidlist 
			/bin/echo ""
		fi

		/bin/echo "------------ Flow Generator related debug info ---------------------------"
		flow --debug fg
		/bin/echo ""
		/bin/echo "------------ NP flow dump ---------------------------"
		flow --debug flow
		/bin/echo ""
		if [ "$FABOS_SWITCHNO" == 0 ]; then
			/bin/echo "------------ NP sysdb dump ---------------------------"
			flow --debug sysdb
			/bin/echo "------------ Flow Monitor related debug info ---------------------------"
			flow --debug fpm
			/bin/echo "------------ Flow Mirror related debug info -----------------"
			flow --debug mirror 
		fi
		/bin/echo ""
		/bin/echo ""
		/bin/echo "------------ NP deamon (npd) info---------------------------"
		npd_pid=`pidof npd` 
		if [ "$npd_pid" == "" ]; then
			/bin/echo "npd is not running" 
		else
			/bin/echo "------------output of ps aux---------------------------"
			/bin/ps aux | grep npd | grep -v grep
		fi
		/bin/echo ""
		/bin/echo "------------NP Config files ---------------------------"
		/bin/echo "------------output of ls /etc/fabos/np.*--------------------"
		/bin/ls -lh /etc/fabos/ | grep -i np
		/bin/echo ""
}

start_dump
