Search This Blog

Sunday, July 19, 2015

startNodeManager with WLST in Windows

If you are working on OFMW environments there is a utility script startNMProps.sh/.cmd file present in the ORACLE_COMMON_HOME/common/bin. This script would update the nodemanager.properties file, which is exists in the WL_HOME/common/nodemanger [NM_Home].
When I've used the example command given in the WLST help got the following error:

Caused by: java.lang.UnsatisfiedLinkError: no nodemanager in java.library.path

Here the problem could be solved or workaround with two options:

  1. Check your JAVA_HOME, JAVA_VENDOR values correctly pointed or not.
  2. Change the nodemanager.properties content with the following option

NativeVersionEnabled=false

When you execute the startNodeManager command for the WLST offline you could pass two arguments: DomainRegistrationEnabled, NodeManagerHome.

wls:/offline> startNodeManager(DomainRegistrationEnabled='true',NodeManagerHome='c:/Oracle/product/fmw/wlserver_10.3/common/nodemanager')
Launching NodeManager ...
Removed output here...
Where it displays that generated nodemanager.properties and also shows the domain mapping.
:
:
NMProcess: INFO: Secure socket listener started on port 5556
Successfully launched the Node Manager.
The Node Manager process is running independent of the WLST process.
Exiting WLST will not stop the Node Manager process. Please refer
to the Node Manager logs for more information.
The Node Manager logs will be under c:\Oracle\product\fmw\wlserver_10.3\common\nodemanager
Node Manager starting in the background

You could experiment on NodeManager on Windows share your issues in the comments.


Sunday, July 12, 2015

NodeManager Status from WLST

When you use WebLogic admin console you know the Node manager is 'Reachable' or 'Inactive' state. The same thing if you wish to get it from WLST machine monitoring, this is not available as exposed MBean attribute.



How to find the NodeManager Running from WLST?
Brainstorming...
Found three alternative solutions.

  1. Use jps command to find the NodeManager Pid exist or not
  2. Connect the Nodemanager if it is succeeds then NM Reachable otherwise not.
  3. Use a simple socket module to create the socket object on the host, port

NodeManager Check with jps command

JDK provides jps command to show the list of Java Pids with name of the Java program. provided your JAVA_HOME must be available in os environment variables. So conditions applied here!! anyways lets see the solution :

def nm_status():
        NMstatus=os.system('jps |grep -i nodemanager|grep -v grep')
        if NMstatus==0:
                return 'Reachable'
        else:
                return 'Inactive'
Note: Please check indentations after copying to your editor.
The disadvantage of this method is it is going to work on Linux/Unix environments only, No Windows.

Connect to NodeMnager get State


WLST Command nmConnect() is going to connect if the machine have a Node Manager running, but here it does not returns the output to a variable. The output normally redirecting to standard output stdout. If we can redirect that to a file and check that contians "Connected"word then you can confirm Nodemanager is 'Reachable' otherwise 'Inactive' state.

def NM_status(nmUser, nmPassword, nmHost, nmPort, dName, domainPath,nmTYPE):
 """ This option nmConnect will give that it is reachable or not from stdout """
        redirect('/tmp/mywlst.out')
        nmConnect(nmUser, nmPassword, nmHost, nmPort, dName, domainPath,nmTYPE)
        stopRedirect()
        flag=0
        for line in open("/tmp/mywlst.out"):
         if "Connected" in line:
          flag=1
          break

 nmDisconnect()
        if flag==1:
          return "Reachable"
        else:
         return "Inactive"

Here we met the purpose of knowing about the status of Node manager. Still looking for better alternative than this!

Node manager status by Socket module

In Python we have Socket object and its related methods to check weather a port is available or not. On a machine if we try to create socket object with Node manager ip address, port then it is going to check the port availability that gives us status!

def is_available(address, port):
    import socket
    try:
        s = socket.socket()
        s.connect((address, int(port)))
        return true
    except:
        return false

def nmStatus(machinesList):
 """ This will create global string with Node manager status"
 machine_port=5556
 machine_host=localhost
 global g_str  
 g_str+="NM "+machine+ " -   "
     
 if is_available(machine_host, machine_port):
  g_str+="Reachable"+"\n"
 else:
  g_str+="Inactive"+"\n"
 
In you main script you could call nmStatus to know about the nodemanager status. Do you have any new thoughts, ideas or suggestions are welcome, Thanks for being with me.

Popular Posts