Class LinuxInfoUtils
java.lang.Object
org.apache.pulsar.broker.loadbalance.LinuxInfoUtils
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic class -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanCheck this VM has nic speed.static doubleGet CGroup cpu usage.static LinuxInfoUtils.ResourceUsageReads first line of /proc/stat to get total cpu usage.static doublegetTotalCpuLimit(boolean isCGroupsEnabled) Get total cpu limit.static doublegetTotalNicLimit(List<String> nics, org.apache.pulsar.broker.BitRateUnit bitRateUnit) Get all physical nic limit.static doublegetTotalNicUsage(List<String> nics, LinuxInfoUtils.NICUsageType type, org.apache.pulsar.broker.BitRateUnit bitRateUnit) Get all physical nic usage.Get paths of all usable physical nic.static booleanDetermine whether the OS enable CG Group.static booleanisLinux()Determine whether the OS is the linux kernel.
-
Constructor Details
-
LinuxInfoUtils
public LinuxInfoUtils()
-
-
Method Details
-
isLinux
public static boolean isLinux()Determine whether the OS is the linux kernel.- Returns:
- Whether the OS is the linux kernel
-
isCGroupEnabled
public static boolean isCGroupEnabled()Determine whether the OS enable CG Group. -
getTotalCpuLimit
public static double getTotalCpuLimit(boolean isCGroupsEnabled) Get total cpu limit.- Parameters:
isCGroupsEnabled- Whether CGroup is enabled- Returns:
- Total cpu limit
-
getCpuUsageForCGroup
public static double getCpuUsageForCGroup()Get CGroup cpu usage.- Returns:
- Cpu usage
-
getCpuUsageForEntireHost
Reads first line of /proc/stat to get total cpu usage.cpu user nice system idle iowait irq softirq steal guest guest_nice cpu 317808 128 58637 2503692 7634 0 13472 0 0 0Line is split in "words", filtering the first. The sum of all numbers give the amount of cpu cycles used this far. Real CPU usage should equal the sum substracting the idle cycles, this would include iowait, irq and steal.
-
getTotalNicLimit
public static double getTotalNicLimit(List<String> nics, org.apache.pulsar.broker.BitRateUnit bitRateUnit) Get all physical nic limit.- Parameters:
nics- All nic pathbitRateUnit- Bit rate unit- Returns:
- Total nic limit
-
getTotalNicUsage
public static double getTotalNicUsage(List<String> nics, LinuxInfoUtils.NICUsageType type, org.apache.pulsar.broker.BitRateUnit bitRateUnit) Get all physical nic usage.- Parameters:
nics- All nic pathtype- Nic's usage type: transport, receivebitRateUnit- Bit rate unit- Returns:
- Total nic usage
-
getUsablePhysicalNICs
Get paths of all usable physical nic.- Returns:
- All usable physical nic paths.
-
checkHasNicSpeeds
public static boolean checkHasNicSpeeds()Check this VM has nic speed.- Returns:
- Whether the VM has nic speed
-