OpenVZ Forum


Home » General » Support » *SOLVED* see processes belonging to the Host system
*SOLVED* see processes belonging to the Host system [message #4513] Wed, 12 July 2006 17:50 Go to next message
hello-world is currently offline  hello-world
Messages: 30
Registered: June 2006
Member

Hi,

Is there a straightforward way to see the process belonging only to the host system? Curently on teh host, a simple ps will show all teh processes.

thanks.

[Updated on: Tue, 18 July 2006 06:06] by Moderator

Report message to a moderator

Re: see processes belonging to the Host system [message #4544 is a reply to message #4513] Fri, 14 July 2006 08:10 Go to previous messageGo to next message
msokolov is currently offline  msokolov
Messages: 8
Registered: July 2006
Junior Member
you can use something like:

#!/usr/bin/perl

use strict;

my @pss=`ps ax`;
foreach my $elem (@pss){

        my $ps0=$elem;
        $elem=~s/^[\s]*([0-9]+)[\s]+.*$//;
        my $pidn=($1);

        my $pid0=`vzpid $pidn|tail -1`;
        $pid0=~s/\s+(\d+)//;
        my $pid1=($1);

                if ($pid1==0) {
                        print "$ps0";

                }
}
Re: see processes belonging to the Host system [message #4548 is a reply to message #4544] Fri, 14 July 2006 09:54 Go to previous messageGo to next message
aistis is currently offline  aistis
Messages: 77
Registered: September 2005
Location: Kaunas, Lithuania
Member

here's a "poor mans vzps" in bash:

#!/bin/bash

PIDLIST=(`ps ax | grep -v PID | awk '{print $1}'`)

findpids(){
veidesired=$1
pidlist=

for i in `seq 0 ${#PIDLIST[*]}`; do
        pid=${PIDLIST[$i]}
        [ -f /proc/$pid/status ] || return
        veid=`grep envID /proc/$pid/status | awk -F: '{print $2}'`
        if [ ${veid} = ${veidesired} ]; then
                pidlist=$(echo $pidlist $pid) 
        fi
done
}

findpids $2
if [ "${pidlist}" ]; then
        ps $1 -p "$pidlist"
fi

exit 0


takes 'ps' arguments and VE ID as a second one, example:

./ovzps fvw 10000
Razz


Aistis Zenkevicius
http://static.openvz.org/userbars/openvz-user.png
Re: see processes belonging to the Host system [message #4576 is a reply to message #4548] Sat, 15 July 2006 03:07 Go to previous messageGo to next message
hello-world is currently offline  hello-world
Messages: 30
Registered: June 2006
Member


Hey thanks. i wanted a 'straightforward way'.

anyway, here's what i did, u can't see details, but it is the simplest. Smile

vpsid /proc/[0-9]* | grep '\t0\t'


Thanks.
Re: see processes belonging to the Host system [message #4585 is a reply to message #4576] Sat, 15 July 2006 11:08 Go to previous messageGo to next message
dev is currently offline  dev
Messages: 1693
Registered: September 2005
Location: Moscow
Senior Member

take vzprocps tools from download.openvz.org/contrib Smile
it is usual ps/top with -E option allowing to filter output.
if given w/o VE number, then it simply adds VEID column to its output


http://static.openvz.org/userbars/openvz-developer.png
Re: see processes belonging to the Host system [message #4601 is a reply to message #4585] Mon, 17 July 2006 10:04 Go to previous message
hello-world is currently offline  hello-world
Messages: 30
Registered: June 2006
Member


THat's what i was looking for. Thanks.
Previous Topic: *HARDWARE* Node crashed with Machine Check Exception error
Next Topic: Gentoo Kernel Problems (2.6.8-openvz-022.077) Panics Immediately - "kernel too old"
Goto Forum:
  


Current Time: Thu Mar 28 20:33:02 GMT 2024

Total time taken to generate the page: 0.01772 seconds