-XX:NativeMemoryTracking=detail
jps
ps -p <PID> -o pcpu,rss,size,vsize
| import java.util.regex.Matcher; | |
| import java.util.regex.Pattern; | |
| public class RegexMatcheUtils { | |
| public static void main(String[] args) { | |
| String result = replaceWithHandler("${x}*get(@36,3)", "@\\w+", | |
| new RegexMatcheHandler() { |
| import java.io.*; | |
| import java.util.*; | |
| import sun.jvm.hotspot.memory.*; | |
| import sun.jvm.hotspot.oops.*; | |
| import sun.jvm.hotspot.debugger.*; | |
| import sun.jvm.hotspot.runtime.*; | |
| import sun.jvm.hotspot.tools.*; | |
| import sun.jvm.hotspot.utilities.*; | |
| public class DirectMemorySize extends Tool { |
| import java.lang.instrument.Instrumentation; | |
| import java.net.URL; | |
| import java.security.CodeSource; | |
| import java.security.ProtectionDomain; | |
| import java.util.Arrays; | |
| import java.util.Comparator; | |
| public class DumpClassURL { | |
| public static void agentmain(String agentArgs, Instrumentation inst) { | |
| Class<?>[] classes = inst.getAllLoadedClasses(); |
| 在java机器上执行: | |
| tcpdump -i eth1 -s 0 -l -w - dst port 3306 | strings | |
| -s 0 : 抓取数据包时默认抓取长度为68字节。加上-s 0 后可以抓到完整的数据包 | |
| -l:表示每行都输出到文件,不缓存 | |
| -w - :输出到console | |
| dst port 3306 :目标端口,必须写在最后 |
指标参考下面几个内容整理。
含义参考了: 对应的 manpage, kernel doc。
We're looking at CPU bandwidth control via CFS:
Program does number of iterations, in each iteration we burn CPU in small chunks until we get 5ms of real time spent. On each iteration we also print how much
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| #include <sys/socket.h> | |
| #include <netinet/in.h> | |
| #define SERVER_ADDR "173.194.72.94" | |
| #define SERVER_PORT 80 | |
| int main() |
| xstat() { | |
| for target in "${@}"; do | |
| inode=$(ls -di "${target}" | cut -d ' ' -f 1) | |
| fs=$(df "${target}" | tail -1 | awk '{print $1}') | |
| crtime=$(sudo debugfs -R 'stat <'"${inode}"'>' "${fs}" 2>/dev/null | | |
| grep -oP 'crtime.*--\s*\K.*') | |
| printf "%s\t%s\n" "${crtime}" "${target}" | |
| done | |
| } |