<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wese</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wese"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Wese"/>
	<updated>2026-05-15T20:51:01Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Wese&amp;diff=6346</id>
		<title>User:Wese</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Wese&amp;diff=6346"/>
		<updated>2008-08-19T10:05:37Z</updated>

		<summary type="html">&lt;p&gt;Wese: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
&lt;br /&gt;
* HostNode: Debian Etch, OpenVz Stable&lt;br /&gt;
* Munin-OpenVZ Plugin: [http://blog.dead.at/2007/11/munin-plugin-openvz.html here]&lt;br /&gt;
* Munin-OpenVZ Plugin V2: [http://blog.dead.at/2008/08/munin-plugin-openvz-v2 here]&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
* ICQ: 14393012&lt;br /&gt;
* Homepage: [http://www.dead.at here]&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Monitoring_openvz_resources_using_munin&amp;diff=6338</id>
		<title>Monitoring openvz resources using munin</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Monitoring_openvz_resources_using_munin&amp;diff=6338"/>
		<updated>2008-08-14T15:23:56Z</updated>

		<summary type="html">&lt;p&gt;Wese: Added usage example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Monitoring]]&lt;br /&gt;
&lt;br /&gt;
There are several plugins available on this page to monitor beancounter values in [http://munin.projects.linpro.no/ Munin].&lt;br /&gt;
The third one tries to combine the other two.&lt;br /&gt;
&lt;br /&gt;
= &amp;quot;Simple&amp;quot; munin plugin =&lt;br /&gt;
&lt;br /&gt;
The plugin listed below grabs all the beancounters' values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
&lt;br /&gt;
ATTR=`basename $0 | sed 's/^vebc_//g'`&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
                echo yes&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
            cat /proc/bc/0/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                echo ${vals[0]}&lt;br /&gt;
            done&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
#       echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_title $ATTR beancounter for containers&amp;quot;&lt;br /&gt;
        echo 'graph_category system'&lt;br /&gt;
        echo &amp;quot;graph_info 'Containers beancounters info'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
        for CTID in `ls -d1 /proc/bc/???`; do&lt;br /&gt;
            id=`basename $CTID`&lt;br /&gt;
            grep $ATTR $CTID/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                name=${vals[0]}&lt;br /&gt;
                echo ${id}.label $id&lt;br /&gt;
                echo &amp;quot;${id}.warning  ${vals[3]}&amp;quot;&lt;br /&gt;
                echo &amp;quot;${id}.critical  ${vals[4]}&amp;quot;&lt;br /&gt;
            done&lt;br /&gt;
        done&lt;br /&gt;
&lt;br /&gt;
        exit 0&lt;br /&gt;
fi;&lt;br /&gt;
&lt;br /&gt;
for CTID in `ls -d1 /proc/bc/???`; do&lt;br /&gt;
    id=`basename $CTID`&lt;br /&gt;
    grep $ATTR $CTID/resources |&lt;br /&gt;
    while read str; do&lt;br /&gt;
        vals=($str)&lt;br /&gt;
        name=${vals[0]}&lt;br /&gt;
        echo &amp;quot;$id.value ${vals[1]}&amp;quot;&lt;br /&gt;
    done&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Extended Version for old system using user_beancounter =&lt;br /&gt;
&lt;br /&gt;
Put it with the munin plugins and make a link for every&lt;br /&gt;
graph which should be produced named like:&lt;br /&gt;
&lt;br /&gt;
vebc_VALUENAME1_VALUENAME2_..._CTID&lt;br /&gt;
&lt;br /&gt;
e.g.: vebc_numflock_numpty_numsiginfo_101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
&lt;br /&gt;
ATTR=`basename $0 | sed -e 's/^vebc_.*_//'`&lt;br /&gt;
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
                echo yes&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
            cat /proc/bc/0/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                echo ${vals[0]}&lt;br /&gt;
            done&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
#       echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_title beancounter for CT$ATTR: $STATS&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_category CT$ATTR&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_info 'Container bean counters info'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
        readme=&amp;quot;false&amp;quot;&lt;br /&gt;
        cat /proc/user_beancounters | while read myid stuff; do&lt;br /&gt;
                line=&amp;quot;&amp;quot;&lt;br /&gt;
                if [ &amp;quot;$myid&amp;quot; == &amp;quot;$ATTR:&amp;quot; ]; then&lt;br /&gt;
                        readme=&amp;quot;true&amp;quot;&lt;br /&gt;
                        line=&amp;quot;$stuff&amp;quot;&lt;br /&gt;
                        echo $line&lt;br /&gt;
                else&lt;br /&gt;
                        loid=`echo $myid | sed -e 's/.*:/:/'`&lt;br /&gt;
                        if [ &amp;quot;$loid&amp;quot; == &amp;quot;:&amp;quot; ]; then&lt;br /&gt;
                                readme=&amp;quot;false&amp;quot;&lt;br /&gt;
                        fi&lt;br /&gt;
                        if [ &amp;quot;$readme&amp;quot; == &amp;quot;true&amp;quot; ]; then&lt;br /&gt;
                                line=&amp;quot;$myid $stuff&amp;quot;&lt;br /&gt;
                        echo $line&lt;br /&gt;
                        fi&lt;br /&gt;
                fi&lt;br /&gt;
        done | while read name value top warn max; do&lt;br /&gt;
                okname=&amp;quot;dummy&amp;quot;&lt;br /&gt;
                for statname in $STATS; do&lt;br /&gt;
                        if [ &amp;quot;$name&amp;quot; == &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
                                okname=$name&lt;br /&gt;
                        fi&lt;br /&gt;
                done&lt;br /&gt;
&lt;br /&gt;
                if [ &amp;quot;$okname&amp;quot; != &amp;quot;dummy&amp;quot; ]; then&lt;br /&gt;
                        echo $okname.label $name&lt;br /&gt;
                        echo $okname.warning $warn&lt;br /&gt;
                        echo $okname.critical $max&lt;br /&gt;
                fi&lt;br /&gt;
        done&lt;br /&gt;
        exit 0&lt;br /&gt;
fi;&lt;br /&gt;
&lt;br /&gt;
readme=&amp;quot;false&amp;quot;&lt;br /&gt;
cat /proc/user_beancounters | while read myid stuff; do&lt;br /&gt;
        line=&amp;quot;&amp;quot;&lt;br /&gt;
        if [ &amp;quot;$myid&amp;quot; == &amp;quot;$ATTR:&amp;quot; ]; then&lt;br /&gt;
                readme=&amp;quot;true&amp;quot;&lt;br /&gt;
                line=&amp;quot;$stuff&amp;quot;&lt;br /&gt;
                echo $line&lt;br /&gt;
        else&lt;br /&gt;
                loid=`echo $myid | sed -e 's/.*:/:/'`&lt;br /&gt;
                if [ &amp;quot;$loid&amp;quot; == &amp;quot;:&amp;quot; ]; then&lt;br /&gt;
                        readme=&amp;quot;false&amp;quot;&lt;br /&gt;
                fi&lt;br /&gt;
                if [ &amp;quot;$readme&amp;quot; == &amp;quot;true&amp;quot; ]; then&lt;br /&gt;
                        line=&amp;quot;$myid $stuff&amp;quot;&lt;br /&gt;
                echo $line&lt;br /&gt;
                fi&lt;br /&gt;
        fi&lt;br /&gt;
done | while read name value x; do&lt;br /&gt;
        okname=&amp;quot;dummy&amp;quot;&lt;br /&gt;
        for statname in $STATS; do&lt;br /&gt;
                if [ &amp;quot;$name&amp;quot; == &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
                        okname=$name&lt;br /&gt;
                fi&lt;br /&gt;
        done&lt;br /&gt;
        if [ &amp;quot;$okname&amp;quot; != &amp;quot;dummy&amp;quot; ]; then&lt;br /&gt;
                echo $okname.value $value&lt;br /&gt;
        fi&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not too performant but should do and the graphs are much&lt;br /&gt;
more readable then the first solution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Extended plugin from Jan Tomasek =&lt;br /&gt;
* Jan has posted another plugin on http://forum.openvz.org/index.php?t=msg&amp;amp;goto=15122, where I've fixed two things:&lt;br /&gt;
*# &amp;quot;exit 0&amp;quot; in the &amp;quot;config&amp;quot; block&lt;br /&gt;
*# Replaced &amp;quot;vals=($str); echo ${vals[0]}&amp;quot; with &amp;quot;echo ${str%% *}&amp;quot; (the former was causing problems I don't remember anymore)&lt;br /&gt;
* v1.3.2 (2008/08/09)&lt;br /&gt;
*# If only 1 variable is graphed, also display maxheld, barrier and limit&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# Munin's plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
# $Log$&lt;br /&gt;
# Revision 1.3 2007/07/19 12:57:00 Jan Tomasek &amp;lt;jan@tomasek.cz&amp;gt;&lt;br /&gt;
# * rewrited to work with /proc/bc/&amp;lt;VEID&amp;gt;/resources instead of&lt;br /&gt;
# /proc/user_beancounters, that simplified code and result&lt;br /&gt;
# is also bit faster.&lt;br /&gt;
# * added references to OpenVZ wiki&lt;br /&gt;
# Revision 1.3.1 2008/05/13 01:26:00 Daniel Hahler &amp;lt;http://daniel.hahler.de/&amp;gt;&lt;br /&gt;
# * Minor fixes&lt;br /&gt;
#   - &amp;quot;exit 0&amp;quot; in &amp;quot;config&amp;quot; block&lt;br /&gt;
#   - Use &amp;quot;echo ${str%% *}&amp;quot; in &amp;quot;suggest&amp;quot;, instead of &amp;quot;vals=($str); echo ${vals[0]}&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
# Revision 1.3.2 2008/08/09 12:30:00 Christian Rubbert &amp;lt;crubbert@xrc.de&amp;gt;&lt;br /&gt;
# * Feature&lt;br /&gt;
#   - If only 1 variable is graphed, also display maxheld, barrier and limit&lt;br /&gt;
#&lt;br /&gt;
# Original revision taken from:&lt;br /&gt;
# http://wiki.openvz.org/Monitoring_openvz_resources_using_munin&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
 &lt;br /&gt;
VEID=`basename $0 | sed -e 's/^vebc_.*_//'`;&lt;br /&gt;
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`&lt;br /&gt;
x=0; STATSCNT=`for i in $STATS; do x=$[$x+1]; done; echo $x`&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
    if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
        echo yes&lt;br /&gt;
        exit 0&lt;br /&gt;
    else&lt;br /&gt;
        echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    fi&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
    if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
        cat /proc/bc/0/resources | while read str; do&lt;br /&gt;
        # Print everything before &amp;quot; &amp;quot;&lt;br /&gt;
        echo ${str%% *}&lt;br /&gt;
        done&lt;br /&gt;
        exit 0&lt;br /&gt;
    else&lt;br /&gt;
        exit 1&lt;br /&gt;
    fi&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f /proc/bc/$VEID/resources ]; then&lt;br /&gt;
    exit 0;&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
    #echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_title VE$VEID: $STATS&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_vlabel bean counters&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_category VE$VEID&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # Note on URLs. General graph info is by munin version 1.2.5&lt;br /&gt;
    # accepted even with HTML code. But for value.info it escapes URL,&lt;br /&gt;
    # I expect that authors of munin will note that in future and put&lt;br /&gt;
    # escaping even for graph.info.&lt;br /&gt;
    echo &amp;quot;graph_info VE bean counters info. Documentation of the OpenVZ resource management is located at &amp;lt;a href=\&amp;quot;&lt;br /&gt;
http://wiki.openvz.org/UBC\&amp;quot;&amp;gt;http://wiki.openvz.org/UBC&amp;lt;/a&amp;gt;.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do&lt;br /&gt;
        for statname in $STATS; do&lt;br /&gt;
        if [ &amp;quot;$name&amp;quot; = &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
            URL=&amp;quot;http://wiki.openvz.org/$name&amp;quot;&lt;br /&gt;
            if [ &amp;quot;$warn&amp;quot; = &amp;quot;0&amp;quot; ]; then&lt;br /&gt;
                warn=$max&lt;br /&gt;
            fi&lt;br /&gt;
            echo $name.label $name&lt;br /&gt;
            echo $name.warning $warn&lt;br /&gt;
            echo $name.critical $max&lt;br /&gt;
            echo $name.info Description of this resource is located at $URL&lt;br /&gt;
        fi&lt;br /&gt;
        done&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
    if [ &amp;quot;$STATSCNT&amp;quot; == &amp;quot;1&amp;quot; ]; then&lt;br /&gt;
        echo maxheld.label Maxheld&lt;br /&gt;
        echo maxheld.draw LINE2&lt;br /&gt;
        echo maxheld.info Maximum value&lt;br /&gt;
        echo barrier.label Barrier&lt;br /&gt;
        echo barrier.draw LINE2&lt;br /&gt;
        echo barrier.info Barrier&lt;br /&gt;
        echo limit.label Limit&lt;br /&gt;
        echo limit.draw LINE2&lt;br /&gt;
        echo limit.info Limit&lt;br /&gt;
    fi&lt;br /&gt;
    exit 0&lt;br /&gt;
fi;&lt;br /&gt;
 &lt;br /&gt;
cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do&lt;br /&gt;
    for statname in $STATS; do&lt;br /&gt;
    if [ &amp;quot;$name&amp;quot; = &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
        echo $name&amp;quot;.value &amp;quot;$value;&lt;br /&gt;
&lt;br /&gt;
	if [ &amp;quot;$STATSCNT&amp;quot; == &amp;quot;1&amp;quot; ]; then&lt;br /&gt;
	    echo maxheld.value $top&lt;br /&gt;
	    echo barrier.value $warn&lt;br /&gt;
	    echo limit.value $max &lt;br /&gt;
	fi&lt;br /&gt;
    fi&lt;br /&gt;
    done&lt;br /&gt;
done&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Munin plugin setup =&lt;br /&gt;
== Run as root ==&lt;br /&gt;
Please note, you have to configure plugin to run as root. Therefore, add the following to /etc/munin/plugin-conf.d/ somewhere:&lt;br /&gt;
  [vebc*]&lt;br /&gt;
  user root&lt;br /&gt;
&lt;br /&gt;
== Installing the plugins ==&lt;br /&gt;
There's a single plugin file, which can be installed several times and can put several values into the same graph.&lt;br /&gt;
You should install the plugin from above to e.g. &amp;lt;code&amp;gt;/usr/local/share/munin/plugins/vebc_&amp;lt;/code&amp;gt; and then put symlinks to there from /etc/munin/plugins.&lt;br /&gt;
The following script allows you to handle this easily:&lt;br /&gt;
To install this, you can use the following script:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
FILE=`mktemp /tmp/ln-vebc-XXXXXX`&lt;br /&gt;
&lt;br /&gt;
cd /etc/munin/plugins&lt;br /&gt;
&lt;br /&gt;
for resources in kmemsize \&lt;br /&gt;
    lockedpages_privvmpages_shmpages_physpages_vmguarpages_oomguarpages \&lt;br /&gt;
    numproc \&lt;br /&gt;
    numtcpsock_numflock_numpty_numsiginfo_numothersock_numiptent \&lt;br /&gt;
    tcpsndbuf_tcprcvbuf_othersockbuf_dgramrcvbuf \&lt;br /&gt;
    dcachesize \&lt;br /&gt;
    numfile&lt;br /&gt;
do&lt;br /&gt;
    for VE in 0 `/usr/sbin/vzlist | sed &amp;quot;s/^ *//&amp;quot; |grep '^[0-9]' | cut -f 1 -d &amp;quot; &amp;quot;` ; do&lt;br /&gt;
        ln -sf /usr/local/share/munin/plugins/vebc_ &amp;quot;vebc_&amp;quot;$resources&amp;quot;_&amp;quot;$VE&lt;br /&gt;
        echo &amp;quot;vebc_&amp;quot;$resources&amp;quot;_&amp;quot;$VE &amp;gt;&amp;gt; $FILE&lt;br /&gt;
    done&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# remove no longer deserved links (ie. links pointing to machines&lt;br /&gt;
# which were destroyed or stoped)&lt;br /&gt;
&lt;br /&gt;
find -type l -name vebc_\* | sed &amp;quot;s/\.\///&amp;quot; | while read LN; do&lt;br /&gt;
    if grep ^$LN$ $FILE &amp;gt;/dev/null; then&lt;br /&gt;
        true&lt;br /&gt;
    else&lt;br /&gt;
        rm $LN&lt;br /&gt;
    fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
rm $FILE&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Alternative: Using vzlist =&lt;br /&gt;
This simple script will generate an overview of the requested stat from all VE's.&lt;br /&gt;
When using vzlist your saved from any changes to the beancounters.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
Simply append the variable you want to monitor:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;ln -s /usr/share/munin/plugins/openvz_ /etc/munin/plugins/openvz_physpages&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# Munin's plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
# $Log$&lt;br /&gt;
# 2008/08/14 Rene Weselowski &amp;lt;http://www.dead.at&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf&lt;br /&gt;
&lt;br /&gt;
ATTRIBUTE=`basename $0 | sed 's/^openvz_//g'`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        echo yes&lt;br /&gt;
        exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
        echo &amp;quot;graph_title $ATTRIBUTE&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_args --base 1000 -l 0&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_scale yes&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_vlabel $ATTRIBUTE Value&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_category openvz&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_info This graph shows OpenVZ: $ATTRIBUTE&amp;quot;&lt;br /&gt;
        vzlist -a -H -o hostname | awk '{gsub(/\./,&amp;quot;_&amp;quot;,$1)&lt;br /&gt;
        print(&amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.label &amp;quot;$1&amp;quot;\n&amp;quot; \&lt;br /&gt;
        &amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.info '$ATTRIBUTE' for VE&amp;quot;$1)}'&lt;br /&gt;
        exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
vzlist -a -H -o hostname,$ATTRIBUTE | awk '{gsub(/\./,&amp;quot;_&amp;quot;,$1)&lt;br /&gt;
         print(&amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.value &amp;quot;$2)}'&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Monitoring_openvz_resources_using_munin&amp;diff=6337</id>
		<title>Monitoring openvz resources using munin</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Monitoring_openvz_resources_using_munin&amp;diff=6337"/>
		<updated>2008-08-14T15:19:12Z</updated>

		<summary type="html">&lt;p&gt;Wese: Added script which parses vzlist&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category: Monitoring]]&lt;br /&gt;
&lt;br /&gt;
There are several plugins available on this page to monitor beancounter values in [http://munin.projects.linpro.no/ Munin].&lt;br /&gt;
The third one tries to combine the other two.&lt;br /&gt;
&lt;br /&gt;
= &amp;quot;Simple&amp;quot; munin plugin =&lt;br /&gt;
&lt;br /&gt;
The plugin listed below grabs all the beancounters' values.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
&lt;br /&gt;
ATTR=`basename $0 | sed 's/^vebc_//g'`&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
                echo yes&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
            cat /proc/bc/0/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                echo ${vals[0]}&lt;br /&gt;
            done&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
#       echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_title $ATTR beancounter for containers&amp;quot;&lt;br /&gt;
        echo 'graph_category system'&lt;br /&gt;
        echo &amp;quot;graph_info 'Containers beancounters info'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
        for CTID in `ls -d1 /proc/bc/???`; do&lt;br /&gt;
            id=`basename $CTID`&lt;br /&gt;
            grep $ATTR $CTID/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                name=${vals[0]}&lt;br /&gt;
                echo ${id}.label $id&lt;br /&gt;
                echo &amp;quot;${id}.warning  ${vals[3]}&amp;quot;&lt;br /&gt;
                echo &amp;quot;${id}.critical  ${vals[4]}&amp;quot;&lt;br /&gt;
            done&lt;br /&gt;
        done&lt;br /&gt;
&lt;br /&gt;
        exit 0&lt;br /&gt;
fi;&lt;br /&gt;
&lt;br /&gt;
for CTID in `ls -d1 /proc/bc/???`; do&lt;br /&gt;
    id=`basename $CTID`&lt;br /&gt;
    grep $ATTR $CTID/resources |&lt;br /&gt;
    while read str; do&lt;br /&gt;
        vals=($str)&lt;br /&gt;
        name=${vals[0]}&lt;br /&gt;
        echo &amp;quot;$id.value ${vals[1]}&amp;quot;&lt;br /&gt;
    done&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Extended Version for old system using user_beancounter =&lt;br /&gt;
&lt;br /&gt;
Put it with the munin plugins and make a link for every&lt;br /&gt;
graph which should be produced named like:&lt;br /&gt;
&lt;br /&gt;
vebc_VALUENAME1_VALUENAME2_..._CTID&lt;br /&gt;
&lt;br /&gt;
e.g.: vebc_numflock_numpty_numsiginfo_101&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
&lt;br /&gt;
ATTR=`basename $0 | sed -e 's/^vebc_.*_//'`&lt;br /&gt;
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
                echo yes&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
        if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
            cat /proc/bc/0/resources |&lt;br /&gt;
            while read str; do&lt;br /&gt;
                vals=($str)&lt;br /&gt;
                echo ${vals[0]}&lt;br /&gt;
            done&lt;br /&gt;
                exit 0&lt;br /&gt;
        else&lt;br /&gt;
                exit 1&lt;br /&gt;
        fi&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
#       echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_title beancounter for CT$ATTR: $STATS&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_category CT$ATTR&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_info 'Container bean counters info'&amp;quot;&lt;br /&gt;
&lt;br /&gt;
        readme=&amp;quot;false&amp;quot;&lt;br /&gt;
        cat /proc/user_beancounters | while read myid stuff; do&lt;br /&gt;
                line=&amp;quot;&amp;quot;&lt;br /&gt;
                if [ &amp;quot;$myid&amp;quot; == &amp;quot;$ATTR:&amp;quot; ]; then&lt;br /&gt;
                        readme=&amp;quot;true&amp;quot;&lt;br /&gt;
                        line=&amp;quot;$stuff&amp;quot;&lt;br /&gt;
                        echo $line&lt;br /&gt;
                else&lt;br /&gt;
                        loid=`echo $myid | sed -e 's/.*:/:/'`&lt;br /&gt;
                        if [ &amp;quot;$loid&amp;quot; == &amp;quot;:&amp;quot; ]; then&lt;br /&gt;
                                readme=&amp;quot;false&amp;quot;&lt;br /&gt;
                        fi&lt;br /&gt;
                        if [ &amp;quot;$readme&amp;quot; == &amp;quot;true&amp;quot; ]; then&lt;br /&gt;
                                line=&amp;quot;$myid $stuff&amp;quot;&lt;br /&gt;
                        echo $line&lt;br /&gt;
                        fi&lt;br /&gt;
                fi&lt;br /&gt;
        done | while read name value top warn max; do&lt;br /&gt;
                okname=&amp;quot;dummy&amp;quot;&lt;br /&gt;
                for statname in $STATS; do&lt;br /&gt;
                        if [ &amp;quot;$name&amp;quot; == &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
                                okname=$name&lt;br /&gt;
                        fi&lt;br /&gt;
                done&lt;br /&gt;
&lt;br /&gt;
                if [ &amp;quot;$okname&amp;quot; != &amp;quot;dummy&amp;quot; ]; then&lt;br /&gt;
                        echo $okname.label $name&lt;br /&gt;
                        echo $okname.warning $warn&lt;br /&gt;
                        echo $okname.critical $max&lt;br /&gt;
                fi&lt;br /&gt;
        done&lt;br /&gt;
        exit 0&lt;br /&gt;
fi;&lt;br /&gt;
&lt;br /&gt;
readme=&amp;quot;false&amp;quot;&lt;br /&gt;
cat /proc/user_beancounters | while read myid stuff; do&lt;br /&gt;
        line=&amp;quot;&amp;quot;&lt;br /&gt;
        if [ &amp;quot;$myid&amp;quot; == &amp;quot;$ATTR:&amp;quot; ]; then&lt;br /&gt;
                readme=&amp;quot;true&amp;quot;&lt;br /&gt;
                line=&amp;quot;$stuff&amp;quot;&lt;br /&gt;
                echo $line&lt;br /&gt;
        else&lt;br /&gt;
                loid=`echo $myid | sed -e 's/.*:/:/'`&lt;br /&gt;
                if [ &amp;quot;$loid&amp;quot; == &amp;quot;:&amp;quot; ]; then&lt;br /&gt;
                        readme=&amp;quot;false&amp;quot;&lt;br /&gt;
                fi&lt;br /&gt;
                if [ &amp;quot;$readme&amp;quot; == &amp;quot;true&amp;quot; ]; then&lt;br /&gt;
                        line=&amp;quot;$myid $stuff&amp;quot;&lt;br /&gt;
                echo $line&lt;br /&gt;
                fi&lt;br /&gt;
        fi&lt;br /&gt;
done | while read name value x; do&lt;br /&gt;
        okname=&amp;quot;dummy&amp;quot;&lt;br /&gt;
        for statname in $STATS; do&lt;br /&gt;
                if [ &amp;quot;$name&amp;quot; == &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
                        okname=$name&lt;br /&gt;
                fi&lt;br /&gt;
        done&lt;br /&gt;
        if [ &amp;quot;$okname&amp;quot; != &amp;quot;dummy&amp;quot; ]; then&lt;br /&gt;
                echo $okname.value $value&lt;br /&gt;
        fi&lt;br /&gt;
&lt;br /&gt;
done&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not too performant but should do and the graphs are much&lt;br /&gt;
more readable then the first solution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Extended plugin from Jan Tomasek =&lt;br /&gt;
* Jan has posted another plugin on http://forum.openvz.org/index.php?t=msg&amp;amp;goto=15122, where I've fixed two things:&lt;br /&gt;
*# &amp;quot;exit 0&amp;quot; in the &amp;quot;config&amp;quot; block&lt;br /&gt;
*# Replaced &amp;quot;vals=($str); echo ${vals[0]}&amp;quot; with &amp;quot;echo ${str%% *}&amp;quot; (the former was causing problems I don't remember anymore)&lt;br /&gt;
* v1.3.2 (2008/08/09)&lt;br /&gt;
*# If only 1 variable is graphed, also display maxheld, barrier and limit&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# Munin's plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
# $Log$&lt;br /&gt;
# Revision 1.3 2007/07/19 12:57:00 Jan Tomasek &amp;lt;jan@tomasek.cz&amp;gt;&lt;br /&gt;
# * rewrited to work with /proc/bc/&amp;lt;VEID&amp;gt;/resources instead of&lt;br /&gt;
# /proc/user_beancounters, that simplified code and result&lt;br /&gt;
# is also bit faster.&lt;br /&gt;
# * added references to OpenVZ wiki&lt;br /&gt;
# Revision 1.3.1 2008/05/13 01:26:00 Daniel Hahler &amp;lt;http://daniel.hahler.de/&amp;gt;&lt;br /&gt;
# * Minor fixes&lt;br /&gt;
#   - &amp;quot;exit 0&amp;quot; in &amp;quot;config&amp;quot; block&lt;br /&gt;
#   - Use &amp;quot;echo ${str%% *}&amp;quot; in &amp;quot;suggest&amp;quot;, instead of &amp;quot;vals=($str); echo ${vals[0]}&amp;quot;&lt;br /&gt;
#&lt;br /&gt;
# Revision 1.3.2 2008/08/09 12:30:00 Christian Rubbert &amp;lt;crubbert@xrc.de&amp;gt;&lt;br /&gt;
# * Feature&lt;br /&gt;
#   - If only 1 variable is graphed, also display maxheld, barrier and limit&lt;br /&gt;
#&lt;br /&gt;
# Original revision taken from:&lt;br /&gt;
# http://wiki.openvz.org/Monitoring_openvz_resources_using_munin&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf suggest&lt;br /&gt;
 &lt;br /&gt;
VEID=`basename $0 | sed -e 's/^vebc_.*_//'`;&lt;br /&gt;
STATS=`basename $0 | sed -e 's/^vebc_//' -e 's/_[0-9]*$//' -e 's/_/ /g'`&lt;br /&gt;
x=0; STATSCNT=`for i in $STATS; do x=$[$x+1]; done; echo $x`&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
    if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
        echo yes&lt;br /&gt;
        exit 0&lt;br /&gt;
    else&lt;br /&gt;
        echo &amp;quot;no (/proc/bc/0/resources not found)&amp;quot;&lt;br /&gt;
        exit 1&lt;br /&gt;
    fi&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;suggest&amp;quot; ]; then&lt;br /&gt;
    if [ -r /proc/bc/0/resources ]; then&lt;br /&gt;
        cat /proc/bc/0/resources | while read str; do&lt;br /&gt;
        # Print everything before &amp;quot; &amp;quot;&lt;br /&gt;
        echo ${str%% *}&lt;br /&gt;
        done&lt;br /&gt;
        exit 0&lt;br /&gt;
    else&lt;br /&gt;
        exit 1&lt;br /&gt;
    fi&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ ! -f /proc/bc/$VEID/resources ]; then&lt;br /&gt;
    exit 0;&lt;br /&gt;
fi&lt;br /&gt;
 &lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
    #echo &amp;quot;graph_order down up&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_title VE$VEID: $STATS&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_vlabel bean counters&amp;quot;&lt;br /&gt;
    echo &amp;quot;graph_category VE$VEID&amp;quot;&lt;br /&gt;
&lt;br /&gt;
    # Note on URLs. General graph info is by munin version 1.2.5&lt;br /&gt;
    # accepted even with HTML code. But for value.info it escapes URL,&lt;br /&gt;
    # I expect that authors of munin will note that in future and put&lt;br /&gt;
    # escaping even for graph.info.&lt;br /&gt;
    echo &amp;quot;graph_info VE bean counters info. Documentation of the OpenVZ resource management is located at &amp;lt;a href=\&amp;quot;&lt;br /&gt;
http://wiki.openvz.org/UBC\&amp;quot;&amp;gt;http://wiki.openvz.org/UBC&amp;lt;/a&amp;gt;.&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
    cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do&lt;br /&gt;
        for statname in $STATS; do&lt;br /&gt;
        if [ &amp;quot;$name&amp;quot; = &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
            URL=&amp;quot;http://wiki.openvz.org/$name&amp;quot;&lt;br /&gt;
            if [ &amp;quot;$warn&amp;quot; = &amp;quot;0&amp;quot; ]; then&lt;br /&gt;
                warn=$max&lt;br /&gt;
            fi&lt;br /&gt;
            echo $name.label $name&lt;br /&gt;
            echo $name.warning $warn&lt;br /&gt;
            echo $name.critical $max&lt;br /&gt;
            echo $name.info Description of this resource is located at $URL&lt;br /&gt;
        fi&lt;br /&gt;
        done&lt;br /&gt;
    done&lt;br /&gt;
&lt;br /&gt;
    if [ &amp;quot;$STATSCNT&amp;quot; == &amp;quot;1&amp;quot; ]; then&lt;br /&gt;
        echo maxheld.label Maxheld&lt;br /&gt;
        echo maxheld.draw LINE2&lt;br /&gt;
        echo maxheld.info Maximum value&lt;br /&gt;
        echo barrier.label Barrier&lt;br /&gt;
        echo barrier.draw LINE2&lt;br /&gt;
        echo barrier.info Barrier&lt;br /&gt;
        echo limit.label Limit&lt;br /&gt;
        echo limit.draw LINE2&lt;br /&gt;
        echo limit.info Limit&lt;br /&gt;
    fi&lt;br /&gt;
    exit 0&lt;br /&gt;
fi;&lt;br /&gt;
 &lt;br /&gt;
cat /proc/bc/$VEID/resources | while read name value top warn max stuff ; do&lt;br /&gt;
    for statname in $STATS; do&lt;br /&gt;
    if [ &amp;quot;$name&amp;quot; = &amp;quot;$statname&amp;quot; ]; then&lt;br /&gt;
        echo $name&amp;quot;.value &amp;quot;$value;&lt;br /&gt;
&lt;br /&gt;
	if [ &amp;quot;$STATSCNT&amp;quot; == &amp;quot;1&amp;quot; ]; then&lt;br /&gt;
	    echo maxheld.value $top&lt;br /&gt;
	    echo barrier.value $warn&lt;br /&gt;
	    echo limit.value $max &lt;br /&gt;
	fi&lt;br /&gt;
    fi&lt;br /&gt;
    done&lt;br /&gt;
done&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Munin plugin setup =&lt;br /&gt;
== Run as root ==&lt;br /&gt;
Please note, you have to configure plugin to run as root. Therefore, add the following to /etc/munin/plugin-conf.d/ somewhere:&lt;br /&gt;
  [vebc*]&lt;br /&gt;
  user root&lt;br /&gt;
&lt;br /&gt;
== Installing the plugins ==&lt;br /&gt;
There's a single plugin file, which can be installed several times and can put several values into the same graph.&lt;br /&gt;
You should install the plugin from above to e.g. &amp;lt;code&amp;gt;/usr/local/share/munin/plugins/vebc_&amp;lt;/code&amp;gt; and then put symlinks to there from /etc/munin/plugins.&lt;br /&gt;
The following script allows you to handle this easily:&lt;br /&gt;
To install this, you can use the following script:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
&lt;br /&gt;
FILE=`mktemp /tmp/ln-vebc-XXXXXX`&lt;br /&gt;
&lt;br /&gt;
cd /etc/munin/plugins&lt;br /&gt;
&lt;br /&gt;
for resources in kmemsize \&lt;br /&gt;
    lockedpages_privvmpages_shmpages_physpages_vmguarpages_oomguarpages \&lt;br /&gt;
    numproc \&lt;br /&gt;
    numtcpsock_numflock_numpty_numsiginfo_numothersock_numiptent \&lt;br /&gt;
    tcpsndbuf_tcprcvbuf_othersockbuf_dgramrcvbuf \&lt;br /&gt;
    dcachesize \&lt;br /&gt;
    numfile&lt;br /&gt;
do&lt;br /&gt;
    for VE in 0 `/usr/sbin/vzlist | sed &amp;quot;s/^ *//&amp;quot; |grep '^[0-9]' | cut -f 1 -d &amp;quot; &amp;quot;` ; do&lt;br /&gt;
        ln -sf /usr/local/share/munin/plugins/vebc_ &amp;quot;vebc_&amp;quot;$resources&amp;quot;_&amp;quot;$VE&lt;br /&gt;
        echo &amp;quot;vebc_&amp;quot;$resources&amp;quot;_&amp;quot;$VE &amp;gt;&amp;gt; $FILE&lt;br /&gt;
    done&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
# remove no longer deserved links (ie. links pointing to machines&lt;br /&gt;
# which were destroyed or stoped)&lt;br /&gt;
&lt;br /&gt;
find -type l -name vebc_\* | sed &amp;quot;s/\.\///&amp;quot; | while read LN; do&lt;br /&gt;
    if grep ^$LN$ $FILE &amp;gt;/dev/null; then&lt;br /&gt;
        true&lt;br /&gt;
    else&lt;br /&gt;
        rm $LN&lt;br /&gt;
    fi&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
rm $FILE&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Alternative: Using vzlist =&lt;br /&gt;
This simple script will generate an overview of the requested stat from all VE's.&lt;br /&gt;
When using vzlist your saved from any changes to the beancounters.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
#&lt;br /&gt;
# Munin's plugin to monitor OpenVZ bean counters.&lt;br /&gt;
#&lt;br /&gt;
# $Log$&lt;br /&gt;
#&lt;br /&gt;
# 2008/08/14 Rene Weselowski &amp;lt;http://www.dead.at&amp;gt;&lt;br /&gt;
#&lt;br /&gt;
#&lt;br /&gt;
#%# family=auto&lt;br /&gt;
#%# capabilities=autoconf&lt;br /&gt;
&lt;br /&gt;
ATTRIBUTE=`basename $0 | sed 's/^openvz_//g'`&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;autoconf&amp;quot; ]; then&lt;br /&gt;
        echo yes&lt;br /&gt;
        exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
if [ &amp;quot;$1&amp;quot; = &amp;quot;config&amp;quot; ]; then&lt;br /&gt;
        echo &amp;quot;graph_title $ATTRIBUTE&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_args --base 1000 -l 0&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_scale yes&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_vlabel $ATTRIBUTE Value&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_category openvz&amp;quot;&lt;br /&gt;
        echo &amp;quot;graph_info This graph shows OpenVZ: $ATTRIBUTE&amp;quot;&lt;br /&gt;
        vzlist -a -H -o hostname | awk '{gsub(/\./,&amp;quot;_&amp;quot;,$1)&lt;br /&gt;
        print(&amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.label &amp;quot;$1&amp;quot;\n&amp;quot; \&lt;br /&gt;
        &amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.info '$ATTRIBUTE' for VE&amp;quot;$1)}'&lt;br /&gt;
        exit 0&lt;br /&gt;
