Created
October 4, 2016 08:28
-
-
Save teddyking/9fdffb3331ed1bc1bc40d104164a4122 to your computer and use it in GitHub Desktop.
Hacktastic script to print a PID from each mount namespace on a host
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
| mntnses = Dir.glob("/proc/*/ns/mnt") | |
| foundmnts = [] | |
| foundpids = [] | |
| mntnses.each do |mntns| | |
| actualmntns = `readlink "#{mntns}"` | |
| pid = mntns.split("/")[2] | |
| mntnum = actualmntns.gsub(/mnt:\[/, "").gsub(/\]/, "") | |
| #puts "#{pid} - #{mntnum}" | |
| if ! foundmnts.include? mntnum | |
| foundmnts << mntnum | |
| foundpids << pid | |
| end | |
| end | |
| puts foundpids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment