Remove lxc-version, lxc-ps and lxc-netstat

lxc-ps and lxc-netstat have an unfortunate tendency to break every so
often, produce mostly unreadable output and should be replaced by a
lxc-attach call in 99% of the cases.

In an effort to cleanup the lxc-* namespace, I think those two should
go, so this patch gets rid of them as well as any reference to them in
our documentation.

I also think that lxc-version should disappear as it's only a one line
shell script printing the version string, so having a whole command just
for that seems to be a bit of a waste.

Instead, this patch introduces a new --version common option which all
binaries will automatically inherit and that'll print LXC_VERSION on
stdout and exit 0.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
This commit is contained in:
Stéphane Graber 2014-01-21 12:16:04 -05:00
parent 0306de4f28
commit 7f12cae956
20 changed files with 11 additions and 1383 deletions

3
.gitignore vendored
View File

@ -60,8 +60,6 @@ src/lxc/lxc-info
src/lxc/lxc-init
src/lxc/lxc-monitor
src/lxc/lxc-monitord
src/lxc/lxc-netstat
src/lxc/lxc-ps
src/lxc/lxc-shutdown
src/lxc/lxc-snapshot
src/lxc/lxc-start
@ -70,7 +68,6 @@ src/lxc/lxc-stop
src/lxc/lxc-unfreeze
src/lxc/lxc-unshare
src/lxc/lxc-usernsexec
src/lxc/lxc-version
src/lxc/lxc-wait
src/lxc/legacy/lxc-ls
src/lxc/lxc-user-nic

View File

