jablonka.czprosek.czf

xenstats

Subversion Repositories:
[/] [xenupdate.py] - Blame information for rev 2

 

Line No. Rev Author Line
11simandl#!/usr/bin/python
2import sys
3import os
4import re
5import time
6 
7if len(sys.argv)!=2:
8 print "Syntax: %s <rrdbasename>"%sys.argv[0]
9 sys.exit(1)
10 
11now=str(int(time.time()))
12basename=sys.argv[1]
13data=os.popen2("/usr/sbin/xm list")[1].read()
14domains=data.split("\n")[1:-1]
15for domain in domains:
16 name,id,mem,cpu,state,cputime=re.split("[\t ]+",domain)
17 cputime=int(float(cputime)*1000)
18 rrd=basename+name+".rrd"
19 if not os.access(rrd,os.F_OK):
20 # 10 days of exact archive, 42 days of 1 hr RRD, 1000 days of 1 day RRD
21 os.system("rrdtool create "+rrd+" --step 60 DS:cpu:COUNTER:666:0:10000"+
22 " RRA:LAST:0.5:1:15000"+
23 " RRA:MIN:0.5:60:1000 RRA:MIN:0.5:1440:1000"+
24 " RRA:MAX:0.5:60:1000 RRA:MAX:0.5:1440:1000"+
25 " RRA:AVERAGE:0.5:60:1000 RRA:AVERAGE:0.5:1440:1000")
26 os.system("rrdtool update %s %s:%s"%(rrd,now,cputime))
27 

Powered by WebSVN 2.2.1