Last active
August 29, 2015 14:23
-
-
Save Chaturaphut/027f0e13633c4004f4dc to your computer and use it in GitHub Desktop.
Revisions
-
pavel-odintsov created this gist
May 4, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ #!/usr/bin/perl use strict; use warnings; unless (scalar @ARGV == 1) { die "Parameter needed, please pass ctid as parameter"; } my $ctid = $ARGV[0]; sub get_ctid { my $pid = shift; open my $fl, "<", "/proc/$pid/status" or return 0; while(<$fl>) { if (/TaskUB:\s*(\d+)/i) { return $1; } } # it's host system return 0; } my @all_processes = `ps aux`; chomp @all_processes; for my $process_raw (@all_processes) { my (undef, $pid) = split /\s+/, $process_raw; if (get_ctid($pid) == $ctid) { print $process_raw, "\n"; } }