JBOSS Monitoring Commands on Linux

 

##Check all the process ids of Jboss:

pgrep -f jboss

 

##Check on which port jboss is running

ps -eaf | grep  jboss | cut -c126-140

 

##Cut can be customized

 ps -eaf | grep  jboss | grep -E -o ".{0,8}httpport.{0,8}"

 

 

##Command to get only specific text:

cut -c126-140

 

##will list all chars starting from 126 to 140

 

##JBoss cheatsheet for Linux Administrators

##Details Published: 05 January 2016

 

#Domain How to check that the Domain Controller is alive

 

#!/bin/bash

CONNECTED=$(netstat -an | grep -wF 9999 | wc -l)

while [ $CONNECTED -gt 0 ]

do

  sleep 20

  CONNECTED=$(netstat -an | grep -wF 9999 | wc -l)

done

echo "Lost Domain Controller! Do something here."

##Replace "9999" with the jboss.management.native.port if you don't use the default port.

 

##JBoss CLI

 

##How to store in a bash variable the result of a Command Line readAttribute

 

heapused=$(./jboss-cli.sh -c "/core-service=platform-mbean/type=memory:read-attribute(name=heap-memory-usage)" | grep "used" | awk '{print $3}' | sed 's/L,//')

 

 

##How to check that the application web.war is deployed

 

APPS=$(./jboss-cli.sh --controller=127.0.0.1:9999 -c "deploy")

 

list=( $APPS )

 

deployed=false

 

for i in "${list[@]}"

do

        #echo $i

        if [ $i = "web.war" ] ; then

        deployed=true;  

        fi

done

 

if [ "$deployed" = true ]

then

 echo "Application web.war deployed"

else

echo "Application web.war not available"

fi

##How to shutdown the application server

 

$JBOSS_HOME/bin/jboss-cli.sh --connect --controller=$CONTROLLER_IP:$CONTROLLER_PORT --command=:shutdown

JAR Files

 

##How to find a class in a set of JARS recursively

 

##Here is how to search recursively for the class org.jboss.as.ejb3.cache.CacheFactory in the modules folder of the application server

 

$ grep -r org.jboss.as.ejb3.cache.CacheFactory modules

#Binary file modules/system/layers/base/org/jboss/as/ejb3/main/jboss-as-ejb3-7.5.0.Final-redhat-21.jar matches

#How to compile a class adding all the application server JARS in the classpath

 

$ javac -cp .:`find $JBOSS_HOME -name "*.jar" | tr "\n" ":"` MyClass.java

#Server logs

 

#How to grep the Server logs for the last hour (ex. find the ERROR String)

 

$ grep "^$(date -d '-1 hour' +'%H')" /home/jboss/server.log  | grep 'ERROR'

 

#How to grep the Server logs for the last minutes (ex. find the ERROR String)

 

#$ sed -n "/^$(date --date='10 minutes ago' '+%H:%M')/,\$p" /home/jboss/log/server.log | grep "ERROR"

 

 

#How to find which logs files contain a String in the last n days (ex. 5 days)

 

$ find . -name "server.log*" -mtime -5 | xargs grep -i "OutOfMemoryError"

#Clustering

 

#How to check that multicast is working properly

 

$ java -cp jgroups-3.0.14.Final.jar org.jgroups.tests.McastReceiverTest -mcast_addr 224.10.10.10 -port 5555

$ java -cp jgroups-3.0.14.Final.jar org.jgroups.tests.McastSenderTest -mcast_addr 224.10.10.10 -port 5555

##(Replace the jgroups JAR with the one you have in your distribution)

 


 


 

Comments

Popular posts from this blog

Command Line tool for Android and iOS [ adb and cfgutil ]

Convert Chrome recording to Vugen Script

Jmeter-CheatSheet