Last active
January 17, 2018 20:25
-
-
Save c0mpiler/8b8c913b91ec5f6c2f0f67aeeaee0170 to your computer and use it in GitHub Desktop.
Print File descriptors count
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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