Menu

Saturday, 15 May 2021

Scripts for HeapDump Generation On JBoss || Tomcat

 ##To Capture the 1 HeapDmp file with CPU usage on Tomcat & JBoss application.

Step 1: Create a file "heap_dump_script.sh" and add below script codes.

##Codes for heapdump generation.
***********************************************************
#!/bin/sh
JAVA_HOME=/u01/jdk1.8.0_121
# Number of times to collect data.
LOOP=1
# Interval in seconds between data points.
INTERVAL=1
 
for ((i=1; i <= $LOOP; i++))
do
   _now=$(date)
   echo "${_now}" >>high-cpu-Heap.out
   top -b -n 1 -H -p $1 >>high-cpu-Heap.out
   echo "${_now}" >>high-cpu-Heapdump.out
  $JAVA_HOME/bin/jmap -dump:format=b,file=heapdump_`date +"%Y-%m-%d-%T"`.hprof $1
   echo "heap dump captured #" $i
   if [ $i -lt $LOOP ]; then
      echo "Sleeping..."
      sleep $INTERVAL
   fi
done
 ***********************************************

Step 2: How to Run the "heap_dump_script.sh" script.

./heap_dump_script.sh JVM_PID


For HeapDump analysis , use Memory Analyzer (MAT) tool.

Download Address: https://www.eclipse.org/mat/downloads.php


Thanks :-)

Scripts for ThreadDump Generation On JBoss & Tomcat

 ###To Capture 6 ThreadDump with 20seconds interval + 6 High CPU Threads output with 20seconds interval.

Step 1: create a file  & write below codes.


#script code "high_cpu_linux_jstack.sh"
************************************************************

#!/bin/sh

JAVA_HOME=/u01/jdk1.8.0_121

# Number of times to collect data.

LOOP=6

# Interval in seconds between data points.

INTERVAL=20

 

for ((i=1; i <= $LOOP; i++))

do

   _now=$(date)

   echo "${_now}" >>high-cpu.out

   top -b -n 1 -H -p $1 >>high-cpu.out

   echo "${_now}" >>high-cpu-tdump.out

  $JAVA_HOME/bin/jstack -l $1 >>high-cpu-tdump.out

   echo "thread dump #" $i

   if [ $i -lt $LOOP ]; then

      echo "Sleeping..."

      sleep $INTERVAL

   fi

done

************************************************************

How to Run the "high_cpu_linux_jstack.sh" script.

./ high_cpu_linux_jstack.sh JVM_PID


Analysis of high_cpu_linux_jstack.sh can be easily done from REDHAT LABS:

Step 1 : GO to Address: https://access.redhat.com/labs/jvmpeg/

 Step 2: DROP your output files for HIGH CPU easy analysis with modifying CPU Threshold.

Snap:-

Thanks :-)

Thursday, 6 May 2021

How to install opensource mod_security on Apache 2.4

 Step 1: Download the mod_security  binaries 

https://github.com/SpiderLabs/ModSecurity/releases/download/v2.9.1/modsecurity-2.9.1.tar.gz

 Or 

https://src.fedoraproject.org/lookaside/pkgs/mod_security/


Step 2: tar -zxvf modsecurity-2.9.1.tar.gz

 

Step 3: cd modsecurity-2.9.1

 

Step 4: Run below commands:

            ./configure --with-apxs=$Apache_Home/bin/apxs

make

make install

 

 Step 5: Add/Enable module in httpd.conf file.

LoadModule unique_id_module modules/mod_unique_id.so

LoadModule security2_module modules/mod_security2.so

 

 Step 6: for version disclosed add below parameters in httpd.conf

           ########################################

Header unset Server

Header unset Etag

ServerTokens Prod

ServerSignature off

Header always unset "X-Powered-By"

Header unset "X-Powered-By"

 

<IfModule security2_module>

    SecRuleEngine Off

    ServerTokens Full

    SecServerSignature " "

</IfModule>

#########################################

 Thanks :-)

 How to install opensource mod_security on Apahce 2.4

How to upgrade opensource apache from 2.4.39 to 2.4.46 (Minor Version Upgrade).

 Step 1: Install below rpm on Linux server.

yum install openssl-devel

yum install pcre-devel

yum install pcre

yum install expat-devel

yum install openssl

yum install gcc

yum install libxml2-devel

 

Step 2: Download the latest version and copy on server & extract http://httpd.apache.org/

 

Step 3: Locate to OLD version $Apache_Home/build folder copy the "config.nice" to New Apache binaries location.

  

Step 4: Locate to New Apache binaries location and run below commands:

 Commands:

$ ./config.nice

$ make

$ make install

 

 Step 5: Check the OLD apache version , it must be updated.

$Apache_Home/bin/httpd -V

 

Thanks :-) 

How to upgrade opensource apache from 2.4.39 to 2.4.46 (Minor Version Upgrade).