
#!/bin/sh
# File	: chk_finger.sh
# By	: Maarten.deBoer@AtosOrigin.com, 091214
# Subject	: Check if no hanging users (from not today)
# (0.2)	: Case added
#set -x
PGM="`basename $0|cut -d\. -f1`"
VERSION="0.2"
TMP="/tmp/${PGM}.$$"
LOG="${HOME}/log/${PGM}.log"
MAILTO="maarten.deboer@atosorigin.com"
touch ${TMP}
OS="`uname -s`"
case ${OS} in
  SunOS)
    DAY="`date +%a`" ; finger|grep -v TTY|grep -v "${DAY}"|grep -v 'No one logged on'|tee -a ${TMP} ;;
  Linux)
    DAY="`date +%d`" ; finger|grep -v Tty|grep -v "${DAY}"|grep -v 'No one logged on'|tee -a ${TMP} ;;
  *) echo "Unknown OS (${OS}). Exiting ..." >> ${TMP} ;;
esac
# If ${TMP} (error msg), then mail
if [ -s ${TMP} ]; then
  cat ${TMP} | mailx -s "`hostname`: Check finger [${PGM} v${VERSION}]" ${MAILTO}
  echo "Mailed to ${MAILTO}"
fi
rm ${TMP}
exit

