Uncategorized

A New Tech Sharing Flavor In Middleware Magic

.

First of all Happy New Year to all our readers/Subscribers. Thank you for all your support and Visits on Middleware Magic. It’s time when we taken a step ahead and started a new venture called Sharing .  As part of Sharing you will see a lots of insight on day to day technologies like Promotions, Giveaway, Mobile technology, Social Networking, Internet and lots more.

Just wanted to share this with you As

“MM Sharing is all about Sharing…”

So now the Moddleware magic has two flavors as follows:

1).   Middleware Magic Sharing: http://middlewaremagic.com/sharing/

2). Middleware Magic WebLogic: http://middlewaremagic.com/weblogic/

.

Thanks

Ravish Mody & Jay SenSharma


Creating DataSource Using WLST with Properties File

Hi,

Jay SenSharma

Jay SenSharma

Here is a simple example of WLST Script which allows us to create Users and Groups  and Assign different Users to Different Groups. Doing the same thing from admin console is very time consuming. The following WLST Script is just an example for the same but it can be enhance more to delete Users and Groups as well in the same manner.

The best thing here is the Administrator need to just edit the properties file with the users and group details, rest of the things will be taken care by the WLST Script. Administrator need to just change the  Iteration of “for” Loop in the WLST Script sccording to the number of WebLogic Users and WebLogic Groups.

Step1). Create a Directory somewhere in your file system like :  “C:WLST_MultiDomain_DS”

Step2). Write a Properties file “details.properties” inside “C:WLST_MultiDomain_DS” like following:

domain.name=7001_Domain
admin.url=t3://localhost:7001
admin.userName=weblogic
admin.password=weblogic
security.realmName=myrealm

create.group.name.1=GroupOne
create.group.name.2=GroupTwo

create.group.description.1= This is a Test Gropu One
create.group.description.2= This is a Test Gropu Two

create.user.name.1=TestUserOne
create.user.password.1=TestUserOnePassword
create.user.description.1= This is a Test User One

create.user.name.2=TestUserTwo
create.user.password.2=TestUserTwoPassword
create.user.description.2= This is a Test User Two

create.user.name.3=TestUserThree
create.user.password.3=TestUserThreePassword
create.user.description.3= This is a Test User Three

create.group.name.1.members=TestUserOne,TestUserTwo,
create.group.name.2.members=TestUserThree,

NOTE: The “create.group.name.1.members” Entries must end with a COMMA (,)
Step3). Write the  WLST Script “users_groups.py” inside “C:WLST_MultiDomain_DS” directory.

from java.io import FileInputStream

propInputStream = FileInputStream("details.properties")
configProps = Properties()
configProps.load(propInputStream)

domainName=configProps.get("domain.name")
adminURL=configProps.get("admin.url")
adminUserName=configProps.get("admin.userName")
adminPassword=configProps.get("admin.password")
realmName=configProps.get("security.realmName")

connect(adminUserName, adminPassword, adminURL)
serverConfig()
authenticatorPath= '/SecurityConfiguration/' + domainName + '/Realms/' + realmName + '/AuthenticationProviders/DefaultAuthenticator'
print authenticatorPath
cd(authenticatorPath)
print 'Creating Groups . . .'
for i in 1,2:
    groupName = configProps.get("create.group.name."+ str(i))
    groupDescription = configProps.get("create.group.description."+ str(i))
    cmo.createGroup(groupName , groupDescription)
    print '-----------Group Created With Name : ' , groupName

    print 'Creating Users . . .'
for x in 1,2,3:
    userName = configProps.get("create.user.name."+ str(x))
    userPassword = configProps.get("create.user.password."+ str(x))
    userDescription = configProps.get("create.user.description."+ str(x))
    cmo.createUser(userName , userPassword , userDescription)
    print '-----------User Created With Name : ' , userName

    print 'Adding Group Membership of the Users:'
for y in 1,2:
    grpName = configProps.get("create.group.name."+ str(y))
    groupMembers= configProps.get("create.group.name."+ str(y) + ".members")
    usrName=''
    for member in groupMembers:
                    if member == ",":
                    	cmo.addMemberToGroup(grpName,usrName)
                    	print 'USER:' , usrName , 'Added to GROUP: ' , grpName
                    	usrName=''
                    else:
                        usrName=usrName+member
    print ' '
    print ' '

Step4). Run the “. ./setWLSEnv.sh” by adding two DOTs separated by a single space …..before the actual script like following : (use ‘cd’ command to move inside the <BEA_HOME>/wlserver_10.3/server/bin) then run the following command….
.  ./setWLSEnv.sh
Note: the first DOT represents that set the Environment in the current Shell, AND the second ./ represents execute the script from the current directory.

Step5). Now run the WLS Script like following:
java        weblogic.WLST        users_groups.py

C:WLST_MultiDomain_DS>java weblogic.WLST users_groups.py

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

7001_Domain
t3://localhost:7001
weblogic
weblogic
myrealm
Connecting to t3://localhost:7001 with userid weblogic ...
Successfully connected to Admin Server 'AdminServer' that belongs to domain '7001_Domain'.

Warning: An insecure protocol was used to connect to the
server. To ensure on-the-wire security, the SSL port or
Admin port should be used instead.

Already in Config Runtime

/SecurityConfiguration/7001_Domain/Realms/myrealm/AuthenticationProviders/DefaultAuthenticator
Creating Groups . . .
-----------Group Created With Name :  GroupOne
Creating Users . . .
-----------Group Created With Name :  GroupTwo
Creating Users . . .
-----------User Created With Name :  TestUserOne
Adding Group Membership of the Users:
-----------User Created With Name :  TestUserTwo
Adding Group Membership of the Users:
-----------User Created With Name :  TestUserThree
Adding Group Membership of the Users:
USER: TestUserOne Added to GROUP:  GroupOne
USER: TestUserTwo Added to GROUP:  GroupOne

USER: TestUserThree Added to GROUP:  GroupTwo

.
.
Thanks
Jay SenSharma

1 Comment more...

WebLogic SNMP LogFilter Configuration

Hi All,
Jay SenSharma

Jay SenSharma

In this Example we are going to see a very Simple Demonstration of Using the WebLogic SNMP Agent with the LogFilter. This sample will explain us how we can set a Log Filter using SNMP Agent so that an Alert will be sent to the SnmpTrapMonitor as soon as we make any Changes at “Management” Subsystem of WebLogic Server which causes a “Warning” Message in the Server Log.
So Basically this tutorial will explain us How SNMP Agent will send an Alert to the SnmpTrapMonitor as soon as a Warning message is encountered by the <Management> subsystem of WebLogic Server.
.
Note: In the following sample of SNMP we are not going to use any SNMP Tree for MIB navigation but for advance usages of WebLogic SNMP Agent you can use the below link…which helps a lot while navigating the MIBs  http://download.oracle.com/docs/cd/E11035_01/wls100/snmp/index.html
.
Step1). We Need to Start the Admin Server and then Login to the AdminConsole.
.
Step2). Create one SNMP Agent in the AdminConsole “Diagnostics—->SNMP”
Creating_SNMP_Agent

Creating_SNMP_Agent

Make_Sure_To_Enable_SNMP

Make_Sure_To_Enable_SNMP

Step3). Once you target the SNMP agent on the running server then you will get the following output on the prompt which makes sure that our configuration is taken properly.
SNMP Trap

SNMP Trap

Step4). Creating the LogFilter for the SNMP Agent. The WebLogic SNMP agent runs on a domain’s Administration Server, It can GET requests from an SNMP manager for the current value of WebLogic attributes as well as it can send notifications to SNMP managers.
SNMP_LogFilter_Configuration

SNMP_LogFilter_Configuration

SNMP_LogFilter

SNMP_LogFilter

Step5). We Need to create a “Trap Destination”. A Trap Destination provides the information that the WebLogic SNMP agent needs to send trap notifications to an SNMP manager.  Make sure to configure the Trap Destination like below.
SNMP_TrapDestination

