Skip to content

Instantly share code, notes, and snippets.

View ChinaXing's full-sized avatar
🤣
I may be slow to respond.

chinaxing ChinaXing

🤣
I may be slow to respond.
View GitHub Profile
@ChinaXing
ChinaXing / md5-hex-string.erl
Created March 27, 2015 07:12
erlang-md5-hex-string
get_md5_hex_str(Str) ->
X = erlang:md5(Str),
[begin if N < 10 -> 48 + N; true -> 87 + N end end || <<N:4>> <= X].
@ChinaXing
ChinaXing / btrace-java-agent.sh
Created April 27, 2020 09:13
btrace java agent
# -------------- trace script Java source ---------------- #
import com.sun.btrace.annotations.*;
import static com.sun.btrace.BTraceUtils.*;
import com.sun.btrace.AnyType;
@BTrace // (trusted=true)
public class Test {
@OnMethod(
clazz="java.net.ServerSocket",
method="bind"
@ChinaXing
ChinaXing / fix-nic-teamd.sh
Created February 12, 2020 14:22
teamd fix
yum erase ais-vnic -y # 卸载ali-vnic
yum install teamd -y
systemctl daemon-reload # systemctl 更新配置
modprobe bonding # teamd依赖
modprobe team # teamd依赖的驱动
ip link del bond0 # 删除bond 驱动新增的网卡
systemctl restart network # 启动网络,teamd 后台进程会启动 ps auxf | grep teamd 查看确认
-- 分析 unreachable对象 https://wiki.eclipse.org/MemoryAnalyzer/FAQ#How_to_analyse_unreachable_objects
-consoleLog -application org.eclipse.mat.api.parse -keep_unreachable_objects <heapDump.bin>
-- 查询 非unreachable的对象,GCRootInfo null 表名此对象非GcRoot,MAT keepunreachable 对象时,unreachable对象的gcroot是自身
SELECT * FROM byte[] s WHERE ((s.@length >= 2000000) and (s.@GCRootInfo = null))
@ChinaXing
ChinaXing / ps-tools.md
Last active November 16, 2018 06:27
ps-tools

show pid namespace all threads of process 21503

ps axH -opid,ppid,pidns -p 21503

list namespace of process 21503

lsns -p 21503

list namespace inode of process 21503

ls -iL /proc/21503/ns/pid

@ChinaXing
ChinaXing / jstat config
Created January 24, 2018 07:51
start jstatd all policy
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
jstatd -J-Djava.security.policy=jstatd.all.policy
@ChinaXing
ChinaXing / java-attach-api.java
Last active September 13, 2017 08:10
attach to JVM use java attach API
import com.sun.tools.attach.VirtualMachine;
import com.sun.tools.attach.VirtualMachineDescriptor;
import java.util.List;
public class ListVM{
public static void main(String[] args){
List<VirtualMachineDescriptor> vmList = VirtualMachine.list();
for(VirtualMachineDescriptor vm : vmList){
System.out.println("name: " + vm.displayName() + " id :" + vm.id());
try{
@ChinaXing
ChinaXing / packet-loose.sh
Created October 24, 2016 06:08
packet loose mock use tc
#!/bin/env bash
# --------------------------------------------
#
# 网络丢包模拟工具
#
# --------------------------------------------
block(){
interface=$1
import com.sun.btrace.annotations.*;
import com.sun.btrace.AnyType;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class Q{
@OnMethod(
clazz="java.nio.Buffer",
method="/.*/",
location=@Location(value=Kind.FIELD_SET, clazz="java.nio.Buffer", field="po
import com.sun.btrace.annotations.*;
import com.sun.btrace.AnyType;
import static com.sun.btrace.BTraceUtils.*;
@BTrace
public class Q{
@OnMethod(
clazz="java.nio.Buffer",
method="/.*/",
location=@Location(value=Kind.FIELD_SET, clazz="java.nio.Buffer", field="po