Skip to content

Instantly share code, notes, and snippets.

@henrikno
henrikno / gist:4eabd7a4cb5be2f37f9d86145e5cae39
Created April 30, 2020 00:07
Get current/max memory usage for java process
PID=$(jps | grep Main | awk '{print $1}')
CUR=$(jstat -gc $PID | tail -n 1 | awk '{split($0,a," "); sum=a[3]+a[4]+a[6]+a[8]; print sum/1024}')
MAX=$(jstat -gccapacity $PID | tail -n 1 | awk '{split($0,a," "); sum=a[2]+a[8]; print sum/1024}')
echo $CUR/$MAX
@henrikno
henrikno / server.py
Last active March 4, 2021 20:46
Python Multithreaded TCP server example
#!/usr/bin/python
import socket # Import socket module
from threading import Thread
def on_new_client(clientsocket, addr):
try:
while True:
msg = clientsocket.recv(1024)
if not msg: