#!/usr/bin/python2.2 import ensimapplpath import vh3.db.bandwidth as bandwidthdb from vh3.db import db_get_site_list as gsl import sys sites, max_bw_limit, total_sites = bandwidthdb.get_bw_totals(len(gsl())) print """\ =========================================================================== Sites using BW: %d =========================================================================== Site MB IN MB OUT TOTAL LIMIT %% Used ===========================================================================""" \ % total_sites tout = 0 tin = 0 tlimit = 0 tpct = 0 for site in sites: name, inb, outb, limit = site inb = inb / (1024.00 * 1024) outb = outb / (1024.00 * 1024) if limit != None and limit > 0: limit = limit / (1024.00 * 1024) total = inb + outb tout = outb + tout tin = inb + tin tlimit = limit + tlimit if limit != None and limit > 0: pct = ((inb+outb)/limit)*100.00 else: pct = 0 tpct = pct + tpct print "%-30s %8.2f %8.2f %8.2f %9.2f %5.2f" % \ (name, inb, outb, total, limit, pct) print """\ =========================================================================== Totals: %8.2f %8.2f %8.2f %9.2f %5.2f ===========================================================================""" \ % (tin, tout, (tin+tout), tlimit, ((tin+tout)/tlimit) * 100)