#!/bin/sh

# Follow the snmplog.messages file for "real-time" SNMP message display.

# Copyright (c) 2002 - Marc Niegowski
#                      Connectivity, Inc.
#                      23 W. Fourth Street
#                      Media, PA 19063-2805
#                      USA
#
#                      All Rights Reserved
#
#                      Phone: (610) 566-0227
#                      Fax:   (610) 566-0641
#
#                      Email: Marc@Tech-Center.com
#                      Web:   http://www.marcsweb.com
#                      Ftp:   ftp://ftp.marcsweb.com

echo -e "\n"
echo followlog - SNMPLog message display utility
echo -e "\n"

# Edit the following path if your log file has a
# different name or is located elsewhere.

F=/var/log/snmplog/snmplog.messages

if test -f $F
   then L=`sed -n $= $F` || \
        {
        echo -e "\n"
        echo Unable to open/read log file $F
        echo -e "\n"
        exit -1
        }

   if test -z $L
      then L=0
   fi

   echo $F contains $L log records.
   echo -e "\n"
   echo Use Ctrl-C to stop "tailing" $F
   echo -e "\n"

   tail -n$L -f $F

   exit 0
fi

echo File $F doesn\'t exist.
echo -e "\n"
exit -1
