Forwarding Sentinel events to BMC with MSEND

Forwarding Sentinel events to BMC with MSEND

If your Enterprise Operations Management solution is the BMC suite, Sentinel can easily be configured to send correlated event information using the msend binary as an Execute Action.

Due to Bug # 944428, you will require at least Execute a Command 2011.1r2 or greater.

This bash script will allow you to send enough information for BMC to action (i.e. Send SMS, Log Remedy ticket, etc).

#!/bin/sh

#
# Function to display pretty usage details
#
usageDisplay()
{
    echo -e "\n"
    echo -e "Usage: $0 -e=FILE -c=FILE -a=VAR -r=VAR -m=TEXT [-h=TEXT] [-o=TEXT] [-l=TEXT] [-p=VAR -t=TEXT] [-k=TEXT]\n"
    echo -e "Mandadory arguments to long options are mandatory for short options too."
    echo -e "\n"
    echo -e "  -e, --exec=FILE               Path to msend binary executable"
    echo -e "  -c, --config=FILE             Path to msend configuration file mclient.conf"
    echo -e "  -a, --class=VAR               Class name for event"
    echo -e "  -r, --criticality=VAR         Criticality of the event"
    echo -e "  -m, --short-message=TEXT      Short message about event"
    echo -e "\n"
    echo -e "  -h, --host=TEXT               Host name of the event source"
    echo -e "  -o, --object=TEXT             Event Object"
    echo -e "  -l, --long-message=TEXT       Detailed message about event"
    echo -e "  -p, --parameter=VAR           Parameter name for slot. Used in conjunction with -t"
    echo -e "  -t, --parameter-value=TEXT    Parameter value for slot. Used in conjection with -p"
    echo -e "  -k, --report-link=TEXT        Report link to sentinel for more detail"
    echo -e "  -?, --help                    display this help and exit"
    echo -e "\n"
}

#
# Map severity to criticality
#
declare -a sevs=( [0]="INFORMATION" [1]="INFORMATION" [2]="WARNING" [3]="MINOR" [4]="MAJOR" [5]="CRITICAL" )

#
# Process parsed parameters and set variables
#
for i in "$@"
 do
    case $i in
        -?|--help)
            usageDisplay
            exit 1
        ;;
        -a=*|--class=*)
            MSEND_A=${i#*=}
            shift
        ;;
        -c=*|--config=*)
            MSEND_C=${i#*=}
            XBASE=${MSEND_C##*/}
            MSEND_S=${XBASE%.*}
            shift
        ;;
        -e=*|--exec=*)
            MSEND_E=${i#*=}
            shift
        ;;
        -h=*|--host=*)
            MSEND_H="${i#*=}"
            shift
        ;;
        -k=*|--report-link=*)
            MSEND_K="${i#*=}"
            shift
        ;;
        -l=*|--long-message=*)
            MSEND_L="${i#*=}"
            MSEND_L="${MSEND_L//[\'\"\`]}"
            MSEND_L="${MSEND_L//\$/\\\$}"
            MSEND_L="${MSEND_L//\{/\\\{}"
            MSEND_L="${MSEND_L//\}/\\\}}"
            shift
        ;;
        -m=*|--short-message=*)
            MSEND_M="${i#*=}"
            MSEND_M="${MSEND_M//[\'\"\`]}"
            MSEND_M="${MSEND_M//\$/\\\$}"
            MSEND_M="${MSEND_M//\{/\\\{}"
            MSEND_M="${MSEND_M//\}/\\\}}"
            shift
        ;;
        -o=*|--object=*)
            MSEND_O="${i#*=}"
            shift
        ;;
        -p=*|--parameter=*)
            MSEND_P="${i#*=}"
            shift
        ;;
        -r=*|--criticality=*)
            MSEND_R=${sevs[${i#*=}]}
            shift
        ;;
        -t=*|--parameter-value=*)
            MSEND_V="${i#*=}"
            shift
        ;;
        *)
        ;;
    esac
done

#
# Check for required parameters
#
if [ -z "${MSEND_E}" ] || [ ! -x "${MSEND_E}" ] || [ -z "${MSEND_C}" ] || [ ! -f "${MSEND_C}" ] || [ -z "${MSEND_A}" ] || [ -z "${MSEND_R}" ] || [ -z "${MSEND_M}" ]
 then
    usageDisplay
    exit 2
fi

#
# Start building command line
#
MSEND_COMMAND="${MSEND_E} -q"

#
# Add configuration file
#
if [ -n "${MSEND_C}" ] && [ -f "${MSEND_C}" ]
 then
    MSEND_COMMAND="${MSEND_COMMAND} -c ${MSEND_C}"
fi

#
# Add mandatory parameters
#
MSEND_COMMAND="${MSEND_COMMAND} -a ${MSEND_A} -r ${MSEND_R} -m \"${MSEND_M}\""

#
# Start building slots
#
MSEND_SLOTS="mc_tool=${MSEND_S};mc_tool_id=MSEND"

#
# Add mc_host to slots
#
if [ -n "${MSEND_H}" ]
 then
    if [ -n "${MSEND_SLOTS}" ]
     then
        MSEND_SLOTS="${MSEND_SLOTS};"
    fi
    MSEND_SLOTS="${MSEND_SLOTS}mc_host=${MSEND_H}"
fi

#
# Add mc_object to slots
#
if [ -n "${MSEND_O}" ]
 then
    if [ -n "${MSEND_SLOTS}" ]
     then
        MSEND_SLOTS="${MSEND_SLOTS};"
    fi
    MSEND_SLOTS="${MSEND_SLOTS}mc_object=${MSEND_O}"
fi

#
# Add mc_parameter and mc_parameter_value to slots
#
if [ -n "${MSEND_P}" ] && [ -n "${MSEND_V}" ]
 then
    if [ -n "${MSEND_SLOTS}" ]
     then
        MSEND_SLOTS="${MSEND_SLOTS};"
    fi
    MSEND_SLOTS="${MSEND_SLOTS}mc_parameter=${MSEND_P};mc_parameter_value=${MSEND_V}"
fi

#
# Add Report_link to slots
#
if [ -n "${MSEND_K}" ]
 then
    if [ -n "${MSEND_SLOTS}" ]
     then
        MSEND_SLOTS="${MSEND_SLOTS};"
    fi
    MSEND_SLOTS="${MSEND_SLOTS}Report_link=${MSEND_K}"
fi

#
# Add mc_long_msg to slots
#
if [ -n "${MSEND_L}" ]
 then
    if [ -n "${MSEND_SLOTS}" ]
     then
        MSEND_SLOTS="${MSEND_SLOTS};"
    fi
    MSEND_SLOTS="${MSEND_SLOTS}mc_long_msg='${MSEND_L}'"
fi

#
# Append slots to command line
#
if [ -n "${MSEND_SLOTS}" ]
 then
    MSEND_COMMAND="${MSEND_COMMAND} -b \"${MSEND_SLOTS}\""
fi

eval ${MSEND_COMMAND}
exit $?

To configure the Action, you will need to set some arguments:

  • Command: /path/to/msend.sh
  • Arguments: -e=/path/to/msend -c=/path/to/mclient.conf -a=SENTINEL_EVENT -r=$Severity$ "-m=$EventName$" -h=$ObserverHostName$.$ObserverHostDomain$ -o=$InitiatorUserDomain$ "-l=$Message$" -p=XDASTaxonomyName -t=$XDASTaxonomyName$ -k=https://sentinel.domain.com:8443/

-e= is the path to the msend binary on the Sentinel server.

-c= is the path to the mclient.conf file on the Sentinel server. It should have the following parameters set for best results (setting at least ServerName, ServerLocation and ServerPort to match your environment):

#Trace=Yes
#Tracesrc=No
#TraceProgram=Yes
#TraceModule=Yes
#TraceTime=Yes
TraceConfigFileName=/path/to/mclient.trace
#TraceDefaultFileName=%T/trace
#TraceFileSize=0
#TraceFileHistory=0
#TraceFileAppend=Yes
#TraceEvents=

LocaleConfigFileName=%H/path/to/%P.load

#Encryption=Yes
#EncryptionKey=

ServerName=@bmc.domain.com:1828#mc
ServerLocation=bmc.domain.com
ServerDirectoryName=/path/to/mcell.dir
ServerPort=1828
#ServerIPVersion=46

#ConnectionSetupTimeOut=20
#ConnectionPortRange=
#ConnectionPortReuse=Yes
#SynchronizeTimeOut=5000

#MessageBufferSize=2000
#MessageBufferReconnectInterval=600
#MessageBufferKeepWait=3600
#MessageBufferKeepSent=300
#MessageBufferResendCount=1
#ProductTypeTrueSight=No

-a= is the object class to identify the event in BMC.

-r= is the Severity of the event. This will be translated into BMC criticality.

-m= is the short message detail of the event. NOTE: The position of the quotes is not a mistake and must be wrapped as per the documentation.

-h= is the source host of the event.

-o= is the event object.

-l= is the longer detailed message of the event. NOTE: The position of the quotes is not a mistake and must be wrapped as per the documentation.

-p= and -t= is the parameter and value that initiated the event.

-k= sets an additional field for being able to easily access the Sentinel console from the BMC interface.

Labels (1)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
3 of 3
Last update:
‎2019-10-08 22:25
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.