Java 查看容器信息的几种方式
Java JVM About 7,540 words注意
只能在Linux
下该命令才有效。
命令
Java 11 及之后版本
方法一
jcmd 1 VM.info
输出:截取了最后一段System
系统信息的输出,可以看到container (cgroup) information
段落输出的信息,包含了容器的信息。
--------------- S Y S T E M ---------------
OS:Oracle Linux Server release 8.6
uname:Linux 5.10.0-18-amd64 #1 SMP Debian 5.10.140-1 (2022-09-02) x86_64
OS uptime: 46 days 3:09 hours
libc:glibc 2.28 NPTL 2.28
rlimit (soft/hard): STACK 8192k/infinity , CORE infinity/infinity , NPROC infinity/infinity , NOFILE 1048576/1048576 , AS infinity/infinity , CPU infinity/infinity , DATA infinity/infinity , FSIZE infinity/infinity , MEMLOCK 64k/64k
load average:4.88 5.41 5.93
/proc/meminfo:
MemTotal: 32489056 kB
MemFree: 1832792 kB
MemAvailable: 11278572 kB
Buffers: 369380 kB
Cached: 9691252 kB
SwapCached: 0 kB
Active: 4636248 kB
Inactive: 24453228 kB
Active(anon): 670084 kB
Inactive(anon): 19083268 kB
Active(file): 3966164 kB
Inactive(file): 5369960 kB
Unevictable: 0 kB
Mlocked: 0 kB
SwapTotal: 0 kB
SwapFree: 0 kB
Dirty: 12996 kB
Writeback: 0 kB
AnonPages: 18592124 kB
Mapped: 2141784 kB
Shmem: 797720 kB
KReclaimable: 573880 kB
Slab: 1070984 kB
SReclaimable: 573880 kB
SUnreclaim: 497104 kB
KernelStack: 144176 kB
PageTables: 126788 kB
NFS_Unstable: 0 kB
Bounce: 0 kB
WritebackTmp: 0 kB
CommitLimit: 16244528 kB
Committed_AS: 48700848 kB
VmallocTotal: 34359738367 kB
VmallocUsed: 170624 kB
VmallocChunk: 0 kB
Percpu: 45216 kB
HardwareCorrupted: 0 kB
AnonHugePages: 10881024 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 1542016 kB
DirectMap2M: 30963712 kB
DirectMap1G: 3145728 kB
/sys/kernel/mm/transparent_hugepage/enabled:
[always] madvise never
/sys/kernel/mm/transparent_hugepage/defrag (defrag/compaction efforts parameter):
always defer defer+madvise [madvise] never
Process Memory:
Virtual Size: 11734336K (peak: 19148420K)
Resident Set Size: 499804K (peak: 502604K) (anon: 473196K, file: 26608K, shmem: 0K)
Swapped out: 0K
C-Heap outstanding allocations: 30143K, retained: 77856K
glibc malloc tunables: (default)
/proc/sys/kernel/threads-max (system-wide limit on the number of threads):
253553
/proc/sys/vm/max_map_count (maximum number of memory map areas a process may have):
65530
/proc/sys/kernel/pid_max (system-wide limit on number of process identifiers):
4194304
container (cgroup) information:
container_type: cgroupv2
cpu_cpuset_cpus: not supported
cpu_memory_nodes: not supported
active_processor_count: 1
cpu_quota: no quota
cpu_period: 100000
cpu_shares: 28
memory_limit_in_bytes: unlimited
memory_and_swap_limit_in_bytes: unlimited
memory_soft_limit_in_bytes: unlimited
memory_usage_in_bytes: 514707456
memory_max_usage_in_bytes: not supported
KVM virtualization detected
Steal ticks since vm start: 0
Steal ticks percentage since vm start: 0.000
CPU:total 8 (initial active 1) (4 cores per cpu, 2 threads per core) family 6 model 85 stepping 4 microcode 0x1, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, avx, avx2, aes, clmul, erms, rtm, 3dnowpref, lzcnt, ht, tsc, tscinvbit, bmi1, bmi2, adx, fma
CPU Model and flags from /proc/cpuinfo:
model name : Intel(R) Xeon(R) Platinum 8163 CPU @ 2.50GHz
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single pti ibrs ibpb stibp fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx avx512f avx512dq rdseed adx smap avx512cd avx512bw avx512vl xsaveopt xsavec xgetbv1 arat
Online cpus:
0-7
Offline cpus:
BIOS frequency limitation:
<Not Available>
Frequency switch latency (ns):
<Not Available>
Available cpu frequencies:
<Not Available>
Current governor:
<Not Available>
Core performance/turbo boost:
<Not Available>
Memory: 4k page, physical 32489056k(1832792k free), swap 0k(0k free)
vm_info: OpenJDK 64-Bit Server VM (11.0.16+8) for linux-amd64 JRE (11.0.16+8), built on Jul 16 2022 23:58:30 by "openjdk" with gcc 8.3.1 20190311 (Red Hat 8.3.1-3)
END.
方法二
java -XshowSettings:system -version
输出
bash-4.4# java -XshowSettings:system -version
Operating System Metrics:
Provider: cgroupv2
Effective CPU Count: 1
CPU Period: 100000us
CPU Quota: -1
CPU Shares: 1024us
List of Processors: N/A
List of Effective Processors, 8 total:
0 1 2 3 4 5 6 7
List of Memory Nodes: N/A
List of Available Memory Nodes, 1 total:
0
Memory Limit: 800.00M
Memory Soft Limit: 0.00K
Memory & Swap Limit: 800.00M
openjdk version "11.0.16" 2022-07-19
OpenJDK Runtime Environment 18.9 (build 11.0.16+8)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.16+8, mixed mode, sharing)
方法三
java -Xlog:os*=trace -version
Java 8
java -XX:+UnlockDiagnosticVMOptions -XX:+PrintContainerInfo -version
输出
/ # java -XX:+UnlockDiagnosticVMOptions -XX:+PrintContainerInfo -version
OSContainer::init: Initializing Container Support
Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes
Memory Limit is: 9223372036854771712
Memory Limit is: Unlimited
Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu/cpu.cfs_quota_us
CPU Quota is: -1
Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu/cpu.cfs_period_us
CPU Period is: 100000
Path to /cpu.shares is /sys/fs/cgroup/cpu/cpu.shares
CPU Shares is: 1024
OSContainer::active_processor_count: 2
Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu/cpu.cfs_quota_us
CPU Quota is: -1
Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu/cpu.cfs_period_us
CPU Period is: 100000
Path to /cpu.shares is /sys/fs/cgroup/cpu/cpu.shares
CPU Shares is: 1024
OSContainer::active_processor_count: 2
Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes
Memory Limit is: 9223372036854771712
Memory Limit is: Unlimited
container memory limit unlimited: -1, using host value
Path to /memory.limit_in_bytes is /sys/fs/cgroup/memory/memory.limit_in_bytes
Memory Limit is: 9223372036854771712
Memory Limit is: Unlimited
container memory limit unlimited: -1, using host value
Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu/cpu.cfs_quota_us
CPU Quota is: -1
Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu/cpu.cfs_period_us
CPU Period is: 100000
Path to /cpu.shares is /sys/fs/cgroup/cpu/cpu.shares
CPU Shares is: 1024
OSContainer::active_processor_count: 2
Path to /cpu.cfs_quota_us is /sys/fs/cgroup/cpu/cpu.cfs_quota_us
CPU Quota is: -1
Path to /cpu.cfs_period_us is /sys/fs/cgroup/cpu/cpu.cfs_period_us
CPU Period is: 100000
Path to /cpu.shares is /sys/fs/cgroup/cpu/cpu.shares
CPU Shares is: 1024
OSContainer::active_processor_count: 2
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (IcedTea 3.12.0) (Alpine 8.212.04-r0)
OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
参考手册
Java 11
https://docs.oracle.com/en/java/javase/11/tools/java.html
Java 8
https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
Views: 1,143 · Posted: 2023-06-06
————        END        ————
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...