• ARTICLES
SEARCH

How-To Geek

Setup Email Notifications for Dell Server Hardware Alerts

All Dell servers come with the Dell OpenManage Server Administrator software which has the ability to monitor and display system level indicators. Additionally, through the Alert Management tab you can configure actions to execute whenever an alert is triggered. Unfortunately there is no vehicle for applying uniform notifications to all events, so we are going to provide a script which configures all the alert actions to send an email notifying you of the respective event. While you could set these up manually, having a script is ideal as you can easily deploy this across multiple servers.

How it Works

The script is very simple. There is a setup command which sets each alert to “Execute application” with the application being the script itself. When the script runs, it simply generates an email (by using the the Blat tool) with the computer name, date, time and alert triggered.

Before script is run:

image

After script is run:

image

All alerts use the email notification script:

image

Requirements

Of course, you will need to have Dell OpenManage Server Assistant installed. This software, if not provided with your system, is downloadable through Dell’s support site.

Additionally, you will need to have Blat, a command line emailer, configured on your system. To configure Blat, just download the binary files and extract them (3 total: blat.exe, blat.dll, blat.lib) to a location in your system’s PATH variable, such as your Windowssystem32 folder. Then from the command line, run:

blat -install my.mailserver.com fromaddress@email.com

Replace the mail server and from email address appropriately. For the most part this command is all you need to run, but if your server has a special configuration (alternate port, etc.), you can see the full install options on Blat’s website.

Email Alert Notification Setup

Once you have these requirements in place, you are ready to use the script. Edit the script to include the email address(es) to notify (the ‘ToEmail’ variable). If your server requires authentication to relay, you will have to add these parameters to the Blat command as documented in the script.

To setup the Server Assistant alerts to use the script, just run the setup:

DellAlert /setup

Confirm you want to use this script as your alert action and you are all set. As part of the setup, a sample alert is triggered so you can make sure the emails are reaching the intended recipients.

The Script

@ECHO OFF
TITLE Dell Hardware Email Alert
ECHO Dell Hardware Email Alert
ECHO Written by: Jason Faulkner
ECHO SysadminGeek.com
ECHO.
ECHO.

REM Sends email alerts when Dell hardware warnings are triggered.
REM This script should _not_ be in a path which contains spaces.
REM
REM Usage:
REM DellAlert {/SETUP | Alert message}
REM    /SETUP   Configure Dell Server Assistant to use this script for alerts.
REM    Alert Message
REM             Message to send.
REM
REM Requires:
REM Blat : (command line emailer) is configured and working on the current system.
REM        If your email server requires authentication to relay, see comments below.

REM Email address(es) to send alerts to (comma separated)
SET ToEmail=myaddress@email.com

SETLOCAL EnableExtensions

IF /I {%1}=={/SETUP} GOTO Setup
IF NOT {%1}=={} GOTO Alert
GOTO End

:Alert
SET Log="%TEMP%DellAlert.txt"

DATE /T > %Log%
TIME /T >> %Log%
ECHO Dell Alert Tripped! >> %Log%
ECHO %* >> %Log%

REM If your email server requires autentication to relay,
REM add the following to the end of the line below:
REM -u UserName -pw Password
BLAT %Log% -to %ToEmail% -subject "%ComputerName% Hardware Alert"

IF EXIST %Log% DEL /F /Q %Log%
GOTO End

:Setup
ECHO This will replace all the current Dell Server Assistant alerts with a call
ECHO to this script. To confirm you want to continue, enter YES (case sensitive).
SET /P Confirm=
IF NOT {%Confirm%}=={YES} GOTO End

SET ScriptPath=%~dpnx0
ECHO Configuring alerts to use: %ScriptPath%

