Posts

Showing posts from 2019

How to extract java stack trace log from tomcat log file?

catalina.out - Tomcat output file. ERROR - The keyword displayed in the log file containing the java stack trace. sed -n '/ERROR/p; //,/^[0-9]\{4\}-/ {/^[0-9]\{4\}-/!p}' catalina.out  Ref : https://www.unix.com/shell-programming-and-scripting/277433-using-grep-finding-stacktraces.html

How to find java heap memory usage ?

jmap -heap 26442 Attaching to process ID 26442, please wait... Debugger attached successfully. Server compiler detected. JVM version is 8.1.045 9.0.4+011 using thread-local object allocation. Garbage-First (G1) GC with 8 thread(s) Heap Configuration:    MinHeapFreeRatio         = 40    MaxHeapFreeRatio         = 70    MaxHeapSize              = 27262976000 (26000.0MB)    NewSize                  = 5452592 (5.1999969482421875MB)    MaxNewSize               = 16357785600 (15600.0MB)    OldSize                  = 5452592 (5.1999969482421875MB)    NewRatio                 = 2    SurvivorRatio            = 8    MetaspaceSize            = 21807104 (20.796875MB)    CompressedClassSpaceSize = 268435456 (256.0MB)    MaxMetaspaceSize         = 10737418240 (10240.0MB)    G1HeapRegionSize         = 8388608 (8.0MB) Heap Usage: G1 Heap:    regions  = 3250    capacity = 27262976000 (26000.0MB)    used     = 25738931416 (24546.557823181152MB)    free     = 1524044584 (1453.4421768188477MB)    94.40

SSL domain expiry - bulk domain list

Hi, This is where you need to check the SSL certificate validity for large number of domains. domainlist.txt - The file which stores the list of domains that we need to check the SSL expiry. In this file, make sure that only one domain name is in each row. i - The variable used here, for each iteration, each domain is checked. for i in `cat domainlist.txt` ; do echo "++++++++++++++++ $i ++++++++++++++++" ; echo | openssl s_client -servername NAME -connect $i:443 2>/dev/null | openssl x509 -noout -dates ; echo --------------------------------------- ; done

Bash basics for personal use

Replace using sed when too many slashes are there. --------------------------------------------------- sed -i -e 's@/home/username/jas/@/home/username/jas/folder/@g' file.sh sed -i -e 's@xxx.xxx.xxx.xxx@xxx.xxx.xxx.xxx@g' file.sh Note : In bash scripting on remote server ssh login, we could experience problems with awk print $ and "`". In such situations, use cut and there will be no such issues. To add double quotes in a line which has words separated by comma. ----------------------------------------------------------------- sed -e 's/"//g' -e 's/[^,]*/"&"/g' -i filename To add double quotes at end of line in a file. ------------------------------------------------- sed -e 's/$/"/' -i filename To add double quotes at beginning of a line in a file. ----------------------------------------------------- sed -e 's/^/"/' -i filename To check a log file between two dates. -------------------------------