jablonka.czprosek.czf

xenstats

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

 

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):
203simandl #this should preserve rrd file reset when there is some problem
21 time.sleep(10)
22 if not os.access(rrd,os.F_OK):
23 # 10 days of exact archive, 42 days of 1 hr RRD, 1000 days of 1 day RRD
24 os.system("rrdtool create "+rrd+" --step 60 DS:cpu:COUNTER:666:0:10000"+
25 " RRA:LAST:0.5:1:15000"+
26 " RRA:MIN:0.5:60:1000 RRA:MIN:0.5:1440:1000"+
27 " RRA:MAX:0.5:60:1000 RRA:MAX:0.5:1440:1000"+
28 " RRA:AVERAGE:0.5:60:1000 RRA:AVERAGE:0.5:1440:1000")
29 
30 #this should preserve rrd file reset when there is some problem
31 if os.access(rrd,os.F_OK):
32 os.system("rrdtool update %s %s:%s"%(rrd,now,cputime))
331simandl 

Powered by WebSVN 2.2.1