Mini Shell

Direktori : /proc/self/root/proc/thread-self/root/opt/dell/srvadmin/sbin/
Upload File :
Current File : //proc/self/root/proc/thread-self/root/opt/dell/srvadmin/sbin/dataeng-helper

#!/usr/bin/env bash
###############################################################################
#
#          Dell Inc. PROPRIETARY INFORMATION
# This software is supplied under the terms of a license agreement or
# nondisclosure agreement with Dell Inc. and may not
# be copied or disclosed except in accordance with the terms of that
# agreement.
#
# Copyright (c) 2000-2018 Dell Inc. All Rights Reserved.
#
# Module Name:
#
#   dataeng-helper
#
# Abstract/Purpose:
#
#   Systems Management Data Engine helper script
#
# Environment:
#
#   Ubuntu/Debian
#
###############################################################################

DENG_PROD_NAME="Systems Management Data Engine"
DENG_SCRIPT_NAME="dataeng"
DENG_DEFAULT_INSTALL_DIR="/opt/dell/srvadmin"

# Make sure HOSTTYPE is set
[ -z "${HOSTTYPE}" ] && HOSTTYPE=$(uname -m)

# OS information
OM_INITSCRIPT_DIR="/etc/init.d"
OS_INITSCRIPT_DIR="/etc/init.d"
OS_SUBSYS_LOCK_DIR="/var/lock/subsys/"
OS_SCRIPT_FUNCTIONS_LSB="/lib/lsb/init-functions"
OS_SCRIPT_FUNCTIONS_RH="/etc/init.d/functions"
OS_SCRIPT_FUNCTIONS_NONE="none"
OS_SNMP_SVCNAME="snmpd"
OS_SNMP_SCRIPT="${OS_INITSCRIPT_DIR}/${OS_SNMP_SVCNAME}"

# Check for supported OS script functions
if [ -f ${OS_SCRIPT_FUNCTIONS_RH} ];
then
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_RH}
elif [ -f ${OS_SCRIPT_FUNCTIONS_LSB} ];
then
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_LSB}
else
	OS_SCRIPT_FUNCTIONS=${OS_SCRIPT_FUNCTIONS_NONE}
fi

# Include OS script functions if available
if [ ${OS_SCRIPT_FUNCTIONS} != ${OS_SCRIPT_FUNCTIONS_NONE} ];
then
	. ${OS_SCRIPT_FUNCTIONS}
fi

# omreg config file variables
OM_INSTALL_FILE="/opt/dell/srvadmin/etc/srvadmin-omilcore/install.ini"
OM_REG_FILE="/opt/dell/srvadmin/etc/omreg.cfg"
OMDATAENG_INSTALLPATH_KEY="OMDataEngine.installpath"
OMDATAENG_STARTSNMPD_KEY="OMDataEngine.startsnmpd"
OMDATAENG_SHOULDSTART_SVCLIST_KEY="OMDataEngine.shouldstart.servicelist"

DENG_DAEMON_DIR="/opt/dell/srvadmin/sbin"
DENG_FWSNMP_SCRIPT="/opt/dell/srvadmin/lib64/srvadmin-deng/dcfwsnmp.sh"
DENG_FWSNMP_OFF_FILE="/opt/dell/srvadmin/var/lib/srvadmin-deng/dcfwsnmp.off"
DENG_DCSNMP_OFF_FILE="/opt/dell/srvadmin/var/lib/srvadmin-deng/dcsnmp.off"
DENG_LD_LIBRARY_PATH_SET=0

# Script messages
DENG_MSG_DE_SNMP_ENABLED="Data Engine SNMP enabled"
DENG_MSG_DE_SNMP_DISABLED="Data Engine SNMP disabled"
DENG_MSG_DE_SNMP_NOTINSTALLED="Data Engine SNMP not installed"
DENG_MSG_OS_FIREWALL_SNMP_1="WARNING: The SNMP port appears to be closed by the firewall."
DENG_MSG_OS_FIREWALL_SNMP_2="You may not be able to manage this system remotely using SNMP."
DENG_MSG_OS_FIREWALL_SNMP_3="See Firewall Configuration in the product user's guide."
DENG_MSG_OS_SNMP_NOTINSTALLED="OS SNMP support not installed"
DENG_MSG_OS_SNMP_NOTSTARTED_1="warning: ${OS_SNMP_SVCNAME} not started."
DENG_MSG_OS_SNMP_NOTSTARTED_2="${OS_SNMP_SVCNAME} must be started to manage this system using SNMP."

# Default 
DENG_DCSNMP_INSTALLED=1

# Standard status codes for commands other than "status"
STATUS_NO_ERROR=0
STATUS_GENERIC_ERROR=1
STATUS_INVALID_ARG=2
STATUS_NOT_IMPLEMENTED=3

# Data Engine status codes for commands other than "status"
STATUS_OS_SNMP_NOT_FOUND=250
STATUS_DE_SNMP_NOT_FOUND=251
STATUS_SYSTEM_NOT_SUPPORTED=252

# Standard status codes for "status" command
STATUS_RUNNING=0
STATUS_DEAD_PIDFILE_EXISTS=1
STATUS_DEAD_LOCKFILE_EXISTS=2
STATUS_NOT_RUNNING=3
STATUS_UNKNOWN=4

# If DE SNMP is not installed we should not try to start snmp service and report error
	# First clean up
	rm -f $DENG_DCSNMP_OFF_FILE
	grep -q "^SNMP=disable" $OM_INSTALL_FILE
	if [ $? = ${STATUS_RUNNING} ];
	then
		#touch the off file
		touch $DENG_DCSNMP_OFF_FILE
	fi

###############################################################################
# Begin Functions
###############################################################################

###############################################################################
# Function:    dataeng_supt_logmessage <message>
# Description: Log message to OS log
# Returns:     none
###############################################################################
dataeng_supt_logmessage()
{
	MSG="$1"

	# Log message to OS log
	logger -t "${DENG_SCRIPT_NAME}" "${MSG}"
} # dataeng_supt_logmessage

###############################################################################
# Function:    dataeng_check_fwsnmp
# Description: Check status of SNMP port in OS firewall configuration
# Returns:     0 = SNMP port is open, non-zero = SNMP port is closed
###############################################################################
dataeng_check_fwsnmp()
{
	# See if check has been disabled by the user
	if [ -f ${DENG_FWSNMP_OFF_FILE} ];
	then
		return 0
	fi

	# Check SNMP port in firewall
	${DENG_FWSNMP_SCRIPT}
	FWSNMP_STATUS=$?
	if [ ${FWSNMP_STATUS} != 0 ];
	then
		# It looks like the SNMP port is closed.  Warn the user.
		echo ""
		echo ${DENG_MSG_OS_FIREWALL_SNMP_1}
		echo ${DENG_MSG_OS_FIREWALL_SNMP_2}
		echo ${DENG_MSG_OS_FIREWALL_SNMP_3}

		dataeng_supt_logmessage "${DENG_MSG_OS_FIREWALL_SNMP_1} ${DENG_MSG_OS_FIREWALL_SNMP_2} ${DENG_MSG_OS_FIREWALL_SNMP_3}"
	fi

	return ${FWSNMP_STATUS}
} # dataeng_check_fwsnmp


###############################################################################
# Function:    dataeng_set_os_snmp_conf_vars
# Description: Set variables needed to update OS SNMP configuration file
# Returns:     none
###############################################################################
dataeng_set_os_snmp_conf_vars()
{
	OS_SNMP_CONF_FILE_1="/etc/snmp/snmpd.conf"
	OS_SNMP_CONF_FILE_2="/etc/snmpd.conf"
	OS_SNMP_CONF_FILE_3="/etc/ucdsnmpd.conf"
	OS_SNMP_CONF_VIEW_SYS_CHK_1="^view.*systemview.*included.*system$"
	OS_SNMP_CONF_VIEW_SYS_CHK_2="^view.*systemview.*included[ 	]*\.1.3.6.1.2.1.1$"
	OS_SNMP_CONF_VIEW_ALL_CHK="^view.*all.*included.*\.1"
	OS_SNMP_CONF_VIEW_ALL_ADD="view    all            included      .1"
	OS_SNMP_CONF_ACCESS_SYS_CHK="^access.*notConfigGroup.*any.*noauth.*exact.*systemview.*none.*none$"
	OS_SNMP_CONF_ACCESS_ALL_CHK="^access.*notConfigGroup.*any.*noauth.*exact.*all"
	OS_SNMP_CONF_ACCESS_ALL_ADD="access  notConfigGroup \"\"      any       noauth    exact  all    none   none"
	OS_SNMP_CONF_COMMENT_OLD_1="# Allow Dell OpenManage Server Agent to connect to ucd-snmp using SMUX"
	OS_SNMP_CONF_COMMENT_OLD_2="# Allow Server Administrator to connect to ucd-snmp using SMUX"
	OS_SNMP_CONF_COMMENT_DENG="# Allow Systems Management Data Engine SNMP to connect to snmpd using SMUX"
	OS_SNMP_CONF_SMUXPEER_DENG_CHK="smuxpeer.*\.1\.3\.6\.1\.4\.1\.674\.10892\.1"
	OS_SNMP_CONF_SMUXPEER_DENG_ADD="smuxpeer .1.3.6.1.4.1.674.10892.1"

	# check for OS SNMP configuration file
	# (different Linux distros put file in different locations)
	if [ -f ${OS_SNMP_CONF_FILE_1} ];
	then
		OS_SNMP_CONF_FILE=${OS_SNMP_CONF_FILE_1}
	elif [ -f ${OS_SNMP_CONF_FILE_2} ];
	then
		OS_SNMP_CONF_FILE=${OS_SNMP_CONF_FILE_2}
	elif [ -f ${OS_SNMP_CONF_FILE_3} ];
	then
		OS_SNMP_CONF_FILE=${OS_SNMP_CONF_FILE_3}
	else
		OS_SNMP_CONF_FILE=""
	fi
} # dataeng_set_os_snmp_conf_vars

###############################################################################
# Function:    dataeng_supt_daemonstatus <daemon>
# Description: Get current status of a daemon
# Returns:     LSB status code
###############################################################################
dataeng_supt_daemonstatus()
{
	DAEMON="$1"

	# Check for daemon name
	if [ -z ${DAEMON} ];
	then
		return ${STATUS_UNKNOWN}
	fi

	# Get list of pids using pidof
	PIDLIST=`pidof -o $$ -o ${PPID} -o %PPID -x ${DAEMON}`
	if [ -n "${PIDLIST}" ];
	then
		echo "${DAEMON} (pid ${PIDLIST}) is running"
		return ${STATUS_RUNNING}
	fi

	# Check for pid file in standard location
	PIDFILE="/opt/dell/srvadmin/var/run/${DAEMON}.pid"
	if [ -f ${PIDFILE} ];
	then
		echo "${DAEMON} is dead and /opt/dell/srvadmin/var/run pid file exists"
		return ${STATUS_DEAD_PIDFILE_EXISTS}
	fi

	# Check for lock file in standard location
	LOCKFILE="${OS_SUBSYS_LOCK_DIR}/${daemon}"
	if [ -f ${LOCKFILE} ];
	then
		echo "${DAEMON} is dead and /opt/dell/srvadmin/var/lock lock file exists"
		return ${STATUS_DEAD_LOCKFILE_EXISTS}
	fi

	echo "${DAEMON} is stopped"
	return ${STATUS_NOT_RUNNING}
} # dataeng_supt_daemonstatus