omconfig system alertaction event=powersupply execappath="%ScriptPath% power supply failure"
omconfig system alertaction event=powersupplywarn execappath="%ScriptPath% power supply warning"
omconfig system alertaction event=tempwarn execappath="%ScriptPath% temperature warning"
omconfig system alertaction event=tempfail execappath="%ScriptPath% temperature failure"
omconfig system alertaction event=fanwarn execappath="%ScriptPath% fan speed warning"
omconfig system alertaction event=fanfail execappath="%ScriptPath% fan speed failure"
omconfig system alertaction event=voltwarn execappath="%ScriptPath% voltage warning"
omconfig system alertaction event=voltfail execappath="%ScriptPath% voltage failure"
omconfig system alertaction event=intrusion execappath="%ScriptPath% chassis intrusion"
omconfig system alertaction event=redundegrad execappath="%ScriptPath% redundancy degraded"
omconfig system alertaction event=redunlost execappath="%ScriptPath% redundancy lost"
omconfig system alertaction event=memprefail execappath="%ScriptPath% memory pre-failure"
omconfig system alertaction event=memfail execappath="%ScriptPath% memory failure"
omconfig system alertaction event=hardwarelogwarn execappath="%ScriptPath% hardware log warning"
omconfig system alertaction event=hardwarelogfull execappath="%ScriptPath% hardware log full"
omconfig system alertaction event=processorwarn execappath="%ScriptPath% processor warning"
omconfig system alertaction event=processorfail execappath="%ScriptPath% processor failure"
omconfig system alertaction event=watchdogasr execappath="%ScriptPath% watchdog asr"
omconfig system alertaction event=batterywarn execappath="%ScriptPath% battery warning"
omconfig system alertaction event=batteryfail execappath="%ScriptPath% battery failure"
omconfig system alertaction event=systempowerwarn execappath="%ScriptPath% system power warning"
omconfig system alertaction event=systempowerfail execappath="%ScriptPath% system power failure"

omconfig system alertaction event=storagesyswarn execappath="%ScriptPath% storage system warning"
omconfig system alertaction event=storagesysfail execappath="%ScriptPath% storage system failure"
omconfig system alertaction event=storagectrlwarn execappath="%ScriptPath% storage controller warning"
omconfig system alertaction event=storagectrlfail execappath="%ScriptPath% storage controller failure"
omconfig system alertaction event=pdiskwarn execappath="%ScriptPath% physical disk warning"
omconfig system alertaction event=pdiskfail execappath="%ScriptPath% physical disk failure"
omconfig system alertaction event=vdiskwarn execappath="%ScriptPath% virtual disk warning"
omconfig system alertaction event=vdiskfail execappath="%ScriptPath% virtual disk failure"
omconfig system alertaction event=enclosurewarn execappath="%ScriptPath% enclosure warning"
omconfig system alertaction event=enclosurefail execappath="%ScriptPath% enclosure failure"
omconfig system alertaction event=storagectrlbatterywarn execappath="%ScriptPath% storage controller battery warning"
omconfig system alertaction event=storagectrlbatteryfail execappath="%ScriptPath% storage controller battery failure"

ECHO.
ECHO Sending sample alert to:
ECHO %ToEmail%
CALL :Alert Testing Dell hardware alert warnings...
ECHO.
PAUSE
GOTO End

:End
ENDLOCAL

Script Modifications/Maintenance

The event alerts from the provided script are from one of our Dell servers. Depending on your Dell server hardware and Server Assistant version, the alerts may vary. Generally, you can tell when you run the setup script if an event is not valid for your server (for example, if you don’t have Dell RAID controllers) as some of the storage event creation items will fail.

The event triggers in the script above were obtained by running the following from a command prompt:

omconfig system alertaction /?

This command lists all event keywords with a description of the respective alert. To add additional alerts, run the command above and add the missing entries to the setup portion of the script and then rerun the script with the /Setup switch.

Links

Download Dell Server Email Alert Script from SysadminGeek.com

Download Blat Command Line Emailer

Dell Support Site

Jason Faulkner is a developer and IT professional who never has a hot cup of coffee far away. Interact with him on Google+

  • Published 07/21/10

Comments (5)

  1. danorth

    Excellent post. I have only been using Blat with OpenManage to send generic messages. With the script I can now send detail information on what the issue is.

    Thanks!

  2. Saman

    Hi Jason

    cool script. Would u mind if I write a GPL Bash script for Linux servers based on yours?

    Thanks you

    Saman

  3. Jason Faulkner

    @Saman – Absolutely use this however you see fit. Having a Linux equivalent would probably help out lots of people as well.

  4. Saman

    OK here we go!

    With this Linux script you can:
    – list all possible mail alerts
    – individually configure (enable|disable) mail alerts
    – send mail alerts
    – it logs any action to syslog

    ##################################################################################
    cat /opt/dell/srvadmin/bin/omsendmail
    #!/bin/bash

    # By Saman.Behnam@opensoft24.de 22.09.2011
    # Dell srvadmin Hardware Email Alert
    # This script will configure srvadmin “OMSA” to send system mails on hardware alerts.
    # It logs any configuration changes or mail alerts to syslog.
    # Copy this script to the bin directory of your “OMSA” srvadmin installation.
    # In my case Ubuntu server package version 6.5 with bin directory “/opt/dell/srvadmin/bin/”.

    # Change the mail recipient variable to the user of your needs.
    MAIL_RECIPIENT=”root”
    # Change the the server location description string to your needs.
    HOST_LOCATION=”Hausverwaltung imogmbh MUC”

    # You may not change these variables!
    SCRIPTNAME=”omsendmail”
    TEST_MAIL_CONTENT=”Testing Dell hardware alert warnings…”
    HOST_NAME=”$(hostname)”
    DEVNULL=”/dev/null”

    show_help( ){
    echo -e “”
    echo -e “Please invoke like follows”
    echo -e “”
    echo ‘* ‘$SCRIPTNAME’ –option ["optional text"] *’
    echo -e “”
    echo -e “The following options are allowed: \”–enable [alert1 alert2|all]\” \”–disable [alert1 alert2|all]\”"
    echo -e ” \”–listalerts\” \”–mail ["mail content text"]\” \”–testmail\”"
    echo -e “”
    echo -e “Explanation of the options:”
    echo -e “”
    echo -e ” 1) –enable [alert1 alert2|all]”
    echo -e ” If \”–enable\” is specified then \”srvadmin\” is configured to send mail allerts on hardware issues.”
    echo -e ” This must be done just once upon fresh installing or reinstalling the \”srvadmin\” software.”
    echo -e ” Also if you change the name or the file system location of the \”$SCRIPTNAME\” script”
    echo -e ” You can specify a single alert or a space separated list of alerts or \”all\” to enable mail”
    echo -e ” notification for the specified alerts.”
    echo -e ” To get a list of valid alerts please invoke \”$SCRIPTNAME –listalerts\”"
    echo -e “”
    echo -e ” 2) –disable [alert1 alert2|all]”
    echo -e ” If \”–disable\” is specified then specified alert is disabled and no mail notification.”
    echo -e ” ist sent for the specified alert. You can specify a single alert or a space separated list”
    echo -e ” of alerts or \”all\” to disable mail notification for the specified alerts.”
    echo -e ” To get a list of valid alerts please invoke \”$SCRIPTNAME –listalerts\”"
    echo -e “”
    echo -e ” 3) –listalerts”
    echo -e ” If \”–listalerts\” is specified then a all supported \”srvadmin\” alerts on this system are listed.”
    echo -e “”
    echo -e ” 4) –mail [mail text]”
    echo -e ” If \”–mail\” is specified then a mail is sent to the recipient secified in the \”MAIL_RECIPIENT\” variable.”
    echo -e ” The content of the mail is specified in the string [\"mail text\"] following the \”–mail\” option.”
    echo -e “”
    echo -e ” 5) –testmail”
    echo -e ” If \”–testmail\” is specified then a testmail with following content is sent:”
    echo -e ” \”Testing Dell hardware alert warnings…\”"
    echo -e ” The \”–testmail\” can not take more arguments”
    echo -e “”
    }

    send_alert_mail_and_log( ){
    ALERT_MESSAGE=”$(echo $@|awk ‘{print substr($0, index($0,$2)) }’)”
    echo -e “$ALERT_MESSAGE”|mail -s “Hardware alert of Server $HOST_NAME at $HOST_LOCATION” “$MAIL_RECIPIENT”
    logger -t “$SCRIPTNAME” “$ALERT_MESSAGE”
    }

    send_test_mail_and_log( ){
    echo -e “$TEST_MAIL_CONTENT”|mail -s “Hardware alert of Server $HOST_NAME at $HOST_LOCATION” “$MAIL_RECIPIENT”
    logger -t “$SCRIPTNAME” “$TEST_MAIL_CONTENT”
    }

    list_supported_alerts( ){
    omconfig system alertaction 2>”$DEVNULL”|cut -f2 -d”"|sed ‘s/|/ /g’
    }

    get_alert_list( ){
    # Check if alert is valid and build alert list
    ALERT_LIST=”$(echo “$@”|awk ‘{print substr($0, index($0,$2)) }’)”
    if [ "$ALERT_LIST" = all ] ; then
    VALID_ALERT_LIST=$(list_supported_alerts)
    else
    for ALERT in $ALERT_LIST; do
    if list_supported_alerts|grep -q $ALERT; then
    VALID_ALERT_LIST=”$VALID_ALERT_LIST $ALERT”
    else
    echo -e “\n”
    echo -e “The specified alert \”"$ALERT”\” does not exist.”
    echo “Nothing has been changed. Exiting!”
    echo -e “\n”
    return 1
    fi
    done
    fi
    }

    enable_alertmail( ){
    get_alert_list “$@” || return 1
    # Enable alert after user confirmation
    echo “Warning! You are about to change your \”srvadmin\” software configuration.”
    echo -e “\n”
    echo “* Your original \”srvadmin\” configuration will be kept as is. *”
    echo “* Additonally \”srvadmin\” will send mails on hardware alerts! *”
    echo -e “\n”
    echo “If you are shure you want to activate alert mails then”
    echo “press\” yes \” , any other key to abort!”
    read -n 4 CONFIRMATION
    case “$CONFIRMATION” in
    yes|Yes|YES)
    for VALID_ALERT in $VALID_ALERT_LIST; do
    if omconfig system alertaction event=$VALID_ALERT execappath=”$SCRIPTNAME –mail $VALID_ALERT” > “$DEVNULL” 2>&1; then
    echo “Alert \”$VALID_ALERT\” configured successfully.”
    logger -t “$SCRIPTNAME” “Alert \”$VALID_ALERT\” configured successfully.”
    else
    echo “Error! The specified alert \”$VALID_ALERT\” is not supported on this system!”
    logger -t “$SCRIPTNAME” “Error! The specified alert \”$VALID_ALERT\” is not supported on this system!”
    fi
    done
    ;;
    *)
    echo -e “\n”
    echo “Nothing has been changed. Exiting!”
    echo -e “\n”
    return 1
    ;;
    esac
    }

    disable_alertmail( ){
    get_alert_list “$@” || return 1
    # Disable alert after user confirmation
    echo “Warning! You are about to change your \”srvadmin\” software configuration.”
    echo -e “\n”
    echo “* Your original \”srvadmin\” configuration will be kept as is. *”
    echo “* Additonally \”srvadmin\” will stop sending mails on hardware alerts! *”
    echo -e “\n”
    echo “If you are shure you want to disable alert mails then”
    echo “press\” yes \” , any other key to abort!”
    read -n 4 CONFIRMATION
    case $CONFIRMATION in
    yes|Yes|YES)
    for VALID_ALERT in $VALID_ALERT_LIST; do
    if omconfig system alertaction event=$VALID_ALERT execapp=false > “$DEVNULL” 2>&1; then
    #if omconfig system alertaction event=$VALID_ALERT clearall=true > “$DEVNULL” 2>&1; then
    echo “Alert \”$VALID_ALERT\” disabled successfully.”
    logger -t “$SCRIPTNAME” “Alert \”$VALID_ALERT\” disabled successfully.”
    else
    echo “Error! The specified alert \”$VALID_ALERT\” is not supported on this system.”
    logger -t “$SCRIPTNAME” “Error! The specified alert \”$VALID_ALERT\” is not supported on this system!”
    fi
    done
    ;;
    *)
    echo -e “\n”
    echo “Nothing has been changed. Exiting!”
    echo -e “\n”
    return 1
    ;;
    esac
    }

    # here comes the main program
    if [ -z $1 ] ; then
    show_help
    exit 1
    else
    ARG=(“$@”)
    case “${ARG[0]}” in
    –enable)
    if [ -z ${ARG[1]} ] ; then
    show_help
    exit 1
    else
    enable_alertmail “$@” || exit 1
    fi
    ;;
    –disable)
    if [ -z ${ARG[1]} ] ; then
    show_help
    exit 1
    else
    disable_alertmail “$@” || exit 1
    fi
    ;;
    –mail)
    send_alert_mail_and_log “$@”
    ;;
    –testmail)
    if [ ! -z ${ARG[1]} ] ; then
    show_help
    exit 1
    else
    send_test_mail_and_log
    fi
    ;;
    –listalerts)
    list_supported_alerts
    ;;
    *)
    show_help
    exit 1
    ;;
    esac
    fi
    ##################################################################################

    have fun!

  5. dp

    Thank you

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!