Last active
August 29, 2015 14:04
-
-
Save martinhynar/702acf820da2290b4f75 to your computer and use it in GitHub Desktop.
Java's jps in Python using Twitter Commons
This file contains 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
import os | |
import glob | |
import twitter.common.java.perfdata as twc | |
if __name__ == '__main__': | |
pattern = os.path.join('/tmp', 'hsperfdata_*', '*') | |
for path in glob.glob(pattern): | |
root, pid = os.path.split(path) | |
dirname = os.path.basename(root) | |
role = dirname[len('hsperfdata_'):] | |
def loader(): | |
with open(path, 'rb') as fp: | |
return fp.read() | |
perfdata = twc.PerfData.get(loader) | |
perfdata.sample() | |
print role, int(pid), perfdata['sun.rt.javaCommand'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment