Skip to content

Instantly share code, notes, and snippets.

@infoslack
Last active August 29, 2015 14:06
Show Gist options
  • Select an option

  • Save infoslack/9bb5a5d4ebd5b5d29c05 to your computer and use it in GitHub Desktop.

Select an option

Save infoslack/9bb5a5d4ebd5b5d29c05 to your computer and use it in GitHub Desktop.
LXC: ressources statistics
#!/bin/bash
# https://blog.deimos.fr/2014/06/16/lxc-ressources-statistics/
for i in * ; do
if [ -d $i ] ; then
echo "===== $i ====="
echo "CPU, cap: " $(cat /sys/fs/cgroup/lxc/$i/cpuset.cpus)
echo "CPU, shares: " $(cat /sys/fs/cgroup/lxc/$i/cpu.shares)
awk '{ printf "RAM, limit usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.limit_in_bytes
awk '{ printf "RAM+SWAP, limit usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.memsw.limit_in_bytes
awk '{ printf "RAM, current usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.usage_in_bytes
awk '{ printf "RAM+SWAP, current usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.memsw.usage_in_bytes
awk '{ printf "RAM, max usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.max_usage_in_bytes
awk '{ printf "RAM+SWAP, max usage: %sM\n", $1/ 1024/1024 }' /sys/fs/cgroup/lxc/$i/memory.memsw.max_usage_in_bytes
echo "DISK I/O weight: " $(cat /sys/fs/cgroup/lxc/$i/blkio.weight)
echo ""
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment