Skip to content

Instantly share code, notes, and snippets.

View ashishb888's full-sized avatar

Ashish Bhosle ashishb888

View GitHub Profile
@ashishb888
ashishb888 / ignite-custom-config.xml
Created November 12, 2020 09:26
Ignite custom configuration to connect to visor
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
@ashishb888
ashishb888 / sqlline-parameters
Created November 12, 2020 07:17
Ignite sqlline connection parameters
// Find PID
[user@host ~]$ ps -ef | grep app-name
user 14276 184778 1 11:46 pts/3 00:00:28 /host/setups/jdk1.8.0_191/bin/java -jar app-name-0.0.1-SNAPSHOT.jar
-------------------------------
// Find the list of port used for the PID
[user@host ~]$ netstat -lnp | grep 14422
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
@ashishb888
ashishb888 / pidstat.sh
Last active November 4, 2020 07:22
Monitor a process activity. It can display all the threads associated with a process, IO activity per thread, thread context switching etc
#!/bin/bash
pid=$1
appName=$2
timestamp=`date +%FT%H-%M-%S`
pidstat -w -d -t -p $pid -h 5 > /var/tmp/$appName-$timestamp.out
#bash pidstat.sh 22292 app-name &
@ashishb888
ashishb888 / java-active-threads.sh
Created October 26, 2020 08:04
Java active threads for a process by using top command
#!/bin/bash
pid=$1
nohup top -Hb -p $pid > /var/tmp/top-$pid-`date +%FT%H-%M-%S`.log &
@ashishb888
ashishb888 / os-stats.sh
Last active October 26, 2020 07:55
Operating system statistics
#!/bin/bash
nohup iostat -t 5 > /var/log/iostat-logs/iostat-`date +%FT%H-%M-%S`.log &
nohup top -u hdpusr -b > /var/log/top-logs/top-`date +%FT%H-%M-%S`.log &
nohup vmstat -t 5 > /var/log/vmstat-logs/vmstat-`date +%FT%H-%M-%S`.log &
@ashishb888
ashishb888 / top-cpu-usage-analysis.sh
Last active October 5, 2020 11:32
Analyze the top command (batch mode) output. Extract the used and idle CPU usage and sort by used CPU in descending order
#Single file. Works well with double digits e.g. %Cpu(s): 16.5 us, 81.7 id. You may have to change -f2,10 to -f3,11 or something related
#!/bin/bash
inFile=$1
grep 'Cpu(s)' $inFile | cut -d ' ' -f2,10 | sed '/[a-z]/d' | sort -t',' -k1nr,1
# Calling the script
# bash top-cpu-usage-analysis.sh /var/tmp/cpu-stats-2020-10-01T18-16-58.log
@ashishb888
ashishb888 / jfr.sh
Last active July 17, 2020 10:15
JFR script
#!/bin/bash
pid=$1
appName=$2
fileName=$3
delay=$4
duration=$5
timestamp=`date +%FT%H-%M-%S`
$JAVA_HOME/bin/jcmd $pid VM.unlock_commercial_features
@ashishb888
ashishb888 / ByteBufferUsage.java
Created July 10, 2020 03:21
Java ByteBuffer: Putting dates, timestamps and strings. And getting them back
import java.nio.ByteBuffer;
import java.sql.Date;
import java.sql.Timestamp;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
public class ByteBufferUsage {
@ashishb888
ashishb888 / cpu-stats.sh
Last active October 5, 2020 10:30
Linux top command's first ten records by CPU usage in batch mode
#!/bin/bash
timestamp=`date +%FT%H-%M-%S`
sleepMillis=10
while true
do
top -b -o +%CPU | head -n 17 >> /var/tmp/cpu-stats-$timestamp.log
sleep $sleepMillis
done
@ashishb888
ashishb888 / Java flight recorder
Last active June 29, 2020 12:53
Java flight recording with jcmd
[user@abnormalhost ~]$ $JAVA_HOME/bin/jcmd 56135 JFR.start name=app_name delay=1s duration=2m filename=/var/tmp/app_name.jfr
56135:
Java Flight Recorder not enabled.
Use VM.unlock_commercial_features to enable.
[user@abnormalhost ~]$ $JAVA_HOME/bin/jcmd 56135 VM.unlock_commercial_features
56135:
Commercial Features now unlocked.