#!/bin/bash
# (c) 2002-2003 Newisys, Inc.  All rights reserved.
#
# Example shell script to copy the SNMP trap destination list from the 
# source Service Processor, 10.10.30.5, to the Service Processors listed in the file # sp-ips.txt.
#
# Requires: 
#    sp-ips.txt file with list of IP addresses for each Service Processor to connect to.
#    To be run from SSH client. 
# See documentation for more information about commands.
#
source=10.10.30.206
snmp_destinations=`ssh $source sp get snmp-destinations`
for ip in `cat sp-ips.txt` ; do
   echo "Processing IP: $ip";
   # Delete this Service Processor's current SNMP destination set.
   for snmp_trap_dest in $(ssh $ip sp get snmp-destinations); do
      ssh $ip sp delete snmp-destination $snmp_trap_dest
      if [ $? != 0 ]; then
        echo Error deleting snmp destinations for SP $ip 
      fi
   done
    
   # Now add the trap destinations from the source Service Processor. 
   for snmp_trap_dest in $snmp_destinations; do
      ssh $ip sp add snmp-destination $snmp_trap_dest
      if [ $? != 0 ]; then
         echo Error adding snmp destinations for SP $ip 
      fi    
   done
done
