Difference between revisions of "Processes scope and visibility"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(vzprocps description fixed, use template:forum for forum link)
Line 44: Line 44:
  
 
=== Use vzprocps tools ===
 
=== Use vzprocps tools ===
Take vzprocps tools from download.openvz.org/contrib/
+
Take <code>vzprocps</code> tools from http://download.openvz.org/contrib/utils/.
It is usual ps/top with -E option allowing to filter output.
+
These are usual <code>ps</code> and <code>top</code> utilities (named <code>vztop</code> and <code>vzps</code> to not conflict with the standard ones) with an <code>-E</code> option added. You can use <code>-E <i>VEID</i></code> option to limit the output to the selected VEID (use 0 for the host system), or just <code>-E</code> without an argument to just add VEID column to output.
If given w/o VE number, then it simply adds VEID column to its output.
 
  
 
== See also ==
 
== See also ==
* [http://forum.openvz.org/index.php?t=msg&th=836 forum thread #836]
+
* {Forum|836}
  
 
[[Category: HOWTO]]
 
[[Category: HOWTO]]

Revision as of 18:55, 20 July 2006

This HOWTO shows how OpenVZ hardware node administrator can see a processes belonging to the host system only, or to a particular VE.

Problem

From VE0 one can see all the processes running on the system; that includes all the processes of all VEs and the processes of the host system itself. Sometimes you just want to see the processes from the host system only. Sometimes you just want to see the processes from a particular VE.

There are many ways to achieve it.

Solutions

"Poor man's vzps in bash"

Use the following script by aistis, modified by kir.

First argument is VE ID (0 for the host system), all the remaining arguments are passed to ps(1) utility.

#!/bin/bash
# Usage: ./ovzps VEID [ps flags ...]

function find_ve_pids(){
       local pid
       local myveid=$1
       local vepids=

       for pid in $ALLPIDS; do
               [ -f /proc/$pid/status ] || continue
               veid=`grep envID /proc/$pid/status | awk -F: '{print $2}'`
               if [ ${veid} = ${myveid} ]; then
                       VEPIDS="$VEPIDS $pid"
               fi
       done
       echo "$vepids"
}

ALLPIDS=`ps -A -o pid --no-headers`
VEPIDS=`find_ve_pids $1`
shift

if [ "${VEPIDS}" ]; then
        ps $* -p "$VEPIDS"
else
        exit 0
fi

Use vzprocps tools

Take vzprocps tools from http://download.openvz.org/contrib/utils/. These are usual ps and top utilities (named vztop and vzps to not conflict with the standard ones) with an -E option added. You can use -E VEID option to limit the output to the selected VEID (use 0 for the host system), or just -E without an argument to just add VEID column to output.

See also

  • {Forum|836}