@ -596,8 +596,6 @@ AC_CONFIG_FILES([
doc/lxc-info.sgml
doc/lxc-ls.sgml
doc/lxc-monitor.sgml
doc/lxc-netstat.sgml
doc/lxc-ps.sgml
doc/lxc-snapshot.sgml
doc/lxc-start-ephemeral.sgml
doc/lxc-start.sgml
@ -607,7 +605,6 @@ AC_CONFIG_FILES([
doc/lxc-unshare.sgml
doc/lxc-user-nic.sgml
doc/lxc-usernsexec.sgml
doc/lxc-version.sgml
doc/lxc-wait.sgml
doc/lxc.conf.sgml
@ -643,8 +640,6 @@ AC_CONFIG_FILES([
doc/ja/lxc-info.sgml
doc/ja/lxc-ls.sgml
doc/ja/lxc-monitor.sgml
doc/ja/lxc-netstat.sgml
doc/ja/lxc-ps.sgml
doc/ja/lxc-snapshot.sgml
doc/ja/lxc-start-ephemeral.sgml
doc/ja/lxc-start.sgml
@ -654,7 +649,6 @@ AC_CONFIG_FILES([
doc/ja/lxc-unshare.sgml
doc/ja/lxc-user-nic.sgml
doc/ja/lxc-usernsexec.sgml
doc/ja/lxc-version.sgml
doc/ja/lxc-wait.sgml
doc/ja/lxc.conf.sgml
@ -686,10 +680,7 @@ AC_CONFIG_FILES([
src/Makefile
src/lxc/Makefile
src/lxc/lxc-ps
src/lxc/lxc-netstat
src/lxc/lxc-checkconfig
src/lxc/lxc-version
src/lxc/lxc-start-ephemeral
src/lxc/legacy/lxc-ls
src/lxc/lxc.functions

View File

@ -27,8 +27,6 @@ man_MANS = \
lxc-freeze.1 \
lxc-info.1 \
lxc-monitor.1 \
lxc-netstat.1 \
lxc-ps.1 \
lxc-snapshot.1 \
lxc-start.1 \
lxc-stop.1 \
@ -36,7 +34,6 @@ man_MANS = \
lxc-unshare.1 \
lxc-user-nic.1 \
lxc-usernsexec.1 \
lxc-version.1 \
lxc-wait.1 \
\
lxc.conf.5 \

View File

@ -20,8 +20,6 @@ man_MANS = \
lxc-freeze.1 \
lxc-info.1 \
lxc-monitor.1 \
lxc-netstat.1 \
lxc-ps.1 \
lxc-snapshot.1 \
lxc-start.1 \
lxc-stop.1 \
@ -29,7 +27,6 @@ man_MANS = \
lxc-unshare.1 \
lxc-user-nic.1 \
lxc-usernsexec.1 \
lxc-version.1 \
lxc-wait.1 \
\
lxc.conf.5 \

View File

@ -1,161 +0,0 @@
<!--
(C) Copyright Canonical Ltd. 2013
Authors:
Stéphane Graber <stgraber@ubuntu.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Translated into Japanese
by KATOH Yasufumi <karma at jazz.email.ne.jp>
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-netstat</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-netstat</refname>
<refpurpose>
<!--
run netstat for the specified container
-->
指定したコンテナに対する netstat の実行
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-netstat</command>
<arg choice="opt">--name <replaceable>name</replaceable></arg>
<arg choice="opt">-- netstat option</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title><!-- Description -->説明</title>
<para>
<!--
<command>lxc-netstat</command> is a wrapper to the netstat command.
-->
<command>lxc-netstat</command> は netstat コマンドのラッパーです.
</para>
</refsect1>
<refsect1>
<title><!-- Options -->オプション</title>
<variablelist>
<varlistentry>
<term>
<option>-n, --name <replaceable>name</replaceable></option>
</term>
<listitem>
<para>
<!--
The container name.
-->
コンテナ名
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><optional>netstat options</optional></option>
</term>
<listitem>
<para>
<!--
The <command>netstat</command> options must be separated
from <command>lxc-netstat</command> options by
the <option>&#045;&#045;</option> parameter.
-->
<command>netstat</command> オプションは <command>lxc-netstat</command> のオプションと <option>--</option> で分けなければなりません.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title><!-- Example -->例</title>
<variablelist>
<varlistentry>
<term>lxc-netstat --name foo -- -lnp</term>
<listitem>
<para>
<!--
Call netstat -lnp for container foo.
-->
コンテナ foo に対して netstat -lnp を呼び出します.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See Also</title>
<simpara>
<citerefentry>
<refentrytitle>netstat</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
</simpara>
</refsect1>
&seealso;
<refsect1>
<title><!-- Author -->作者</title>
<para>Stéphane Graber <email>stgraber@ubuntu.com</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -1,217 +0,0 @@
<!--
lxc: linux Container library
(C) Copyright IBM Corp. 2007, 2008
Authors:
Daniel Lezcano <daniel.lezcano at free.fr>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Translated into Japanese
by KATOH Yasufumi <karma at jazz.email.ne.jp>
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-ps</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-ps</refname>
<refpurpose>
<!--
list the processes belonging to a specific container.
-->
指定したコンテナに属するプロセスのリスト表示
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-ps</command>
<arg choice="opt">--name <replaceable>name</replaceable></arg>
<arg choice="opt">--lxc</arg>
<arg choice="opt">--host</arg>
<arg choice="opt">-- <replaceable>ps options</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title><!-- Description -->説明</title>
<para>
<!--
<command>lxc-ps</command> is a wrapper to the ps command
to report the name of lxc container associated
to reported processes.
-->
<command>lxc-ps</command> は,プロセスが属する lxc コンテナ名を報告する ps コマンドのラッパーです.
</para>
<para>
<!--
The cgroup fs must be mounted before container creation,
to be able to have <command>lxc-ps</command> to find
the container associated to processes.
-->
<command>lxc-ps</command> がコンテナに関連するプロセスを見つけるためには,コンテナが作成される前に cgroup FS がマウントされている必要があります.
</para>
<para>
<!--
The additional specified <replaceable>ps options</replaceable> must not
remove the default ps header and the pid information,
to be able to have the <command>lxc-ps</command> to find
the container associated to processes.
-->
<command>lxc-ps</command> がコンテナに関連したプロセスを見つけるためには,追加で指定された <replaceable>ps options</replaceable> が,標準の ps コマンドのヘッダや pid 情報を削除してはいけません.
</para>
</refsect1>
<refsect1>
<title><!-- Options -->オプション</title>
<variablelist>
<varlistentry>
<term>
<option>-n, --name <replaceable>name</replaceable></option>
</term>
<listitem>
<para>
<!--
specify the container <replaceable>NAME</replaceable>
to limit the output to the processes belonging
to this container name.
-->
<replaceable>name</replaceable> で指定したコンテナに属するプロセスのみ出力します.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--lxc</option>
</term>
<listitem>
<para>
<!--
limit the output to the processes belonging
to all lxc containers.
-->
全ての lxc コンテナに属するプロセスを出力します.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--host</option>
</term>
<listitem>
<para>
<!--
limit the output to the processes belonging
to the host.
-->
ホスト (訳注: コンテナ以外) に属するプロセスのみを出力します.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><optional><replaceable>ps options</replaceable></optional></option>
</term>
<listitem>
<para>
<!--
The <command>ps</command> options must be separated
from <command>lxc-ps</command> options by
the <option>&#045;&#045;</option> parameter.
-->
<command>ps</command> のオプションと,<command>lxc-ps</command> のオプションとは,<option>--</option> で区切って指定します.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title><!-- Example -->例</title>
<variablelist>
<varlistentry>
<term>lxc-ps --name foo -- --forest</term>
<listitem>
<para>
<!--
list all the processes belonging to container 'foo' and show
dependencies.
-->
foo という名前のコンテナに属する全てのプロセスをリスト表示し,依存関係を示します.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See Also</title>
<simpara>
<citerefentry>
<refentrytitle>ps</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
</simpara>
</refsect1>
&seealso;
<refsect1>
<title><!-- Author -->作者</title>
<para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -1,108 +0,0 @@
<!--
(C) Copyright Canonical Ltd.
Authors:
Stéphane Graber <stgraber@ubuntu.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Translated into Japanese
by KATOH Yasufumi <karma at jazz.email.ne.jp>
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-version</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-version</refname>
<refpurpose>
<!--
print the currently installed lxc version
-->
現在インストールされている lxc のバージョンの表示
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-version</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title><!-- Description -->説明</title>
<para>
<!--
<command>lxc-version</command> print the currently installed lxc version
-->
<command>lxc-version</command> は,現在インストールされている lxc のバージョンを表示します.
</para>
</refsect1>
<refsect1>
<title><!-- Examples -->例</title>
<variablelist>
<varlistentry>
<term>lxc-version</term>
<listitem>
<para>
<!--
print the currently installed lxc version.
-->
現在インストールされている lxc のバージョンを表示します.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
&seealso;
<refsect1>
<title><!-- Author -->作者</title>
<para>Stéphane Graber <email>stgraber@ubuntu.com</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -682,7 +682,6 @@ rootfs
following commands may be useful:
<programlisting>
lxc-ls
lxc-ps &#045;&#045;name foo
lxc-info -n foo
</programlisting>
-->
@ -690,7 +689,6 @@ rootfs
このような時には,以下のようなコマンドが役に立つかもしれません.
<programlisting>
lxc-ls
lxc-ps --name foo
lxc-info -n foo
</programlisting>
</para>
@ -702,29 +700,6 @@ rootfs
<command>lxc-ls</command> は,システムのコンテナを一覧します.
</para>
<para>
<!--
<command>lxc-ps</command> will display the pids for a specific
container. <command>lxc-ps</command>
is built on top of <command>ps</command> and accepts the same
options, eg:
<programlisting>lxc-ps &#045;&#045;name foo &#045;&#045;forest</programlisting>
will display the processes hierarchy for the processes
belonging the 'foo' container.
<programlisting>lxc-ps &#045;&#045;lxc</programlisting>
will display all the containers and their processes.
-->
<command>lxc-ps</command> は特定のコンテナに対する pid を表示します.
<command>lxc-ps</command> は <command>ps</command> コマンドをうまく利用して作られており,同じオプションを利用可能です.
例えば,
<programlisting>lxc-ps --name foo --forest</programlisting>
は 'foo' という名前のコンテナに属するプロセスを階層構造で表示します.
<programlisting>lxc-ps --lxc</programlisting>
は全てのコンテナとそのコンテナに属するプロセスを表示します.
</para>
<para>
<!--
<command>lxc-info</command> gives information for a specific
@ -742,14 +717,6 @@ rootfs
lxc-info -n $i
done
</programlisting>
And displaying all the pids of all the containers:
<programlisting>
for i in $(lxc-ls -1); do
lxc-ps &#045;&#045;name $i &#045;&#045;forest
done
</programlisting>
-->
ここで,以上のコマンドを組み合わせて,どのようにしたら全てのコンテナのリストと,それぞれの状態が得られるかの例を示します.
<programlisting>
@ -757,39 +724,6 @@ rootfs
lxc-info -n $i
done
</programlisting>
そして,全てのコンテナの全ての pid を表示させる例です.
<programlisting>
for i in $(lxc-ls -1); do
lxc-ps --name $i --forest
done
</programlisting>
</para>
<para>
<!--
<command>lxc-netstat</command> display network information for
a specific container. This command is built on top of
the <command>netstat</command> command and will accept its
options
-->
<command>lxc-netstat</command> は,指定したコンテナのネットワークの情報を表示します.
このコマンドは <command>netstat</command> をうまく利用して作られており,<command>netstat</command> のオプションを受け付けます.
</para>
<para>
<!--
The following command will display the socket information for
the container 'foo'.
<programlisting>
lxc-netstat -n foo -tano
</programlisting>
-->
以下のコマンドは,'foo' という名前のコンテナのソケット情報を表示します.
<programlisting>
lxc-netstat -n foo -tano
</programlisting>
</para>
</refsect2>

View File

@ -85,11 +85,6 @@ by KATOH Yasufumi <karma at jazz.email.ne.jp>
<manvolnum>1</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle><command>lxc-ps</command></refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle><command>lxc-info</command></refentrytitle>
<manvolnum>1</manvolnum>

View File

@ -1,143 +0,0 @@
<!--
(C) Copyright Canonical Ltd. 2013
Authors:
Stéphane Graber <stgraber@ubuntu.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-netstat</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-netstat</refname>
<refpurpose>
run netstat for the specified container
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-netstat</command>
<arg choice="opt">--name <replaceable>name</replaceable></arg>
<arg choice="opt">-- netstat option</arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lxc-netstat</command> is a wrapper to the netstat command.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term>
<option>-n, --name <replaceable>name</replaceable></option>
</term>
<listitem>
<para>
The container name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><optional>netstat options</optional></option>
</term>
<listitem>
<para>
The <command>netstat</command> options must be separated
from <command>lxc-netstat</command> options by
the <option>--</option> parameter.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Example</title>
<variablelist>
<varlistentry>
<term>lxc-netstat --name foo -- -lnp</term>
<listitem>
<para>
Call netstat -lnp for container foo.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See Also</title>
<simpara>
<citerefentry>
<refentrytitle>netstat</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
</simpara>
</refsect1>
&seealso;
<refsect1>
<title>Author</title>
<para>Stéphane Graber <email>stgraber@ubuntu.com</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -1,188 +0,0 @@
<!--
lxc: linux Container library
(C) Copyright IBM Corp. 2007, 2008
Authors:
Daniel Lezcano <daniel.lezcano at free.fr>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-ps</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-ps</refname>
<refpurpose>
list the processes belonging to a specific container.
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-ps</command>
<arg choice="opt">--name <replaceable>name</replaceable></arg>
<arg choice="opt">--lxc</arg>
<arg choice="opt">--host</arg>
<arg choice="opt">-- <replaceable>ps options</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lxc-ps</command> is a wrapper to the ps command
to report the name of lxc container associated
to reported processes.
</para>
<para>
The cgroup fs must be mounted before container creation,
to be able to have <command>lxc-ps</command> to find
the container associated to processes.
</para>
<para>
The additional specified <replaceable>ps options</replaceable> must not
remove the default ps header and the pid information,
to be able to have the <command>lxc-ps</command> to find
the container associated to processes.
</para>
</refsect1>
<refsect1>
<title>Options</title>
<variablelist>
<varlistentry>
<term>
<option>-n, --name <replaceable>name</replaceable></option>
</term>
<listitem>
<para>
specify the container <replaceable>name</replaceable>
to limit the output to the processes belonging
to this container name.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--lxc</option>
</term>
<listitem>
<para>
limit the output to the processes belonging
to all lxc containers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option>--host</option>
</term>
<listitem>
<para>
limit the output to the processes belonging
to the host.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<option><optional><replaceable>ps options</replaceable></optional></option>
</term>
<listitem>
<para>
The <command>ps</command> options must be separated
from <command>lxc-ps</command> options by
the <option>--</option> parameter.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>Example</title>
<variablelist>
<varlistentry>
<term>lxc-ps --name foo -- --forest</term>
<listitem>
<para>
list all the processes belonging to container 'foo' and show
dependencies.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1>
<title>See Also</title>
<simpara>
<citerefentry>
<refentrytitle>ps</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
</simpara>
</refsect1>
&seealso;
<refsect1>
<title>Author</title>
<para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -1,96 +0,0 @@
<!--
(C) Copyright Canonical Ltd.
Authors:
Stéphane Graber <stgraber@ubuntu.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-->
<!DOCTYPE refentry PUBLIC @docdtd@ [
<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
]>
<refentry>
<docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
<refmeta>
<refentrytitle>lxc-version</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>lxc-version</refname>
<refpurpose>
print the currently installed lxc version
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>lxc-version</command>
</cmdsynopsis>
</refsynopsisdiv>
<refsect1>
<title>Description</title>
<para>
<command>lxc-version</command> print the currently installed lxc version
</para>
</refsect1>
<refsect1>
<title>Examples</title>
<variablelist>
<varlistentry>
<term>lxc-version</term>
<listitem>
<para>
print the currently installed lxc version.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
&seealso;
<refsect1>
<title>Author</title>
<para>Stéphane Graber <email>stgraber@ubuntu.com</email></para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:2
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:nil
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->

View File

@ -457,7 +457,6 @@ rootfs
following commands may be useful:
<programlisting>
lxc-ls
lxc-ps --name foo
lxc-info -n foo
</programlisting>
</para>
@ -466,19 +465,6 @@ rootfs
system.
</para>
<para>
<command>lxc-ps</command> will display the pids for a specific
container. <command>lxc-ps</command>
is built on top of <command>ps</command> and accepts the same
options, eg:
<programlisting>lxc-ps --name foo --forest</programlisting>
will display the processes hierarchy for the processes
belonging the 'foo' container.
<programlisting>lxc-ps --lxc</programlisting>
will display all the containers and their processes.
</para>
<para>
<command>lxc-info</command> gives information for a specific
container.
@ -493,29 +479,6 @@ rootfs
done
</programlisting>
And displaying all the pids of all the containers:
<programlisting>
for i in $(lxc-ls -1); do
lxc-ps --name $i --forest
done
</programlisting>
</para>
<para>
<command>lxc-netstat</command> display network information for
a specific container. This command is built on top of
the <command>netstat</command> command and will accept its
options
</para>
<para>
The following command will display the socket information for
the container 'foo'.
<programlisting>
lxc-netstat -n foo -tano
</programlisting>
</para>
</refsect2>

View File

@ -82,11 +82,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
<manvolnum>1</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle><command>lxc-ps</command></refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>,
<citerefentry>
<refentrytitle><command>lxc-info</command></refentrytitle>
<manvolnum>1</manvolnum>

View File

@ -156,11 +156,7 @@ liblxc_so_LDADD += $(CGMANAGER_LIBS) $(DBUS_LIBS) $(NIH_LIBS) $(NIH_DBUS_LIBS)
liblxc_so_CFLAGS += $(CGMANAGER_CFLAGS) $(DBUS_CFLAGS) $(NIH_CFLAGS) $(NIH_DBUS_CFLAGS)
#endif
bin_SCRIPTS = \
lxc-ps \
lxc-netstat \
lxc-checkconfig \
lxc-version
bin_SCRIPTS = lxc-checkconfig
EXTRA_DIST = \
lxc-device \

View File

@ -33,6 +33,7 @@
#include "arguments.h"
#include "utils.h"
#include "version.h"
/*---------------------------------------------------------------------------*/
static int build_shortopts(const struct option *a_options,
@ -128,6 +129,11 @@ static void print_usage(const struct option longopts[],
exit(0);
}
static void print_version() {
printf("%s\n", LXC_VERSION);
exit(0);
}
static void print_help(const struct lxc_arguments *args, int code)
{
fprintf(stderr, "\
@ -140,6 +146,7 @@ Common options :\n\
-P, --lxcpath=PATH Use specified container path\n\
-?, --help Give this help list\n\
--usage Give a short usage message\n\
--version Print the version number\n\
\n\
Mandatory or optional arguments to long options are also mandatory or optional\n\
for any corresponding short options.\n\
@ -203,6 +210,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
return ret;
break;
case OPT_USAGE: print_usage(args->options, args);
case OPT_VERSION: print_version();
case '?': print_help(args, 1);
case 'h': print_help(args, 0);
default:

View File

@ -105,6 +105,7 @@ struct lxc_arguments {
{"name", required_argument, 0, 'n'}, \
{"help", no_argument, 0, 'h'}, \
{"usage", no_argument, 0, OPT_USAGE}, \
{"version", no_argument, 0, OPT_VERSION}, \
{"quiet", no_argument, 0, 'q'}, \
{"logfile", required_argument, 0, 'o'}, \
{"logpriority", required_argument, 0, 'l'}, \
@ -113,6 +114,7 @@ struct lxc_arguments {
/* option keys for long only options */
#define OPT_USAGE 0x1000
#define OPT_VERSION OPT_USAGE-1
extern int lxc_arguments_parse(struct lxc_arguments *args,
int argc, char *const argv[]);

View File

@ -1,154 +0,0 @@
#!/bin/sh
#
# lxc: linux Container library
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
. @DATADIR@/lxc/lxc.functions
usage() {
echo "usage: $(basename $0) -n|--name <name> [-P|--lxcpath <lxc_path>] -- [netstat_options]" >&2
}
help() {
usage
echo >&2
echo "Execute 'netstat' for the specified container." >&2
echo >&2
echo " --name NAME specify the container name" >&2
echo " --lxcpath LXC_PATH use an alternate container path" >&2
echo " NETSTAT_OPTIONS netstat command options (see \`netstat --help')" >&2
}
get_parent_cgroup()
{
parent_cgroup=""
# Obtain a list of hierarchies that contain one or more subsystems
hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
# Iterate through the list until a suitable hierarchy is found
for hierarchy in $hierarchies; do
# Obtain information about the init process in the hierarchy
fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
if [ -z "$fields" ]; then continue; fi
fields=${fields#*:}
# Get a comma-separated list of the hierarchy's subsystems
subsystems=${fields%:*}
# Get the cgroup of the init process in the hierarchy
init_cgroup=${fields#*:}
# Get the filesystem mountpoint of the hierarchy
mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
'$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup
# (do not append '/lxc' if the hierarchy contains the 'ns' subsystem)
case ",$subsystems," in
*,ns,*) parent_cgroup="${mountpoint}${init_cgroup%/}";;
*) parent_cgroup="${mountpoint}${init_cgroup%/}/lxc";;
esac
break
done
}
exec=""
while true; do
case $1 in
-h|--help)
help; exit 1;;
-n)
# If we already have a value for $name, treat -n as being an
# argument for netstat
if [ -n "$name" ]
then
break
else
name="$2"; shift 2;
fi
;;
--name)
name=$2; shift 2;;
-P|--lxcpath)
lxc_path="$2"; shift 2;;
--exec)
exec="exec"; shift;;
--)
shift; break;;
*)
break;;
esac
done
if [ "$(id -u)" != "0" ]; then
echo "$(basename $0): must be run as root" >&2
exit 1
fi
if [ -z "$name" ]; then
usage
exit 1
fi
if [ -z "$lxc_path" ]; then
echo "$(basename $0): no configuration path defined" >&2
usage
exit 1
fi
if [ -z "$exec" ]; then
exec @BINDIR@/lxc-unshare -s MOUNT -- $0 -n $name -P "$lxc_path" --exec -- "$@"
fi
if lxc-wait -n $name -P "$lxc_path" -s 'STOPPED' -t 0; then
echo "$(basename $0): container '$name' is not running" >&2
exit 1
fi
get_parent_cgroup
if [ ! -d "$parent_cgroup" ]; then
echo "$(basename $0): no cgroup mount point found" >&2
exit 1
fi
pid=$(head -1 $parent_cgroup/$name/tasks)
if [ -z "$pid" ]; then
echo "$(basename $0): no process found for '$name'" >&2
exit 1
fi
tmpdir=$(mktemp -d)
if [ -z "$tmpdir" -o ! -d "$tmpdir" ]; then
echo "$(basename $0): unable to create temporary directory" >&2
exit 1
fi
# Bind mount /proc/$pid/net onto /proc/net before calling 'netstat'.
# However, we can not simply bind mount on top of procfs, so we have
# to move procfs out of the way first.
mount -n --move /proc "$tmpdir" && \
mount -n -t tmpfs tmpfs /proc && \
mkdir /proc/root /proc/net && \
mount -n --move "$tmpdir" /proc/root && \
rmdir "$tmpdir" && \
mount -n --bind /proc/root/$pid/net /proc/net && \
exec netstat "$@"

View File

@ -1,177 +0,0 @@
#!/bin/sh
#
# lxc: linux Container library
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
. @DATADIR@/lxc/lxc.functions
usage()
{
echo "usage: $(basename $0) [-P PATH] [--lxc | --host | --name NAME] [[--] [PS_OPTIONS...]" >&2
}
help() {
usage
echo >&2
echo "List current processes with container names." >&2
echo >&2
echo " --lxc show processes in all containers" >&2
echo " --host show processes not related to any container, i.e. to the host" >&2
echo " --name NAME show processes in the specified container" >&2
echo " (multiple containers can be separated by commas)" >&2
echo " -P PATH show container in lxcpath PATH" >&2
echo " PS_OPTIONS ps command options (see \`ps --help')" >&2
}
get_parent_cgroup()
{
local hierarchies hierarchy fields init_cgroup mountpoint
parent_cgroup=""
subsystems=""
# Obtain a list of hierarchies that contain one or more subsystems
hierarchies=$(tail -n +2 /proc/cgroups | cut -f 2)
# Iterate through the list until a suitable hierarchy is found
for hierarchy in $hierarchies; do
# Obtain information about the init process in the hierarchy
fields=$(grep -E "^$hierarchy:" /proc/1/cgroup | head -n 1)
if [ -z "$fields" ]; then continue; fi
fields=${fields#*:}
# Get a comma-separated list of the hierarchy's subsystems
subsystems=${fields%:*}
# Get the cgroup of the init process in the hierarchy
init_cgroup=${fields#*:}
# Get the filesystem mountpoint of the hierarchy
mountpoint=$(awk -v subsysregex="(^|,)$subsystems(,|\$)" \
'$3 == "cgroup" && $4 ~ subsysregex {print $2}' /proc/self/mounts)
if [ -z "$mountpoint" ]; then continue; fi
# Return the absolute path to the containers' parent cgroup
parent_cgroup="${mountpoint}${init_cgroup%/}";
break
done
}
containers=""
list_container_processes=0
while true; do
case $1 in
-h|--help)
help; exit 1;;
-n|--name)
containers=$2; list_container_processes=1; shift 2;;
--lxc)
list_container_processes=1; shift;;
--host)
list_container_processes=-1; shift;;
-P|--lxcpath)
lxc_path=$2; shift 2;;
--)
shift; break;;
*)
break;;
esac
done
if [ "$list_container_processes" -eq "1" ]; then
set -- -e $@
fi
get_parent_cgroup
if [ ! -d "$parent_cgroup" ]; then
echo "$(basename $0): no cgroup mount point found" >&2
exit 1
fi
if [ -z "$containers" ]; then
case ",$subsystems," in
*,ns,*) containers="$(find $parent_cgroup -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
*) containers="$(find $parent_cgroup/lxc -mindepth 1 -maxdepth 1 -type d 2>/dev/null | sed 's:.*/::')";;
esac
fi
container_field_width=9
tasks_files=
for container in ${containers}; do
if [ "${#container}" -gt "$container_field_width" ]; then
container_field_width=${#container}
fi
if ! lxc-wait -P $lxc_path -s STOPPED -n $container -t 0; then
initpid=`lxc-info -P $lxc_path -p -n $container | awk -F: '{ print $2 }' | awk '{ print $1 }'`
cgroup=`grep cpuset /proc/$initpid/cgroup | awk -F: '{ print $3}'`
if [ -f "$parent_cgroup/$cgroup/tasks" ]; then
tasks_files="$tasks_files $parent_cgroup$cgroup/tasks"
fi
fi
done
# first file is stdin, the rest are the container tasks
ps "$@" | awk -v container_field_width="$container_field_width" \
-v list_container_processes="$list_container_processes" '
# first line is PS header
NR == 1 {
header = $0
# find pid field index
for (i = 1; i<=NF; i++)
if ($i == "PID") {
pididx = i
break
}
if (pididx == "") {
print("No PID field found") > "/dev/stderr"
header = "" # to signal error condition to the END rule
exit 1
}
next
}
# store lines from ps with pid as index
NR == FNR {
ps_line[NR] = $0
pid_of_line[NR] = $pididx
next
}
# find container name from filename on first line
FNR == 1 {
container = FILENAME
sub(/\/tasks/, "", container)
sub(/.*\//, "", container)
}
# container tasks
{
container_of_pid[$0] = container
}
END {
if (!header) exit 1 # quit due to internal error
printf("%-" container_field_width "s %s\n", "CONTAINER", header)
for (i in ps_line) {
container = container_of_pid[pid_of_line[i]]
if (list_container_processes == 0 || (container != "") == (list_container_processes > 0) )
printf("%-" container_field_width "s %s\n", container, ps_line[i])
}
}
' - $tasks_files

View File

@ -1,3 +0,0 @@
#!/bin/sh
echo "lxc version: @PACKAGE_VERSION@"