jablonka.czprosek.czf

xenstats

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

 

Line No. Rev Author Line
11simandl#!/usr/bin/python
2import sys
3import os
4import glob
5import time
6 
7if len(sys.argv)!=2:
8 print "Syntax: %s <rrdbasename>"%sys.argv[0]
9 sys.exit(1)
10 
11colors=["000000", "FF0000", "00FF00", "0000FF" ]
12colors+=["DEDE00", "00FFFF", "FF90FF", "FF8040", "C040A0", "A0A0A0", "40A0A0", "40A0FF", "FFA040" ]
13 
14def graph(basename, subname, seconds):
15 rrds=glob.glob(basename+"*.rrd")
16 rrds=[x for x in rrds if os.stat(x)[8] > (time.time()-seconds)]
172simandl cmdline="--imgformat PNG --unit % --vertical-label 'Xen CPU%'"
18 cmdline+="' %s' "%(subname)
191simandl #cmdline="--imgformat PNG --unit % --vertical-label CPU% --rigid --lower-limit 0 --upper-limit 100 "
20 
21 for rrd,id in zip(rrds,range(len(rrds))):
22 cmdline+="DEF:id%draw=%s:cpu:LAST "%(id,rrd)
23 cmdline+="CDEF:id%dpercent=id%draw,10,/ "%(id,id)
24 cmdline+="CDEF:id%dzero=id%dpercent,DUP,UN,EXC,0,EXC,IF "%(id,id)
25 for rrd,id in zip(rrds,range(len(rrds))):
26 cmdline+="%s:id%dzero#%s:%s "%({0:"AREA"}.get(id,"STACK"),id,colors[id%len(colors)],rrd[len(basename):-4])
27 cmdline+="GPRINT:id%dpercent:AVERAGE:\"%s\" "%(id,"Average CPU usage\: %02.0lf%%\\j")
28 
29# print cmdline
30 os.system("rrdtool graph %s../graph/xen-%s.png --start -%d --end -69 %s"%(basename,subname,seconds,cmdline))
31 
32basename=sys.argv[1]
33graph(basename, "hourly", 4000)
342simandlgraph(basename, "6hours", 24000)
351simandlgraph(basename, "daily", 100000)
36graph(basename, "weekly", 800000)
37graph(basename, "monthly", 3200000)
38graph(basename, "yearly", 40000000)
39 

Powered by WebSVN 2.2.1