Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
vzprocess: ps with CTID filtration for OpenVZ
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";

This comment has been minimized.

Copy link

phincylp commented May 20, 2015

excellent !!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.