|

SAMPLE UNIX start_peer FILE:
[For a Linux (Red
Hat 7.0 - 8.0) Installation...File edits are
in RED]
#!/bin/sh
#
# copyright (c) 1994 by the Oracle Corporation
#
# $Header: start_peer 14-may-97.09:07:02 dnakos
Exp $
#
# FILENAME
# start_peer
#
# DESCRIPTION
# This is the script to
startup the peer master agent,
# peer encapsulator and native
snmpd.
#
# OWNER
# wchan
1/4/95
#
if [ "$ORACLE_HOME" = "" ] ; then
echo "ORACLE_HOME
is not set..Exiting.."
exit 1
fi
ME=`basename $0`
USERID=`/usr/bin/whoami`
MASTER=no
ENCAP=no
NATIVE=no
USAGE=no
HELP=no
#
# variables for modifying /etc/inet/services
#
ORG_SNMPD_PORT=161 # port that
snmpd listens to. Don't modify.
ORG_TRAPD_PORT=162 # port that
snmpd send trap to. Don't modify.
NEW_SNMPD_PORT=1161 # new port
that snmpd listens to. Make sure
# this is the same as the one you use in
# CONFIG.encap
NEW_TRAPD_PORT=1162 # peer
enscapsulator port that
# snmpd send trap to.
SYNC_TIME=4
# time allowed for peer startup.
#SNMPD=/opt/SUNWconn/snm/agents/snmpd
# pls. update the location if incorrect
SNMPD=$ORACLE_HOME/network/snmp/peer/snmpd.conf
#/usr/sbin/snmpd -- another option for
snmpd location
SNMPD_CONFIG=snmpd.conf
TRPCMD="exit 1"
trap localhost.localdomain
#"$TRPCMD" 1 2 3 9 15 (This is the
original line)
#
# Check for the user id. If the user is
not root,
# print out the error and usage messages.
#
if [ $USERID != "root" ]
then
echo "$ME: You must be root to run $0."
USAGE=yes;
fi
#
# Parse the arguments and print out usage if
# invalid arguments are found.
#
while [ $# -gt 0 ]
do
case $1 in
-a) MASTER=yes;
ENCAP=yes; NATIVE=yes;;
-m) MASTER=yes;;
-e) ENCAP=yes;;
-n) NATIVE=yes;;
-h) USAGE=yes;
HELP=yes;;
*) echo "$0:
option $1 not recognized"
USAGE=yes;;
esac
shift
done
#
# Print out usage message if error is detected.
#
if [ $USAGE = "yes" ]
then
echo "NAME"
echo " start_peer -
start up peer SNMP processes"
echo
echo "SYNOPSIS"
echo " start_peer
[-a|-m|-e|-n|-h]"
echo
if [ $HELP = yes ]
then
echo "DESCRIPTION"
echo " start_peer will
start up the peer master agents,"
echo " peer
encapsulator and native Linux snmpd depending"
echo " on the arguments
provided. If no argument is"
echo " supplied,
nothing will be done."
echo " ** You must be
root to run this script.**"
echo
echo " SNMP agents must
be started up in order, that is,"
echo " you must first
start up master_peer, then"
echo " encap_peer and
then native snmpd."
echo
echo " Before you run
the start_peer, you must make sure"
echo " that the
maste_peer, encap_peer and snmpd (which"
echo " uses the 161/udp
snmpd and 162/udp trapd) are NOT"
echo " running.
If any of them is running, start_peer"
echo " will not be able
to start up agents process"
echo
echo " Then, you need
to add trap-dest entry with"
echo " your localhost
IP address into the system snmpd.conf"
echo " This the sample
entry:"
echo "
trap-dest: <your localhost IP addr>"
echo
echo " After you run
the start_peer, do a ps to check if"
echo " the processes
are running. See example."
echo
echo " Options"
echo " -a
startup all master_peer, encap_peer and snmpd."
echo " -m
startup master_peer only."
echo " -e
startup encap_peer only."
echo " -n
startup snmpd only."
echo " -h
print usage."
echo
echo "CONFIGURATION FILES"
echo " master_peer
reads the config file under"
echo " $ORACLE_HOME/network/snmp/peer/CONFIG.master"
echo " encap_peer reads
the config file under"
echo "
$ORACLE_HOME/network/snmp/peer/CONFIG.encap"
echo " Native snmpd
reads the config file under"
echo "
$ORACLE_HOME/network/snmp/peer/snmpd.conf"
echo
echo "LOG FILES"
echo " The start_peer
will keep a log file for all"
echo " agent process."
echo " The master_peer log is"
echo " $ORACLE_HOME/network/snmp/peer/master_peer.out."
echo " The encap_peer
log is"
echo " $ORACLE_HOME/network/snmp/peer/encap_peer.out."
echo " The native snmpd
log is"
echo " $ORACLE_HOME/network/snmp/peer/snmpd.out."
echo
echo "EXAMPLES"
echo
echo " % cd $ORACLE_HOME/network/snmp/peer"
echo " % ./start_peer -a"
echo " % ps -ef | grep peer"
echo " root 2750
1 0 11:03:29 ttyq6"
echo " 0:01 ./master_peer
CONFIG.master NOV"
echo " root 2752
1 0 11:03:33 ttyq6"
echo " 0:00 ./encap_peer
-t 1162 -c CONFIG.encap"
echo " % ps -ef | grep snmpd"
echo " root 2761
1 0 11:03:53 ?
0:00 snmpd"
echo
echo " If any of them are not running,
check the log file"
echo " and restart it."
echo
echo "SEE ALSO"
echo " snmpd(1M)"
echo
fi
exit 1
fi
# cd $ORACLE_HOME/network/snmp/peer
#
# It is assumed that master peer agent is not
running.
#
if [ "$MASTER" = yes ]
then
echo "Starting master_peer ..."
if [ ! -x ./master_peer ]
then
echo "$ME: Error:
./master_peer doesn't exist or "
echo "$ME: not
executable. Exiting.."
exit 2
fi
echo "./master_peer CONFIG.master NOV >master_peer.out
2>&1 &"
./master_peer CONFIG.master NOV >
master_peer.out 2>&1 &
sleep $SYNC_TIME # need
some time for peer initialization.
echo "Done!"
echo
fi
#
# It is assumed that encap peer agent is not
running.
#
if [ "$ENCAP" = yes ]
then
echo "Starting encap_peer ..."
if [ ! -x ./encap_peer ]
then
echo "$ME: Error:
./encap_peer doesn't exist or"
echo "$ME: not
executable. Exiting.."
exit 3
fi
# The port number after -s is arbitrary.
It should be set to any
# free port number. But not 1161 or
161
echo "./encap_peer -t $NEW_TRAPD_PORT -s
1160 -c CONFIG.encap >encap_peer.out
2>&1 &"
./encap_peer -t $NEW_TRAPD_PORT -s 1160
-c CONFIG.encap >encap_peer.out 2>&1 &
sleep $SYNC_TIME # need
some time for encap to register.
echo "Done!"
echo
fi
#
# It is assumed the running snmpd is using the
new snmpd
# and trapd are using the new port number.
#
if [ "$NATIVE" = yes ]
then
if [ ! -x $SNMPD
]
then
echo "$ME: Error: $SNMPD doesn't exist or"
echo "$ME: not executable. Exiting.."
exit 4
fi
echo "Starting $SNMPD
..."
echo "$SNMPD -c $SNMPD_CONFIG
-p $NEW_SNMPD_PORT >snmpd.out 2>&1 &"
$SNMPD -c $SNMPD_CONFIG
-p $NEW_SNMPD_PORT >snmpd.out 2>&1 &
echo "Done!"
echo
fi
`$CLRCMD`
|