#!/bin/sh

DIR=/var/www/lxc-api/htdocs
lxc-ls -1 --running > "$DIR/index.html"

lxc-ls -1 --running | while read c;
do
	[ ! -d "$DIR/$c" ] && mkdir "$DIR/$c";
	t="$(lxc-info -H -S -n $c)"
	
	for i in CPU Memory RX TX
	do
		echo -e "$t" | grep "$i " | awk -F: '{print $2}' | sed 's/^[ ]*//g' > "$DIR/$c/$i"
	done
done