jablonka.czprosek.czf

xenstats

Subversion Repositories:
[/] [xenupdate.py] - Rev 2 Go to most recent revision

Compare with Previous - Blame - Download


#!/usr/bin/python
import sys
import os
import re
import time

if len(sys.argv)!=2:
    print "Syntax: %s <rrdbasename>"%sys.argv[0]
    sys.exit(1)

now=str(int(time.time()))
basename=sys.argv[1]
data=os.popen2("/usr/sbin/xm list")[1].read()
domains=data.split("\n")[1:-1]
for domain in domains:
    name,id,mem,cpu,state,cputime=re.split("[\t ]+",domain)
    cputime=int(float(cputime)*1000)
    rrd=basename+name+".rrd"
    if not os.access(rrd,os.F_OK):
        # 10 days of exact archive, 42 days of 1 hr RRD, 1000 days of 1 day RRD
        os.system("rrdtool create "+rrd+" --step 60 DS:cpu:COUNTER:666:0:10000"+
                  " RRA:LAST:0.5:1:15000"+
                  " RRA:MIN:0.5:60:1000 RRA:MIN:0.5:1440:1000"+
                  " RRA:MAX:0.5:60:1000 RRA:MAX:0.5:1440:1000"+
                  " RRA:AVERAGE:0.5:60:1000 RRA:AVERAGE:0.5:1440:1000")
    os.system("rrdtool update %s %s:%s"%(rrd,now,cputime))
                  

Powered by WebSVN 2.2.1