Skip to content

Instantly share code, notes, and snippets.

import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.channels.FileChannel.MapMode;
import java.nio.file.Paths;
import java.time.LocalDateTime;
public class LongTTSP {
public static void main(String[] args) throws Exception {
@qsLI
qsLI / Monitors.java
Created September 28, 2022 06:57 — forked from apangin/Monitors.java
Java monitor contention profiler
public class Monitors {
public static native void startProfiling(Object monitor);
public static native void stopProfiling();
public static native long getBlockTime();
public static native long getBlockCount();
static {
System.loadLibrary("monitors");
}

To achieve this you can setup DNS Proxy Mode using the host's resolver with the following command: VBoxManage modifyvm "VM name" --natdnshostresolver1 on

As the result, guest OS DNS requests will be intercepted and resolved using host DNS API, rather than having guest OS connect to external DNS servers as with --netdnsproxy1 on.

You can get the name of the VM by running VBoxManage list runningvms.

@qsLI
qsLI / tcpdump.md
Created September 21, 2020 03:41 — forked from qzaidi/tcpdump.md
capture http headers

HTTP Headers

tcpdump -A -s 10240 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' | egrep --line-buffered "^........(GET |HTTP\/|POST |HEAD )|^[A-Za-z0-9-]+: " | sed -r 's/^........(GET |HTTP\/|POST |HEAD )/\n\1/g'

HTTP Headers and body, on a given interface to a certain dst

tcpdump -i ens4 -A -s 10240 'dst 172.21.43.252 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

Postgres Queries

sudo tcpdump -i lo -s0 -nl -w- dst port postgres | strings -n8
@qsLI
qsLI / Execution-Cache-Single-Use-Plans-Explore.sql
Created November 21, 2019 06:56 — forked from LitKnd/Execution-Cache-Single-Use-Plans-Explore.sql
TSQL to do a quick and dirty look at single-use plans in the execution plan cache of a SQL Server.
/***********************************************************
TSQL to do a quick and dirty look at single-use plans in
the execution plan cache of a SQL Server.
************************************************************/
/* Size of single use adhoc plans in execution plan cache */
SELECT
objtype,
cacheobjtype,
SUM(size_in_bytes)/1024./1024. as [MB]

Object Query Language (OQL)

$ java -version
java version "1.8.0_20"
Java(TM) SE Runtime Environment (build 1.8.0_20-b26)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b23, mixed mode)

OQL is SQL-like query language to query Java heap. OQL allows to filter/select information wanted from Java heap. While pre-defined queries such as "show all instances of class X" are already supported by HAT, OQL adds more flexibility. OQL is based on JavaScript expression language.

-- From this article: https://logicalread.com/troubleshoot-high-cpu-sql-server-pd01/#.WW_hjtPytuY
-- Show CPU Utilization by SQL Server, system idle time and other processes
DECLARE @ms_ticks_now BIGINT
SELECT @ms_ticks_now = ms_ticks
FROM sys.dm_os_sys_info;
SELECT TOP 15 record_id
,dateadd(ms, - 1 * (@ms_ticks_now - [timestamp]), GetDate()) AS EventTime
,SQLProcessUtilizationPercent
@qsLI
qsLI / README.md
Created May 27, 2019 08:49 — forked from sfgeorge/README.md
Carbon / Graphite tip: How to use whisper-resize to change xFilesFactor on existing stats

Carbon / Graphite tip: How to use whisper-resize to change xFilesFactor on existing stats

Detailed Steps

1.) Update /etc/carbon/storage-aggregation.conf to use the new xFilesFactor setting for new stats, if you haven't yet already

2.) Get the retention ranges as defined in storage-schemas.conf

fgrep retentions /etc/carbon/storage-schemas.conf | tr ',' ' '
@qsLI
qsLI / gist:56261ccb4391b52467ac51cdf99ac3b0
Created October 24, 2018 06:00 — forked from jacobhackl/gist:1057159
SQL Activity mon query
--from http://sqlblog.com/blogs/john_paul_cook/archive/2009/08/24/using-the-processes-query-outside-of-activity-monitor.aspx
/* ACTIVITY MONITOR */
/* Processes */
SELECT
[Session ID] = s.session_id,
@qsLI
qsLI / ignore-line-endings
Created October 19, 2018 15:55 — forked from robert-claypool/ignore-line-endings
Ignore Line Endings with Git Merge
git config merge.renormalize true # prevents unnecessary merge conflicts, http://stackoverflow.com/a/12194759/23566