SNMP_TrapDestination

Step6). Now  After above configurations your Server WebLogic Configuration file “<DOMAIN_HOME>/config/config.xml” will look like this. Make Sure to Restart the Server so that the Changes will take Effect.
  <snmp-agent-deployment>
    <name>TestSNMP</name>
    <enabled>true</enabled>
    <send-automatic-traps-enabled>true</send-automatic-traps-enabled>
    <snmp-port>162</snmp-port>
    <snmp-trap-version>1</snmp-trap-version>
    <community-prefix>public</community-prefix>
    <snmp-trap-destination>
      <name>MyTrapDestination-1</name>
      <host>localhost</host>
      <port>165</port>
      <community>public</community>
      <security-level>noAuthNoPriv</security-level>
    </snmp-trap-destination>
    <snmp-log-filter>
      <name>ManagementSNMPLogFilter-0</name>
      <enabled-server>AdminServer</enabled-server>
      <severity-level>Warning</severity-level>
      <subsystem-name>Management</subsystem-name>
    </snmp-log-filter>
    <community-based-access-enabled>true</community-based-access-enabled>
    <snmp-engine-id>TestSNMP</snmp-engine-id>
    <authentication-protocol>noAuth</authentication-protocol>
    <privacy-protocol>noPriv</privacy-protocol>
    <inform-retry-interval>3000</inform-retry-interval>
    <max-inform-retry-count>1</max-inform-retry-count>
    <localized-key-cache-invalidation-interval>3600000</localized-key-cache-invalidation-interval>
    <snmp-access-for-user-m-beans-enabled>false</snmp-access-for-user-m-beans-enabled>
    <inform-enabled>false</inform-enabled>
    <master-agent-x-port>705</master-agent-x-port>
    <target>AdminServer</target>
  </snmp-agent-deployment>

Now Testing The WebLogic SNMP LogFilter

Step7). Now start the  “SnmpTrapMonitor like following: (Make Sure to run the “. ./setWLSEnv.sh” to set the environment in the same shell prompt where you are planning to run the following command)
java weblogic.diagnostics.snmp.cmdline.Manager SnmpTrapMonitor -p 165
Starting_SNMP_Trap_Monitor

Starting_SNMP_Trap_Monitor

Step8). Now Just login to AdminConsole and Make some <Management> related Changes like….Changing the Log Rotation Type to something else and then activate the changes:
AdminServer—-> Logging (Tab) —-> Rotation Type —> By Time
Changing_LoggingType_For_SNMPMonitoring

Changing_LoggingType_For_SNMPMonitoring

Step9). As soon as you change the Log Rotation type you will see the following Kind of Trap is received by the Trap Monitor:
Log_Filter_SNMPTrap_Recieved

Log_Filter_SNMPTrap_Recieved

The Log Filter actually Fetching the Entry made by the WebLogic Server as following:
####<Dec 6, 2010 10:16:18 PM IST> <Warning> <Management> <Jack> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <weblogic> <> <87a1a732136bce67:-637c5910:12cbc927883:-7ffd-000000000000006b> <1291653978890> <BEA-141239> <The non-dynamic attribute RotationType on weblogic.management.configuration.LogMBeanImpl@4525819d([7001_Domain]/Servers[AdminServer]/Log[AdminServer]) has been changed. This may require redeploying or rebooting configured entities> 

####<Dec 6, 2010 10:16:18 PM IST> <Warning> <Management> <Jack> <AdminServer> <[ACTIVE] ExecuteThread: '2' for queue: 'weblogic.kernel.Default (self-tuning)'> <weblogic> <> <87a1a732136bce67:-637c5910:12cbc927883:-7ffd-000000000000006b> <1291653978890> <BEA-141238> <A non-dynamic change has been made which affects the server AdminServer. This server must be rebooted in order to consume this change.> 
.
.
Thanks
Jay SenSharma

Copyright © 2010-2012 Middleware Magic. All rights reserved. |