Friday, August 24, 2018

Shell Script which uses sendmail

#!/bin/sh
#
# Generic script for forwarding Mail from Netcool/OMNIbus
#
# Parameters to be passed from Netcool/OMNIbus are;
# $1 - @Node
# $2 - @Severity
# $3 - "Message" - mail message header text
# $4 - "user" - user to receive mail
# $5 - @Summary
# $6 - @NodeAlias
#
cat <<EOF > /tmp/tmp.$$
To: $4
Subject: $3

This message refers to node $1 ($6) which has the following problem;

$5

The Severity is $2

Severity Table:
5 - Critical (Tickets)
4 - Major
3 - Minor
2 - Warning
1 - Indeterminate
0 - Clear (Resolution)

Sent by the Netcool/OMNIbus Automation system
EOF

# Find the send mail program: it is in different places on different platforms
for senddir in /usr/sbin /sbin /usr/lib /bin /usr/bin
do
        if [ -x "$senddir/sendmail" ]
        then
                break
        fi
done

# Run send mail
"$senddir/sendmail" $4 < /tmp/tmp.$$

rm /tmp/tmp.$$

No comments:

Post a Comment