#!/usr/bin/env python __license__ = 'GPL v3' __copyright__ = '2014, Kovid Goyal ' import os import socket import subprocess BASE = '/srv/download/bw' def main(): if not os.path.exists(BASE): os.makedirs(BASE) os.chdir(BASE) for name in 'hours days months top10 summary'.split(): subprocess.check_call(['vnstati', '--' + name, '-o', name + '.png']) html = '''\ Bandwidth usage for {host}

Bandwidth usage for {host}

Summary

Hours

Days

Months

Top10

'''.format(host=socket.gethostname()) with open('index.html', 'wb') as f: f.write(html.encode('utf-8')) if __name__ == '__main__': main()