sunshine

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

import os
import random

os.chdir("C:/rrdtool")

##13KB
c = 'rrdtool.exe "create" "C:/topic.rrd" "--step" "300" \
"--start" "1167019200" "DS:visits:COUNTER:600:U:U" \
"DS:replys:COUNTER:600:0:U" "DS:focuses:GAUGE:600:U:U" \
"RRA:AVERAGE:0.5:1:24" \
"RRA:AVERAGE:0.5:12:48" \
"RRA:AVERAGE:0.5:12*24:400" \
'
s1 = os.popen(c)

for i in range(1,12*2):
    os.popen('rrdtool.exe "update" "C:/topic.rrd" "%(s)d:%(visit)d:%(reply)d:%(focus)d"' % \
                   {'s': 1167019200 + i*300, "visit": i*200 + random.randint(0,200), "reply": i*10 + random.randint(0,10), \
                    "focus": i*100} )

g = 'rrdtool.exe "graph" "C:/clickRate1.png" "--start" "1167019200" "--end" "1167019200+1d" \
"-t" "zzzz" "-v" "tianya" \
"-c" "BACK#C3D0FF" "-c" "SHADEB#0075BE" \
"-n" "TITLE:14:FZZHYJW.ttf" "-n" "AXIS:10" "-n" "UNIT:20" \
"DEF:visit=C\:/topic.rrd:visits:AVERAGE" \
"DEF:reply=C\:/topic.rrd:replys:AVERAGE" \
"DEF:focus=C\:/topic.rrd:focuses:AVERAGE" \
"CDEF:myvisit=visit,6,*" \
"CDEF:myreply=reply,300,*," \
"CDEF:myfocus=focus,1000,/" \
"LINE1:myvisit#FF0000:"visits"" \
"LINE1:myreply#00FF00:"replys"" \
"LINE1:myfocus#0000FF:"focuses"" \
'
s2 = os.popen(g)
print s2.read()

posted on 2011-07-25 16:15  jeremychen  阅读(121)  评论(0编辑  收藏  举报