Track who is using weblogic admin console

Oracle Weblogic Server

This is a very basic question I have got from many users. There are multiple ways of getting this info. it is also best practice to check the current session before doing any changes. You can configure the Administration Server to emit audit messages that enable auditing of configuration changes in a domain. This provides a record of changes to the configuration of any resource within a domain or invokes management operations on any resource within a domain. Configuration audit records can be saved to a log file, sent to an Auditing provider in the security realm, or both.

below are the steps to configure the same so that audit messages will come in logs for any configuration changes:
In the left pane of the Console, under Domain Structure, select the domain name.
Select Configuration > General, then click Advanced at the bottom of the page.
In the Configuration Audit Type field, select the method to be used for auditing configuration change events:
None – do not audit configuration change events
Change Log – Configuration events will be written to the server log.
Change Audit – Configuration events will be directed to the Security Framework and handled by the Auditing provider.
Change Log and Audit – Configuration events will written to the server log as well as directed to the Security Framework and handled by the Auditing provider.
Click Save and Activate.

But few times we have seen customers ask about getting the username who is logged in to the adminconsole and holding the lock.

While searching for an answer I stumble upon a script which exactly does the same. Below is the python script which will display which user is logged and holding the lock.

Using below script you can track the users activity in admin console.

from weblogic.management.mbeanservers.edit import NotEditorException

### Define all the requried variable
username = 'weblogic'
password = 'weblogic1'
url = 't3://localhost:7001'

### Connect to the Administration Server
connect(username, password, url)

### Get the Configuration Manager
cfgManager = getConfigManager()
try:
cfgManager.getChanges()
print '===> Currently there is a Session'
if cfgManager.isEditor() == true:
### You are making changes!!!
print '===> Looks like you started that session'
print '===> You can check the console for any pending changes'
print '===> Try rerunning this script after you release or commit the pending changes'
exit()

except NotEditorException, e:
if cfgManager.getCurrentEditor() is None:
### No session
pass
else:
### Someone else is making changes
userWithSession = cfgManager.getCurrentEditor().replace(' ', '')
print '===> Currently there is a Session'
print '===> User \"' +userWithSession+'\" is making the changes'
print '===> Wait until \"' +userWithSession+'\" complete the current session'
exit()
pass
except Exception:
### Other Errors
print '===> Error, see log for more info'
exit()

### Disconnect from the Administration Server
disconnect()
exit()

Here is the 12.1.1 MBean Reference page for the MBean:

http://docs.oracle.com/cd/E24329_01/apirefs.1211/e24403/mbeans/ConfigurationManagerMBean.html

If you want to know all the best practices then visit this blog post http://weblogicserver.blogspot.in/2009/02/do-not-step-on-others-feet-wlst.html

 

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.