| #!/bin/csh
#
# mcc_hubwatch.csh
#
# Digital Equipment Corporation, 1992.
#
# Software Product Group
# Open Network Systems Engineering
# Network Management Systems
#
# Description:
#
# This is C-Shell script to invoke the DEC Hub Watch90 Application for all
# selected entities on a DECmcc Iconical Map.
#
# Parameters:
#
# $1 is the name of the Launch Application Datafile
#
# Dependencies:
# DEC Hub Watch90 Environment variable LNMSHOME points to toplevel directory
# in which HUBWatch software resides.
#
#
# Set up some variables.
#
set HUBWATCH_DIR = `printenv NMS_DIR`
if ($HUBWATCH_DIR == "") then
echo "DEC Hub Watch 90 Application invokation requires"
echo " LNMSHOME to point to top_level directory."
exit 1
endif
#
# File containing IP community strings.
# Format: IP_address read_community write_community
#
set COMMUNITY_FILE = $HUBWATCH_DIR/uid/DH90_comm_table.txt
#
# Get application launch datafile from DECmcc
#
set DATAFILE = $1
if ($DATAFILE == "") then
echo "No datafile passed. Exiting"
exit 1
endif
#
# Get list of selected SNMP entities from launch application datafile.
#
set IPs = `cat $DATAFILE | awk '$1 == "SENTITY:" && $2 == "SNMP" {print $6}'`
set Hosts = `cat $DATAFILE | awk '$1 == "SENTITY:" && $2 == "SNMP" {print $8}'`
#
# If there are NO selected SNMP entities, exit.
#
if ($#IPs == 0) then
echo "NO SNMP Entities were selected. Exiting."
exit 0
endif
#
@ i = 0
#
# Start up DEC HUB Watch for each selected SNMP entity.
#
foreach ip ($IPs)
#
set host = ($Hosts)
@ i++
#
# Get community string for read and write for each IP.
# If community file does NOT exist, prompt user for
# information and write it to new file.
set read_comm = `grep $ip $COMMUNITY_FILE | awk '{print $3}'`
set write_comm = `grep $ip $COMMUNITY_FILE | awk '{print $4}'`
#
# If EITHER are not found then MUST ask user to enter manually.
# Because we just don't know for sure which one was mistakenly
# removed from the file.
#
while ($read_comm == "")
echo -n "ENTER read community string for SNMP entity ($ip): "
set read_comm = $<
end
#
if ($write_comm == "") then
echo -n "ENTER write community string for SNMP entity ($ip) [unknown]: "
set ans = $<
if ($ans != "") set write_comm = $ans
endif
#
grep $ip $COMMUNITY_FILE >> /dev/null
if ($status == 1) then
echo "$ip $read_comm $write_comm" >> $COMMUNITY_FILE
if ($status != 1)
echo "Couldn't update $COMMUNITY_FILE with community strings. Check protections."
endif
#
# Invokation depending on availability of write community string.
# Inform user that when write_community is found in $COMMUNITY_FILE, application
# will be invoked with write permissions.
#
if ($write_comm == "") then
echo "DEC HUB Watch 90 invoked for SNMP entity $ip read-only."
echo " If read-write required, edit $COMMUNITY_FILE and ensure entry states "
echo " ip_address read_community write_community."
echo ""
$HUBWATCH_DIR/bin/DH90_main -x $ip -a $host -to 5 -rt 3 &
else
$HUBWATCH_DIR/bin/DH90_main -x $ip -c $write_comm -a $host -to 5 -rt 3 &
endif
end
sleep 20
exit
|