fi&lt;br /&gt;
&lt;br /&gt;
vzlist -a -H -o hostname,$ATTRIBUTE | awk '{gsub(/\./,&amp;quot;_&amp;quot;,$1)&lt;br /&gt;
         print(&amp;quot;'$ATTRIBUTE'&amp;quot;$1&amp;quot;.value &amp;quot;$2)}'&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=User:Wese&amp;diff=3773</id>
		<title>User:Wese</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=User:Wese&amp;diff=3773"/>
		<updated>2007-12-17T07:50:49Z</updated>

		<summary type="html">&lt;p&gt;Wese: New page: == About ==  * HostNode: Debian Etch, OpenVz Stable * Munin-OpenVZ Plugin: [http://blog.dead.at/2007/11/munin-plugin-openvz.html here]  == Contact ==  * ICQ: 14393012 * Homepage: [http://w...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== About ==&lt;br /&gt;
&lt;br /&gt;
* HostNode: Debian Etch, OpenVz Stable&lt;br /&gt;
* Munin-OpenVZ Plugin: [http://blog.dead.at/2007/11/munin-plugin-openvz.html here]&lt;br /&gt;
&lt;br /&gt;
== Contact ==&lt;br /&gt;
&lt;br /&gt;
* ICQ: 14393012&lt;br /&gt;
* Homepage: [http://www.dead.at here]&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Physical_to_container&amp;diff=3772</id>
		<title>Talk:Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Physical_to_container&amp;diff=3772"/>
		<updated>2007-12-17T07:44:16Z</updated>

		<summary type="html">&lt;p&gt;Wese: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== RSync Command ==&lt;br /&gt;
Please check the following command,  Ive used with success:&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp --exclude mnt --exclude sys -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
== Migration Script ==&lt;br /&gt;
&lt;br /&gt;
I composed a little Script to migrate a Debian Sarge Box to OpenVZ. (Some System specific steps have been removed)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#!/bin/sh&lt;br /&gt;
echo &amp;quot;Stopping VE 300...&amp;quot;&lt;br /&gt;
vzctl stop 300&lt;br /&gt;
echo &amp;quot;Creating base filesystem /dev /proc ...&amp;quot;&lt;br /&gt;
mknod /vz/private/300/dev/ptmx c 5 2&lt;br /&gt;
mkdir /vz/private/300/dev/pts&lt;br /&gt;
rm -f /vz/private/300/dev/null&lt;br /&gt;
mknod /vz/private/300/dev/null c 1 3&lt;br /&gt;
chmod o+rw /vz/private/300/dev/null&lt;br /&gt;
echo &amp;quot;Copy the tty's to VE and Set Permissions&amp;quot;&lt;br /&gt;
cp -r /dev/ttyp* /dev/ptyp* /vz/private/300/dev/&lt;br /&gt;
chmod o+wx /vz/private/300/dev/*typ*&lt;br /&gt;
echo &amp;quot;Creating /dev/random and Set Permissions&amp;quot;&lt;br /&gt;
mknod -m 644 /vz/private/300/dev/random c 1 8&lt;br /&gt;
mknod -m 644 /vz/private/300/dev/urandom c 1 9&lt;br /&gt;
chown root:root /vz/private/300/dev/random /vz/private/300/dev/urandom&lt;br /&gt;
echo &amp;quot;clearing mtab / fstab...&amp;quot;&lt;br /&gt;
echo -n &amp;gt; /vz/private/300/etc/fstab&lt;br /&gt;
rm /vz/private/300/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/300/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Physical_to_container&amp;diff=3771</id>
		<title>Talk:Physical to container</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Physical_to_container&amp;diff=3771"/>
		<updated>2007-12-17T07:43:09Z</updated>

		<summary type="html">&lt;p&gt;Wese: Migration Script&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Please check the following command,  Ive used with success:&lt;br /&gt;
 rsync -arvpz --numeric-ids --exclude dev --exclude proc --exclude tmp --exclude mnt --exclude sys -e &amp;quot;ssh -l root@a.b.c.d&amp;quot; root@a.b.c.d:/ /vz/private/123/&lt;br /&gt;
&lt;br /&gt;
== Migration Script ==&lt;br /&gt;
&lt;br /&gt;
I composed a little Script to migrate a Debian Sarge Box to OpenVZ. (Some System specific steps have been removed)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;#!/bin/sh&lt;br /&gt;
echo &amp;quot;Stopping VE 300...&amp;quot;&lt;br /&gt;
vzctl stop 300&lt;br /&gt;
echo &amp;quot;Creating base filesystem /dev /proc ...&amp;quot;&lt;br /&gt;
mknod /vz/private/300/dev/ptmx c 5 2&lt;br /&gt;
mkdir /vz/private/300/dev/pts&lt;br /&gt;
rm -f /vz/private/300/dev/null&lt;br /&gt;
mknod /vz/private/300/dev/null c 1 3&lt;br /&gt;
chmod o+rw /vz/private/300/dev/null&lt;br /&gt;
echo &amp;quot;Copy the tty's to VE and Set Permissions&amp;quot;&lt;br /&gt;
cp -r /dev/ttyp* /dev/ptyp* /vz/private/300/dev/&lt;br /&gt;
chmod o+wx /vz/private/300/dev/*typ*&lt;br /&gt;
echo &amp;quot;Creating /dev/random and Set Permissions&amp;quot;&lt;br /&gt;
mknod -m 644 /vz/private/300/dev/random c 1 8&lt;br /&gt;
mknod -m 644 /vz/private/300/dev/urandom c 1 9&lt;br /&gt;
chown root:root /vz/private/300/dev/random /vz/private/300/dev/urandom&lt;br /&gt;
echo &amp;quot;clearing mtab / fstab...&amp;quot;&lt;br /&gt;
echo -n &amp;gt; /vz/private/300/etc/fstab&lt;br /&gt;
rm /vz/private/300/etc/mtab&lt;br /&gt;
ln -s /proc/mounts /vz/private/300/etc/mtab&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=3013</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=3013"/>
		<updated>2007-04-14T21:14:16Z</updated>

		<summary type="html">&lt;p&gt;Wese: Sidenote on MySQL socket sharing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{roughstub}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The problem ==&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python, or Perl are too powerful. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl, or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
You can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you probably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselves victims of a compromised host. Learning the hard way is by far the most effective method. One possible solution is dedicated webhosting, but most users don't have the experience to maintain a server or it is way to expensive for them.&lt;br /&gt;
&lt;br /&gt;
The main problem with shared webhosting is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read all files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely separate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unnecessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
==== MySQL socket sharing ====&lt;br /&gt;
&lt;br /&gt;
You can also share the socket of an VEx running MySQL, which is alot faster than TCP/IP.&lt;br /&gt;
e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ln /var/lib/vz/private/101/var/run/mysqld/mysqld.sock /var/lib/vz/private/102/var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Inside of 102:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mysql -u root -p -S /var/run/mysqld/mysqld.sock&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 9 to server version: 5.0.32-Debian_7etch1-log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
For apache add a VirtualHost directive&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;VirtualHost external-IP-address:80&amp;gt;&lt;br /&gt;
        ServerName mydomainnameishere.com&lt;br /&gt;
        RewriteEngine     On&lt;br /&gt;
        RewriteRule       ^(.*)$        http://192.168.2.101$1  [P]&lt;br /&gt;
        RewriteRule       ^(.*)$        http://mydomainnameishere.com$1   [P]&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;VirtualHost external-IP-address:80&amp;gt;&lt;br /&gt;
        ServerName mydomainnameishere.com&lt;br /&gt;
        RewriteEngine     On&lt;br /&gt;
        RewriteRule       ^(.*)$        http://192.168.2.101$1  [P]&lt;br /&gt;
        RewriteRule       ^(.*)$        http://www.mydomainnameishere.com$1   [P]&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting server is shown in the figure above.&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=3012</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=3012"/>
		<updated>2007-04-14T21:11:22Z</updated>

		<summary type="html">&lt;p&gt;Wese: MySQL Sharing via Socket&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{roughstub}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The problem ==&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python, or Perl are too powerful. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl, or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
You can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you probably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselves victims of a compromised host. Learning the hard way is by far the most effective method. One possible solution is dedicated webhosting, but most users don't have the experience to maintain a server or it is way to expensive for them.&lt;br /&gt;
&lt;br /&gt;
The main problem with shared webhosting is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read all files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely separate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unnecessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
==== MySQL socket sharing ====&lt;br /&gt;
&lt;br /&gt;
You can also share the socket of an VEx running MySQL.&lt;br /&gt;
e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ln /var/lib/vz/private/101/var/run/mysqld/mysqld.sock /var/lib/vz/private/102/var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Inside of 102:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mysql -u root -p -S /var/run/mysqld/mysqld.sock&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 9 to server version: 5.0.32-Debian_7etch1-log&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
For apache add a VirtualHost directive&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;VirtualHost external-IP-address:80&amp;gt;&lt;br /&gt;
        ServerName mydomainnameishere.com&lt;br /&gt;
        RewriteEngine     On&lt;br /&gt;
        RewriteRule       ^(.*)$        http://192.168.2.101$1  [P]&lt;br /&gt;
        RewriteRule       ^(.*)$        http://mydomainnameishere.com$1   [P]&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;VirtualHost external-IP-address:80&amp;gt;&lt;br /&gt;
        ServerName mydomainnameishere.com&lt;br /&gt;
        RewriteEngine     On&lt;br /&gt;
        RewriteRule       ^(.*)$        http://192.168.2.101$1  [P]&lt;br /&gt;
        RewriteRule       ^(.*)$        http://www.mydomainnameishere.com$1   [P]&lt;br /&gt;
&amp;lt;/VirtualHost&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting server is shown in the figure above.&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=3011</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=3011"/>
		<updated>2007-04-14T21:06:54Z</updated>

		<summary type="html">&lt;p&gt;Wese: MySQL Socket Sharing&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
: Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-) --[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
:: May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
:: If I had to do my research again, I think I would still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will draw more people to this site. I think of it as &amp;quot;user seperation&amp;quot;, but that is the whole point of OpenVZ? As said, its your Wiki, so change it if you think it is better :-) --[[User:Hvdkamer|Hvdkamer]] 10:40, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
::: I changed the introduction to give some examples of the problems shared webhosting is facing. I think that you now could see were it is going? I'm still in the process of setting up this server. So I thought to start this page while I'm working on it. Because if you do it weeks later, most subtle points are lost :-) --[[User:Hvdkamer|Hvdkamer]] 11:42, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Proxying ==&lt;br /&gt;
&lt;br /&gt;
I would suggest using [http://www.apsis.ch/pound/ Pound] as the Proxy Server running on your Frontend VE. Its a pretty lightweight and _fast_ Proxy. Besides proxying it does also support load balancing, failover and SSL.  I've been using it for various projects over the past few years, its proven to be pretty stable and reliable. --[[User:Torsten|Torsten]] 14:51, 9th Nov 2006 (CST)&lt;br /&gt;
&lt;br /&gt;
== MySQL Socket Sharing ==&lt;br /&gt;
&lt;br /&gt;
I found it was a good idea sharing the MySQL Socket instead of using TCP/IP. (which is also &amp;lt;b&amp;gt;ALOT&amp;lt;/b&amp;gt; faster)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# 101 is the MySQL Server VEx (debian 4.0)&lt;br /&gt;
# 102 Another VEx (opensuse 10.0)&lt;br /&gt;
ln /var/lib/vz/private/101/var/run/mysqld/mysqld.sock /var/lib/vz/private/102/var/run/mysqld/mysqld.sock&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The result&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
opensuse:/ # mysql -u root -p -S /var/run/mysqld/mysqld.sock&lt;br /&gt;
Enter password:&lt;br /&gt;
Welcome to the MySQL monitor.  Commands end with ; or \g.&lt;br /&gt;
Your MySQL connection id is 9 to server version: 5.0.32-Debian_7etch1-log&lt;br /&gt;
&lt;br /&gt;
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Wese</name></author>
		
	</entry>
</feed>