Skip to content

Instantly share code, notes, and snippets.

@c0mpiler
Last active January 17, 2018 20:25
Show Gist options
  • Save c0mpiler/8b8c913b91ec5f6c2f0f67aeeaee0170 to your computer and use it in GitHub Desktop.
Save c0mpiler/8b8c913b91ec5f6c2f0f67aeeaee0170 to your computer and use it in GitHub Desktop.
Print File descriptors count
package com.ibm.labbook.utils;
import com.ibm.lang.management.ExtendedOperatingSystem;
import com.ibm.lang.management.ManagementUtils;
import com.ibm.lang.management.OperatingSystemMXBean;
import com.ibm.lang.management.UnixOperatingSystemMXBean;
@SuppressWarnings("restriction")
public class SystemUtil{
public static void main(String[] args) {
printOpenFDs("test");
}
public static void printOpenFDs(String text){
if(text == null)
text = "";
else
text = text.trim();
ManagementUtils.getOperatingSystemBean();
OperatingSystemMXBean os = ExtendedOperatingSystem.getInstance();
if(os instanceof UnixOperatingSystemMXBean){
System.out.println("["+text+"] Number of open fd: " + ((UnixOperatingSystemMXBean) os).getOpenFileDescriptorCount());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment