#!/bin/sh
#
#
#    Copyright (c) 2010-2020 Brocade Communications Systems, Inc.
#    All rights reserved.
#
#    File name:   StuckFlowDetection.sh
#    Module name: an/
#
#  NAME
#     scmonitor - enable or disable stuck flow detection
#
#  SYNOPSIS
#     scmonitor 0 or 1
#
#  AVAILABILITY
#     root
#
#  DESCRIPTION
#     Use  this  command  to  enable or disable stuck flow deetction
#
#
#  OPTIONS
# 		The input is 0 (disable) or 1 (enable).
#

export PATH=/fabos/sbin:/fabos/bin:/bin:/usr/bin:/sbin

#set ROLE to root pass remaining RBAC checks. Don't do it before rbac_check
if [ "$ROLE_ID" != "root" ]
then
	echo "Error: this command is available only to the root user."
	exit 0
fi

if [ $# != 1 ]
then
	echo "Error: Invalid arguments."
	echo "Usage: scmonitor 1/0"
	exit 0
fi

if [ $1 == 1 ] || [ $1 == 0 ]
then
	echo $1 > /tmp/stuckvcdata.conf
	/fabos/cliexec/bottleneckmon --status > /dev/null
else
	echo "Error: Invalid arguments."
	echo "Usage: scmonitor 1/0"
	exit 0
fi
