[Users] reliably detect wether hardware_node, openvz_host or openvz_instance

neerd daneerd at gmail.com
Tue Jul 29 05:13:23 EDT 2008


Hello,

Parsing the /proc/self/status does not work with 2.6.24-ovz005 kernel. In
fact the openvz_host still shows the "EnvID: 0" but there is no more "EnvID"
into the vz instances. I reported it as a bug here:
http://bugzilla.openvz.org/show_bug.cgi?id=936 but with no more informations
since.

I'm using the following code to see if I am in an openvz instance:
-----
tail -n 1 /proc/vz/veinfo | grep -qs '^[[:space:]]*[1-9]'
-----

I use it because openvz instances can not acces hardware where openvz hosts
and pure hardware nodes can.

Jerome


On Mon, Jul 28, 2008 at 5:50 PM, Stanichenko Marat <
mstanichenko at parallels.com> wrote:

> Hello,
>
> this is also not very complicated
>
> --------------
> cat /proc/self/status | awk '$1 == "envID:" {if ($2 != 0) {print("ve")}
> else {print("hn")}}'
> --------------
>
> Stanichenko Marat
>
> Martin пишет:
>
>> Hello,
>>
>> I'm looking for a way to reliably tell (thru shell) wether I'm on a
>> pure hardware_node, openvz_host or inside an instance. I'd like to not
>> rely on any tools from packages, I'd rather use information from /proc
>> or /sys.
>>
>> So far I came up with a very simple test, I'm pretty sure it's
>> somewhere in the manual but I'm just to blind to find that.
>>
>> --snip--
>> if [ -f /proc/user_beancounters ]; then
>>  grep -E '^[[:blank:]]+0:' /proc/user_beancounters 2>/dev/null;
>>  if [ $? -eq 0 ]; then
>>    echo "openvz_host";
>>  else
>>    echo "openvz_instance";
>>  fi;
>> else
>>  echo "hardware_node";
>> fi
>> --snap--
>>
>> thanks martin
>>
>>
> _______________________________________________
> Users mailing list
> Users at openvz.org
> https://openvz.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://openvz.org/pipermail/users/attachments/20080729/6fdd1c5e/attachment.html


More information about the Users mailing list