#!/bin/ksh
#
# Send trap using the snmptrap supplied with NetView in /usr/OV/bin
# Trap here is NetView change status trap
# Source should be passed as $1 - fully qualified domain name
# $2 is 3 word string where:
#  1st word is "Service" , 2nd word is service name , 3rd word is service status
#	
#
#set -x
MANAGER=`hostname`
ENTERPRISE=.1.3.6.1.4.1.2.6.3.1
# If domain name has "." and "-" they will be escaped, so unescape
SOURCE=`echo "$1" | sed "s:\\\\\\::g"`
# Split out $2 into 3 words, $1, $2, $3
set $2
SERVICE="$2"
SERV_STATUS="$3"
#
GENTRAP=6
SPECTRAP=58916871
TIMESTAMP=1
TRAPVAR=.1.2.6.1.4.1.2.6.3.1.1.2.0
SELECTION="$SOURCE":"$SERVICE".CF
if [ $SERV_STATUS = Normal ]
then
  STATUS=Normal
else
  STATUS=User2
fi
#
MESSAGE="Status changed on $SELECTION to $STATUS"
#
/usr/OV/bin/snmptrap $MANAGER $ENTERPRISE $SOURCE $GENTRAP $SPECTRAP $TIMESTAMP  \
  $TRAPVAR Integer 14				\
  $TRAPVAR OctetString $SELECTION		\
  $TRAPVAR OctetString "$MESSAGE Object status is"	\
  $TRAPVAR OctetString $STATUS
#


