X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=root-context%2Fexec%2Fpl-ps;fp=root-context%2Fexec%2Fpl-ps;h=eafdf5bd4c567ee60171f03591fe5a066efdbd52;hb=10503d985ac1acdac4ed653e608ccc492baa446a;hp=0000000000000000000000000000000000000000;hpb=46f46b3486d68231a875c7c21e5dd64282b3813a;p=vsys-scripts.git diff --git a/root-context/exec/pl-ps b/root-context/exec/pl-ps new file mode 100755 index 0000000..eafdf5b --- /dev/null +++ b/root-context/exec/pl-ps @@ -0,0 +1,36 @@ +#!/usr/bin/perl +use strict; + +############################################### +# pl-ps for slicestat by KyoungSoo Park +############################################### + +my %slice_id; +my %slice; + +open THIS_PIPE, "/bin/awk -F: \'{print \$1, \$3}\' /etc/passwd |"; +while() { + if (/(.+)\s+(\d+)/) { + $slice_id{$1} = $2; + $slice{$2} = $1; + } +} +close THIS_PIPE; + +open THIS_PIPE, "/usr/sbin/vps -eo pid,user | sed 1d | awk \'{print \$1, \$2}\' | sort -k 2 |"; +while() { + if (/(\d+)\s+(.+)$/) { + my $pid = $1; + my ($id, $sl); + + if (defined($slice_id{$2})) { + $id = $slice_id{$2}; + $sl = $2; + } else { + $id = $2; + $sl = $slice{$2}; + } + print sprintf("%s %s %s\n", $id, $sl, $pid); + } +} +close THIS_PIPE;