try using /etc/realname if it's there

master
Daniel Jakots 6 years ago
parent 98d219d681
commit 867e2b5415
  1. 15
      bgpd-check-peers.sh

@ -17,7 +17,13 @@ _MAILTO="noc@example.com"
_TMPDIR=/tmp/check-bgp
_PIDFILE="${_TMPDIR}"/bgpd-check-peers.pid
_HOSTNAME=$(hostname)
if [ -e /etc/realname ]; then
_REALNAME=$(cat /etc/realname)
_HOSTNAME=$(hostname -s)
else
_HOSTNAME=$(hostname)
fi
mkdir -p "${_TMPDIR}"
@ -92,7 +98,12 @@ if [[ -f "${_TMPMAILDIR}"/bodynok ]] ; then
cat "${_TMPMAILDIR}"/bodynok >> "${_TMPMAILDIR}"/body
fi
cat "${_TMPMAILDIR}"/body | mail -s "[BGP] ${_HOSTNAME} - State change" "${_MAILTO}"
# Send the mail whether we have a realname or not
if [ -n "${_REALNAME}" ]; then
cat "${_TMPMAILDIR}"/body | mail -s "[BGP] ${_REALNAME} (${_HOSTNAME}) - State change" "${_MAILTO}"
else
cat "${_TMPMAILDIR}"/body | mail -s "[BGP] ${_HOSTNAME} - State change" "${_MAILTO}"
fi
# cleaning
if [[ -d "${_TMPMAILDIR}" ]] ; then

Loading…
Cancel
Save