Package io.antmedia
Class SystemUtils
java.lang.Object
io.antmedia.SystemUtils
This utility is designed for accessing server's
system information more easier.
- Author:
- The Red5 Project (red5@osflash.org), DZS|All-In-One (coolest2guy@gmail.com)
-
Field Summary
Modifier and TypeFieldDescriptionstatic Boolean
static final String
private static final String
private static HotSpotDiagnosticMXBean
static final String
Obtain Java JRE version.static final int
protected static final org.slf4j.Logger
static final int
static final long
static final String
static final int
static final String
Obtain Operating System's Architecture.static final String
Obtain Operating System's name.static final int
Obtain Operating System's processor.static final int
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic long
static long
convertByteSize
(long bytes, String size) static String
convertByteSize
(Long bytes, String size, boolean txtByte) Requirement support for...static String
convertByteSize
(Long bytes, String size, Boolean txtByte, boolean isDisk) Permit to convert bytes to ALMOST any upper bytes with/without extension (Currently at existing TeraByte but one step ahead, PetaByte)static String
convertByteSizeToDisk
(Long bytes, String size, boolean txtByte) protected static void
Custom Error issued switch.protected static void
Error Exception issued switch.static void
getHeapDump
(String filepath) private static HotSpotDiagnosticMXBean
static Long
static Long
static Integer
Returns the "% recent cpu usage" for the Java Virtual Machine process.static Long
Returns the CPU time used by the process on which the Java virtual machine is running in microseconds.static Integer
Returns the "% recent cpu usage" for the whole system.static double
static long
static boolean
static long
Obtain JVM's Free Memory.static long
Obtain JVM's In Use Memory.static long
Obtain JVM's Maximum Memory.static long
Obtain JVM's Total Memory.static long
static long
Obtain Virtual Memory from Operating System's RAM.static long
Obtain Free Physical Memory from Operating System's RAM.static long
Obtain Free Swap Space from Operating System's RAM.static long
osHDFreeSpace
(String path) Obtain Harddrive's Available Space.static long
osHDInUseSpace
(String path) Obtain Harddrive's In Use Space.static long
osHDTotalSpace
(String path) Obtain Harddrive's Overall Space.static long
osHDUsableSpace
(String path) Obtain Harddrive's Usable Space.static long
Obtain In Use Physical Memory from Operating System's RAM.static long
Obtain In Use Swap Space from Operating System's RAM.static long
Obtain Total Physical Memory from Operating System's RAM.static long
Obtain Total Swap Space from Operating System's RAM.static String
readCgroupFile
(String filePath)
-
Field Details
-
HEAPDUMP_HPROF
- See Also:
-
MAX_CONTAINER_MEMORY_LIMIT_BYTES
public static final long MAX_CONTAINER_MEMORY_LIMIT_BYTES- See Also:
-
MAX_MEMORY_CGROUP_V2
- See Also:
-
osName
Obtain Operating System's name. -
osArch
Obtain Operating System's Architecture. -
jvmVersion
Obtain Java JRE version. -
osProcessorX
public static final int osProcessorXObtain Operating System's processor. -
HOTSPOT_BEAN_NAME
- See Also:
-
hotspotMBean
-
logger
protected static final org.slf4j.Logger logger -
MAC_OS_X
public static final int MAC_OS_X- See Also:
-
LINUX
public static final int LINUX- See Also:
-
WINDOWS
public static final int WINDOWS- See Also:
-
OS_TYPE
public static final int OS_TYPE -
containerized
-
-
Constructor Details
-
SystemUtils
public SystemUtils()
-
-
Method Details
-
jvmMaxMemory
public static long jvmMaxMemory()Obtain JVM's Maximum Memory.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
jvmTotalMemory
public static long jvmTotalMemory()Obtain JVM's Total Memory.- Returns:
- bytes size
-
jvmFreeMemory
public static long jvmFreeMemory()Obtain JVM's Free Memory.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
jvmInUseMemory
public static long jvmInUseMemory()Obtain JVM's In Use Memory.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osCommittedVirtualMemory
public static long osCommittedVirtualMemory()Obtain Virtual Memory from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osTotalPhysicalMemory
public static long osTotalPhysicalMemory()Obtain Total Physical Memory from Operating System's RAM.- Returns:
- bytes size
-
getTotalPhysicalMemorySize
public static long getTotalPhysicalMemorySize() -
osFreePhysicalMemory
public static long osFreePhysicalMemory()Obtain Free Physical Memory from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osAvailableMemory
public static long osAvailableMemory()- Returns:
- the amount of available physical memory
-
osInUsePhysicalMemory
public static long osInUsePhysicalMemory()Obtain In Use Physical Memory from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osTotalSwapSpace
public static long osTotalSwapSpace()Obtain Total Swap Space from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osFreeSwapSpace
public static long osFreeSwapSpace()Obtain Free Swap Space from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osInUseSwapSpace
public static long osInUseSwapSpace()Obtain In Use Swap Space from Operating System's RAM.- Parameters:
size
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osHDUsableSpace
Obtain Harddrive's Usable Space.- Parameters:
path
- actual pathsize
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osHDTotalSpace
Obtain Harddrive's Overall Space.- Parameters:
path
- actual pathsize
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osHDFreeSpace
Obtain Harddrive's Available Space.- Parameters:
path
- actual pathsize
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
osHDInUseSpace
Obtain Harddrive's In Use Space.- Parameters:
path
- actual pathsize
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
convertByteSize
Requirement support for... ------------------------------- jvmMaxMemory() jvmTotalMemory() jvmFreeMemory() jvmInUseMemory() osCommittedVirtualMemory() osFreePhysicalMemory() osTotalPhysicalMemory() osInUsePhysicalMemory() osFreeSwapSpace() osTotalSwapSpace() osInUseSwapSpace() osHDUsableSpace() osHDTotalSpace() osHDFreeSpace() osHDInUseSpace() ------------------------------- -
convertByteSizeToDisk
-
convertByteSize
-
convertByteSize
Permit to convert bytes to ALMOST any upper bytes with/without extension (Currently at existing TeraByte but one step ahead, PetaByte)- Parameters:
bytes
- length of bytessize
- null, AUTO, B, KB, MB, GB, TB, or PB (PetaByte does not exist yet) Is not case sensitive.txtByte
- true if include byte extension, false exclude extension- Returns:
- bytes size
-
error
Error Exception issued switch.- Parameters:
e
- Throws exception errors
-
error
Custom Error issued switch.- Parameters:
error
- Error #info
- Extra info from error executed
-
getSystemCpuLoad
Returns the "% recent cpu usage" for the whole system.- Returns:
-
getSystemLoadAverageLastMinute
public static double getSystemLoadAverageLastMinute() -
getProcessCpuLoad
Returns the "% recent cpu usage" for the Java Virtual Machine process. the method returns a negative value.- Returns:
-
getProcessCpuTime
Returns the CPU time used by the process on which the Java virtual machine is running in microseconds.- Returns:
-
getHeapDump
-
getHotspotMBean
-
availablePhysicalBytes
public static long availablePhysicalBytes() -
isContainerized
public static boolean isContainerized() -
getMemoryLimitFromCgroup
- Throws:
IOException
-
getMemAvailableFromCgroup
- Throws:
IOException
-
readCgroupFile
- Throws:
IOException
-