LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Containers
User Name
Password
Linux - Containers This forum is for the discussion of all topics relating to Linux containers. Docker, LXC, LXD, runC, containerd, CoreOS, Kubernetes, Mesos, rkt, and all other Linux container platforms are welcome.

Notices


Reply
  Search this Thread
Old 03-14-2018, 04:30 AM   #1
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
monitor disk usage on lxc containers on host level


Hi,

I'm trying to find a way to measure disk usage on lxc containers (I happen to be using proxmox, but that's less important in this context) using prometheus. I've already installed node_exporter, cadvisor and grafana.

I'm not sure how I can go about doing that if I've got tens of containers. I'm trying to using a solution at the host-level, without needing to install anything on each container.

Any suggestions?
 
Old 03-17-2018, 08:28 AM   #2
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,671
Blog Entries: 4

Rep: Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945Reputation: 3945
In the simplest, most ordinary case, the files seen by a container occupant are "host files," and the omniscient host can see them even when the container occupant cannot – or sees them in an entirely different way.

Some "highly scalable" container environments, such as those hosted by (say ...) RackSpace, do employ more exotic technologies to provide for that rapid scale-up and to avoid creating "hot spots," but the essential concepts are the same. Unlike a virtual machine, you don't have to install instrumentation inside the container's environment, since that environment is a highly restricted subset of the host's. (At the end of the day, the container occupant's software is being executed directly by the host, without virtualization.)
 
1 members found this post helpful.
Old 03-20-2018, 04:00 AM   #3
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
It's actually slightly more complicated than that. And that might be because of how proxmox implements LXCs. So this might be relevant.

When using openvz, you could simply cd into the root directory from the hypervisor. I understand that the same thing applies to dockers. When they adopted lxc, they placed LVM in between, as it were, so it's looks much more like a normal virtual machine. So this might be something related to the way proxmox uses it rather than the lxc per se.
For instance if I write lvs, I get something like that:
Code:
 data          pve      twi-aotz-- 154.73g             33.75  15.42
  root          pve      -wi-ao----  59.50g
  swap          pve      -wi-ao----   8.00g
  vm-100-disk-1 pve      Vwi-a-tz--  72.00g data        0.01
  vm-100-disk-2 pve      Vwi-a-tz--  50.00g data        43.02
  vm-104-disk-2 pve      Vwi-a-tz--  60.00g data        33.54
  vm-106-disk-1 pve      Vwi-a-tz--  32.00g data        1.87
  vm-107-disk-1 pve      Vwi-a-tz--  30.00g data        15.05
  vm-108-disk-1 pve      Vwi-a-tz--  32.00g data        13.11
  vm-200-disk-1 pve      Vwi-aotz--  10.00g data        12.70
All are VM except 200 which is actually an lxc container with Centos 7.4 (the host is Debian). These logical volumes are not meant to be mounted on the host, even if they're containers - or so it seems. And some vm are even proxmox.
 
Old 03-20-2018, 07:40 AM   #4
simosx
Member
 
Registered: Jul 2005
Posts: 66

Rep: Reputation: 11
In LXD containers, you can use the ZFS storage driver
and you have quite some good visibility per container, per image, per snapshot.

You would simply run

Code:
sudo zfs list
and get the result. I believe that the issue you are getting, it related to the storage driver of choice.
 
Old 03-20-2018, 07:48 AM   #5
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
By storage driver you mean lvm in this case?

Can anyone explain exactly how this implementation of prommox is achieved? How come lvm resides 'in-between', as it were? And why it is different from other standard container implementation?
 
Old 03-20-2018, 11:33 AM   #6
simosx
Member
 
Registered: Jul 2005
Posts: 66

Rep: Reputation: 11
Quote:
Originally Posted by vincix View Post
By storage driver you mean lvm in this case?

Can anyone explain exactly how this implementation of prommox is achieved? How come lvm resides 'in-between', as it were? And why it is different from other standard container implementation?
Each Linux container implementation uses the same Linux kernel security features (namespaces, cgroups, etc) to separate processes.
However, each implementation may choose different ways to deal with the storage aspect and the way to store for the files of each container.
They use the terminology "storage backend" or "storage driver".

Depending on your choice of "storage backend" when you configure the Linux container installation, you can get features like "copy-on-write".
That is, if you create ten containers of Ubuntu Linux 16.04, then the initial storage hit is about 360MB (size of uncompressed single Ubuntu Linux 16.04 cloud image).
Any additional files on top of the common cloud image are counted as extra space.

I do not know how it works with proxmox over the LVM storage backend/driver.
As far as I know, LVM can do copy-on-write (therefore you need to take that in count when estimating the container size), but cannot do quotas.
 
Old 03-20-2018, 01:11 PM   #7
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Only LVM thin, to be more exact, can do copy-on-write. That is to say, it expands dynamically as the data is being written. LVM also know snapshots, which also uses the principle of copy-on-write, does't it?
 
Old 03-21-2018, 09:07 AM   #8
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
So the question remains - if anyone could answer it - how would I be able to monitor disk usage for containers that use LVM?
 
Old 03-22-2018, 07:27 AM   #9
simosx
Member
 
Registered: Jul 2005
Posts: 66

Rep: Reputation: 11
Quote:
Originally Posted by vincix View Post
So the question remains - if anyone could answer it - how would I be able to monitor disk usage for containers that use LVM?
You would need to have a look at the management tools for your specific Linux Containers implementation. The way those containers are stored, is specific to that implementation.

From the output you showed earlier, you cannot solve the problem with only LVM commands. The volumes do not appear to have information as to which container they correspond to.
 
Old 03-22-2018, 07:48 AM   #10
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Original Poster
Rep: Reputation: 103Reputation: 103
Identifying whose lvm storage that is is a non-issue. Proxmox tells you that either in the gui or in the config files. The problem is that it's as if they were using the same technology as the one used in virtual machines. I mean, yes, they both use lvm, but one uses kvm/qemu, the other uses lxc. So, returning to the initial issue, I couldn't tell what the disk usage is from the host point of view. I'd need to connect to the containers and install some kind of agent there.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Using LXC containers in embedded systems SamLinux4 Linux - Containers 2 01-16-2018 10:23 AM
[SOLVED] iptables rules for two different lxc containers netpumber Linux - Server 20 05-18-2017 06:48 AM
[SOLVED] LXC Containers Ping Problem sunveer Linux - Newbie 2 10-16-2013 04:04 AM
Problem setting up LXC containers wolf0403 Linux - Server 0 05-23-2011 05:11 AM
vzdump equivalent for lxc containers bigaddo81 Linux - Virtualization and Cloud 0 06-06-2010 08:28 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Containers

All times are GMT -5. The time now is 02:56 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration