in Linux, OpenVZ, Proxmox

Monitoring Proxmox OpenVZ container’s bandwidth

Use these scripts to collect bandwidth data for each container. You can view the data on a graph and total usage by months.

The scripts are originally received from Hutzoft but modified to work with the Proxmox directory structure.

1. Install rrdtool and PHP support

apt-get install rrdtool php5

2. Download the bandwidth collection script and Web UI

wget http://www.aip.im/downloads/vzmonitor.tar.gz

3. Unpack and relocate

tar zxvf vzmonitor.tar.gz
mkdir /usr/local/bandwidth
mv bandwidth /usr/local/bandwidth/
mv vzmonitor /var/www/

4. Create a cron job to collect the data every 5 minutes (crontab -e)

*/5 * * * * cd /usr/local/bandwidth;./bandwidth.sh &> /dev/null

5. Add config to Apache (pico /etc/apache2/conf.d/vzmonitor.conf)

Alias /vzmonitor /var/www/vzmonitor
 
<Directory /var/www/vzmonitor>
DirectoryIndex index.php
</Directory>

6. Restart Apache

/etc/init.d/apache2 restart

7. It’s ready, wait a few minutes and enter this location to view the bandwidth usage: http://yourserver/vzmonitor