###############################################################################
# Function:    dataeng_enablesnmp
# Description: enable Data Engine SNMP
# Returns:     STATUS_NO_ERROR = Data Engine SNMP installed and enabled
#              STATUS_OS_SNMP_NOT_FOUND = OS SNMP support not installed
#              STATUS_DE_SNMP_NOT_FOUND = Data Engine SNMP not installed
###############################################################################
dataeng_enablesnmp()
{
	# check for OS SNMP agent and set configuration variables
	dataeng_set_os_snmp_conf_vars

	# check if OS SNMP support is installed
	if [ -z ${OS_SNMP_CONF_FILE} ];
	then
		# OS SNMP support not installed
		echo ${DENG_MSG_OS_SNMP_NOTINSTALLED}
		dataeng_supt_logmessage "NOTE: ${DENG_MSG_OS_SNMP_NOTINSTALLED}"

		# mark Data Engine SNMP disabled
		touch ${DENG_DCSNMP_OFF_FILE}

		return ${STATUS_OS_SNMP_NOT_FOUND}
	fi

	# check if Data Engine SNMP is installed
	if [ ${DENG_DCSNMP_INSTALLED} = 0 ];
	then
		# Data Engine SNMP not installed
		echo ${DENG_MSG_DE_SNMP_NOTINSTALLED}
		dataeng_supt_logmessage "NOTE: ${DENG_MSG_DE_SNMP_NOTINSTALLED}"

		# mark Data Engine SNMP disabled
		touch ${DENG_DCSNMP_OFF_FILE}

		return ${STATUS_DE_SNMP_NOT_FOUND}
	fi

	# OS SNMP and Data Engine SNMP installed;
	# make needed updates to OS SNMP configuration
	NEW_CONF_FILE="${OS_SNMP_CONF_FILE}.${DENG_SCRIPT_NAME}"
	SNMP_CONF_FILE_UPDATED=0

	# check for "view" for whole MIB tree
	egrep -i "${OS_SNMP_CONF_VIEW_ALL_CHK}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? != 0 ];
	then
		# determine line to add new "view" after
		# by looking for existing well-known "view"
		egrep -i "${OS_SNMP_CONF_VIEW_SYS_CHK_1}" ${OS_SNMP_CONF_FILE} >/dev/null
		if [ $? = 0 ];
		then
			VIEW_CHK="${OS_SNMP_CONF_VIEW_SYS_CHK_1}"
		else
			egrep -i "${OS_SNMP_CONF_VIEW_SYS_CHK_2}" ${OS_SNMP_CONF_FILE} >/dev/null
			if [ $? = 0 ];
			then
				VIEW_CHK="${OS_SNMP_CONF_VIEW_SYS_CHK_2}"
			else
				VIEW_CHK=""
			fi
		fi

		# check if well-known "view" was found
		if [ ! -z "${VIEW_CHK}" ];
		then
			# create sed script to add "view" for whole MIB tree
			TMP_FILE=$(mktemp ${TMP:-/tmp}/${DENG_SCRIPT_NAME}.XXXXXXX)
			if [ $? = 0 ];
			then
				echo "/${VIEW_CHK}/i\\"             >>${TMP_FILE}
				echo "${OS_SNMP_CONF_VIEW_ALL_ADD}" >>${TMP_FILE}

				# add "view" for whole MIB tree
				sed -f ${TMP_FILE} ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
				mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
				rm -f ${TMP_FILE}

				SNMP_CONF_FILE_UPDATED=1
			else
				echo "${DENG_SCRIPT_NAME}: mktemp failed to make filename"
			fi
		fi
	fi

	# check for "access" to whole MIB tree for default group
	egrep -i "${OS_SNMP_CONF_ACCESS_ALL_CHK}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? != 0 ];
	then
		# check for default "access" configuration
		egrep -i "${OS_SNMP_CONF_ACCESS_SYS_CHK}" ${OS_SNMP_CONF_FILE} >/dev/null
		if [ $? = 0 ];
		then
			# change default "access" configuration to allow
			# access to whole MIB tree for default group
			sed "s/${OS_SNMP_CONF_ACCESS_SYS_CHK}/${OS_SNMP_CONF_ACCESS_ALL_ADD}/" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
			mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}

			SNMP_CONF_FILE_UPDATED=1
		fi
	fi

	# check for Data Engine SNMP "smuxpeer" entry
	egrep -i "${OS_SNMP_CONF_SMUXPEER_DENG_CHK}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? != 0 ];
	then
		# add blank line if needed
		LAST_LINE=""
		while read LINE;
		do
			LAST_LINE="${LINE}"
		done < ${OS_SNMP_CONF_FILE}
		if [ "${LAST_LINE}" != "" ];
		then
			echo "" >>${OS_SNMP_CONF_FILE}
		fi

		# add Data Engine SNMP "smuxpeer" entry
		echo "${OS_SNMP_CONF_COMMENT_DENG}" >>${OS_SNMP_CONF_FILE}
		echo "${OS_SNMP_CONF_SMUXPEER_DENG_ADD}" >>${OS_SNMP_CONF_FILE}

		SNMP_CONF_FILE_UPDATED=1
	else
		# check if "smuxpeer" comment needs to be updated
		egrep -i "${OS_SNMP_CONF_COMMENT_OLD_1}" ${OS_SNMP_CONF_FILE} >/dev/null
		if [ $? = 0 ];
		then
			# update "smuxpeer" comment
			sed "s/${OS_SNMP_CONF_COMMENT_OLD_1}/${OS_SNMP_CONF_COMMENT_DENG}/" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
			mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
		else
			egrep -i "${OS_SNMP_CONF_COMMENT_OLD_2}" ${OS_SNMP_CONF_FILE} >/dev/null
			if [ $? = 0 ];
			then
				# update "smuxpeer" comment
				sed "s/${OS_SNMP_CONF_COMMENT_OLD_2}/${OS_SNMP_CONF_COMMENT_DENG}/" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
				mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
			fi
		fi
	fi

	# check for simple access control configuration;
	# if simple access control configuration found;
	# try to determine if SNMP access is restricted to localhost
	SIMPLE_ACCESS_CONTROL=0
	LOCALHOST_ONLY=1
	TMP_FILE=$(mktemp ${TMP:-/tmp}/${DENG_SCRIPT_NAME}.XXXXXXX)
	if [ $? = 0 ];
	then
		egrep -i "^r[ow]community6*[[:blank:]]" ${OS_SNMP_CONF_FILE} >>${TMP_FILE} 2>&1
		while read LINE;
		do
			SIMPLE_ACCESS_CONTROL=1
			SOURCE=`echo ${LINE} | awk '{print $3}'`
			if [ "${SOURCE}" != "127.0.0.1" ] &&
			   [ "${SOURCE}" != "localhost" ];
			then
				LOCALHOST_ONLY=0
				break
			fi
		done < ${TMP_FILE}
		rm -f ${TMP_FILE}
	else
		echo "${DENG_SCRIPT_NAME}: mktemp failed to make filename"
	fi

	# check if simple access control configuration used and
	# if SNMP access appears to be restricted to localhost
	if [ ${SIMPLE_ACCESS_CONTROL} = 1 ] &&
	   [ ${LOCALHOST_ONLY} = 1 ];
	then
		# SNMP access appears to be restricted to localhost
		DENG_MSG_OS_SNMP_ACCESS="NOTE: SNMP access appears to be restricted to localhost in ${OS_SNMP_CONF_FILE}"
		echo ${DENG_MSG_OS_SNMP_ACCESS}
		dataeng_supt_logmessage "${DENG_MSG_OS_SNMP_ACCESS}"
	fi

	# check if SNMP config file updated
	if [ ${SNMP_CONF_FILE_UPDATED} = 1 ];
	then
		# check if SNMP agent started
		dataeng_supt_daemonstatus ${OS_SNMP_SVCNAME} >/dev/null
		if [ $? = ${STATUS_RUNNING} ];
		then
			# SNMP agent needs to be restarted
			DENG_MSG_OS_SNMP_RESTART="NOTE: ${OS_SNMP_SVCNAME} must be restarted to activate changes to ${OS_SNMP_CONF_FILE}"
			echo ${DENG_MSG_OS_SNMP_RESTART}
			dataeng_supt_logmessage "${DENG_MSG_OS_SNMP_RESTART}"
		fi
	fi
	
	# check SNMP port in firewall
	dataeng_check_fwsnmp

	# mark Data Engine SNMP enabled
	rm -f ${DENG_DCSNMP_OFF_FILE}

	echo ${DENG_MSG_DE_SNMP_ENABLED}

	return ${STATUS_NO_ERROR}
} # dataeng_enablesnmp


###############################################################################
# Function:    dataeng_disablesnmp
# Description: Disable Data Engine SNMP
# Returns:     STATUS_NO_ERROR = Data Engine SNMP installed and disabled
#              STATUS_OS_SNMP_NOT_FOUND = OS SNMP support not installed
#              STATUS_DE_SNMP_NOT_FOUND = Data Engine SNMP not installed
###############################################################################
dataeng_disablesnmp()
{
	# check for OS SNMP agent and set configuration variables
	dataeng_set_os_snmp_conf_vars

	# always mark Data Engine SNMP disabled
	touch ${DENG_DCSNMP_OFF_FILE}

	# check if OS SNMP support is installed
	if [ -z ${OS_SNMP_CONF_FILE} ];
	then
		# OS SNMP support not installed
		echo ${DENG_MSG_OS_SNMP_NOTINSTALLED}
		return ${STATUS_OS_SNMP_NOT_FOUND}
	fi

	# check if Data Engine SNMP is installed
	if [ ${DENG_DCSNMP_INSTALLED} = 0 ];
	then
		# Data Engine SNMP not installed
		echo ${DENG_MSG_DE_SNMP_NOTINSTALLED}
		return ${STATUS_DE_SNMP_NOT_FOUND}
	fi

	# OS SNMP and Data Engine SNMP are installed;
	# make needed updates to OS SNMP configuration
	NEW_CONF_FILE="${OS_SNMP_CONF_FILE}.${DENG_SCRIPT_NAME}"

	# check for Data Engine SNMP "smuxpeer" entry
	egrep -i "${OS_SNMP_CONF_SMUXPEER_DENG_CHK}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? = 0 ];
	then
		# remove Data Engine SNMP "smuxpeer" entry 
		egrep -iv "${OS_SNMP_CONF_SMUXPEER_DENG_CHK}" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
		mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
	fi

	# check for Data Engine SNMP "smuxpeer" comment
	egrep -i "${OS_SNMP_CONF_COMMENT_DENG}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? = 0 ];
	then
		# remove Data Engine SNMP "smuxpeer" comment
		egrep -iv "${OS_SNMP_CONF_COMMENT_DENG}" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
		mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
	fi

	# check for old "smuxpeer" comment
	egrep -i "${OS_SNMP_CONF_COMMENT_OLD_1}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? = 0 ];
	then
		# remove old SNMP "smuxpeer" comment
		egrep -iv "${OS_SNMP_CONF_COMMENT_OLD_1}" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
		mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
	fi

	# check for old "smuxpeer" comment
	egrep -i "${OS_SNMP_CONF_COMMENT_OLD_2}" ${OS_SNMP_CONF_FILE} >/dev/null
	if [ $? = 0 ];
	then
		# remove old SNMP "smuxpeer" comment
		egrep -iv "${OS_SNMP_CONF_COMMENT_OLD_2}" ${OS_SNMP_CONF_FILE} >${NEW_CONF_FILE}
		mv -f ${NEW_CONF_FILE} ${OS_SNMP_CONF_FILE}
	fi

	# stop Data Engine SNMP if started
	dataeng_supt_daemonstatus ${DENG_DCSNMP} >/dev/null
	if [ $? = 0 ];
	then
		dataeng_supt_daemonstop ${DENG_DCSNMP}
	fi

	echo ${DENG_MSG_DE_SNMP_DISABLED}

	return ${STATUS_NO_ERROR}
} # dataeng_disablesnmp


###############################################################################
# Function:    dataeng_getsnmpstatus
# Description: Get Data Engine SNMP status
# Returns:     STATUS_NO_ERROR = Data Engine SNMP installed
#              STATUS_OS_SNMP_NOT_FOUND = OS SNMP support not installed
#              STATUS_DE_SNMP_NOT_FOUND = Data Engine SNMP not installed
###############################################################################
dataeng_getsnmpstatus()
{
	# check for OS SNMP agent and set configuration variables
	dataeng_set_os_snmp_conf_vars

	# check if OS SNMP support is installed
	if [ -z ${OS_SNMP_CONF_FILE} ];
	then
		# OS SNMP support not installed
		echo ${DENG_MSG_OS_SNMP_NOTINSTALLED}
		return ${STATUS_OS_SNMP_NOT_FOUND}
	fi

	# check if Data Engine SNMP is installed
	if [ ${DENG_DCSNMP_INSTALLED} = 0 ];
	then
		# Data Engine SNMP not installed
		echo ${DENG_MSG_DE_SNMP_NOTINSTALLED}
		return ${STATUS_DE_SNMP_NOT_FOUND}
	fi

	# OS SNMP and Data Engine SNMP are installed;
	# get Data Engine SNMP status 
	if [ ! -f ${DENG_DCSNMP_OFF_FILE} ];
	then
		echo ${DENG_MSG_DE_SNMP_ENABLED}
	else
		echo ${DENG_MSG_DE_SNMP_DISABLED}
	fi

	return ${STATUS_NO_ERROR}
} # dataeng_getsnmpstatus

###############################################################################
# End Functions
###############################################################################


###############################################################################
# Check command line parameter for action to perform
###############################################################################

case "$1" in
	enablesnmp)
		# enable Data Engine SNMP
		dataeng_enablesnmp
		EXIT_STATUS=$?
		;;

	disablesnmp)
		# disable Data Engine SNMP
		dataeng_disablesnmp
		EXIT_STATUS=$?
		;;

	getsnmpstatus)
		# get Data Engine SNMP enable/disable status
		dataeng_getsnmpstatus
		EXIT_STATUS=$?
		;;
	*)
		echo "${DENG_SCRIPT_NAME}: Invalid argument"
		echo "Usage: ${DENG_SCRIPT_NAME} {enablesnmp|disablesnmp|getsnmpstatus}"
		EXIT_STATUS=${STATUS_INVALID_ARG}
esac

exit ${EXIT_STATUS}


###############################################################################
# End Script
###############################################################################


Zerion Mini Shell 1.0