Skip to content

Instantly share code, notes, and snippets.

@beders
Created June 21, 2015 03:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beders/f0d3e39bccf839ea6b9b to your computer and use it in GitHub Desktop.
Save beders/f0d3e39bccf839ea6b9b to your computer and use it in GitHub Desktop.
List of currently running Java processes, color coded using Nashorn
// List running Java Processes
// ansicolors
var a = { reset : "\u001B[0m", black: "\u001B[30m", red: "\u001B[31m", green: "\u001B[32m",
yellow: "\u001B[33m", blue: "\u001B[34m", purple: "\u001B[35m", cyan: "\u001B[36m",
white: "\u001B[37m"
};
var jps = `jps -vl`.split('\n').slice(0,-1);
var ownPID = java.lang.management.ManagementFactory.getRuntimeMXBean().getName().split('@')[0];
jps.forEach(function(j) {
var params = j.split(' ');
if (params[0] != ownPID)
print(a.red + params[0] + a.white + ' ' + (!params[1] || (params[1][0] == '-') ? 'unknown' : params[1]) + a.reset);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment