Creating SNMP Trap Destination using WLST

Creating SNMP Trap Destination using WLST

Here we are going to  create SNMP Trap Destinations for domain ” Testdomain”

____________________________________________________________________________
 
from java.util import *
from javax.management import *
import javax.management.Attribute
print ‘Starting the script …. ‘
connect(‘system’,'weblogic’,'t3://localhost:7001′)
print ‘Changing to edit mode…’
 
# Check if Diagnostic Module already exists
try:
cd(‘SNMPTrapDestinations/TestdomainSNMPTrapDestination’)
print ‘The TestdomainSNMPTrapDestination Trap Destination already exists.’
exit()
except WLSTException:
pass
print ‘Changing to edit mode…’
edit()
startEdit()
cd(‘/SNMPAgent/Testdomain’)
cmo.createSNMPTrapDestination(‘TestdomainSNMPTrapDestination’)
cd(‘SNMPTrapDestinations/TestdomainSNMPTrapDestination’)
set(‘Community’,'public’)
set(‘Host’,'localhost’)
set(‘Port’,’162′)
cd(‘/SNMPAgent/Testdomain’)
set(‘Enabled’,'true’)
save()
activate()
disconnect()
print ‘End of script, exiting WLST…’
exit()