Editing Processes scope and visibility
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.
The edit can be undone.
Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | This [[:Category:HOWTO|HOWTO]] shows how OpenVZ [[hardware node]] | + | This [[:Category:HOWTO|HOWTO]] shows how OpenVZ [[hardware node]] administrator can see a processes belonging to the host system only, or to a particular [[VE]]. |
− | administrator can see a processes belonging to the host system only, or to a | ||
− | particular [[ | ||
== Problem == | == Problem == | ||
− | From [[ | + | From [[VE0]] one can see all the processes running on the system; that includes all the processes of all [[VE]]s 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. |
− | includes all the processes of all [[ | ||
− | [[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 | ||
There are many ways to achieve it. | There are many ways to achieve it. | ||
== Solutions == | == Solutions == | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== "Poor man's vzps in bash" === | === "Poor man's vzps in bash" === | ||
Line 40: | Line 17: | ||
# Usage: ./ovzps CTID [ps flags ...] | # Usage: ./ovzps CTID [ps flags ...] | ||
− | function | + | function find_ve_pids(){ |
local pid | local pid | ||
− | local | + | local myveid=$1 |
− | local | + | local vepids= |
for pid in $ALLPIDS; do | for pid in $ALLPIDS; do | ||
[ -f /proc/$pid/status ] || continue | [ -f /proc/$pid/status ] || continue | ||
− | + | veid=`grep envID /proc/$pid/status | awk -F: '{print $2}'` | |
− | if [ ${ | + | if [ ${veid} = ${myveid} ]; then |
− | + | vepids="$vepids $pid" | |
fi | fi | ||
done | done | ||
− | echo "$ | + | echo "$vepids" |
} | } | ||
ALLPIDS=`ps -A -o pid --no-headers` | ALLPIDS=`ps -A -o pid --no-headers` | ||
− | + | VEPIDS=`find_ve_pids $1` | |
shift | shift | ||
− | if [ -n "${ | + | if [ -n "${VEPIDS}" ]; then |
− | ps $* -p $ | + | ps $* -p $VEPIDS |
else | else | ||
exit 0 | exit 0 | ||
fi | fi | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</pre> | </pre> | ||
Line 82: | Line 46: | ||
Take <code>vzprocps</code> tools from http://download.openvz.org/contrib/utils/. | Take <code>vzprocps</code> tools from http://download.openvz.org/contrib/utils/. | ||
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>CTID</i></code> option to limit the output to the selected CTID (use 0 for the host system), or just <code>-E</code> without an argument to just add CTID column to 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>CTID</i></code> option to limit the output to the selected CTID (use 0 for the host system), or just <code>-E</code> without an argument to just add CTID column to output. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
== See also == | == See also == |