[rrd-users] Still trying to create a graph from multiple sources in RRDtool

Matthew M. Boedicker matthewm at boedicker.org
Tue Jun 17 14:57:10 CEST 2008


Try removing the space after AVERAGE is the ds0 DEF.

On Tue, Jun 17, 2008 at 08:47:28AM -0400, Emily Chouinard wrote:
> So this is what I have as of right now
> import rrdtool
> import os
> import time
> import string
> 
> interval = 10
> interval = str(interval)
> interval_mins = float(interval) / 60
> heartbeat = str(int(interval) * 2)
> 
> rrdtool.create('usr.rrd',
>         'DS:usr_info:COUNTER:%s:U:U' % heartbeat,
>      'RRA:AVERAGE:0.5:1:%s' % int(4000 / interval_mins),
>     'RRA:AVERAGE:0.5:%d:800' % int(30 / interval_mins),
>     'RRA:AVERAGE:0.5:%d:800' % int(120 / interval_mins),
>           'RRA:AVERAGE:0.5:%d:800' % int(1440 / interval_mins))
> rrdtool.create('sys.rrd',
>     'DS:sys_info:COUNTER:%s:U:U' % heartbeat,
>        'RRA:AVERAGE:0.5:1:%s' % int(4000 / interval_mins),
>      'RRA:AVERAGE:0.5:%d:800' % int(30 / interval_mins),
>    'RRA:AVERAGE:0.5:%d:800' % int(120 / interval_mins),
>        'RRA:AVERAGE:0.5:%d:800' % int(1440 / interval_mins))   
> rrdtool.create('idle.rrd',
>        'DS:idle_info:COUNTER:%s:U:U' % heartbeat,
>        'RRA:AVERAGE:0.5:1:%s' % int(4000 / interval_mins),
>        'RRA:AVERAGE:0.5:%d:800' % int(30 / interval_mins),
>        'RRA:AVERAGE:0.5:%d:800' % int(120 / interval_mins),
>        'RRA:AVERAGE:0.5:%d:800' % int(1440 / interval_mins))
> while True:
>    infile= open('/proc/stat', 'r')
>    #for x in range(0,1): #Reads first line only
>    line = infile.readline()
>    if line.startswith('cpu'): #Check to make sure in 1st line
>    info = line.split()    #Returns a list of the words in the string
>    usr_info = info[1]     #Index the three aspects of CPU Usuage
>    rrdtool.update('usr.rrd','N:12322')           
>    sys_info = info[3]
>    rrdtool.update('sys.rrd','N:12322')
>    idle_info = info[4]
>    rrdtool.update('idle.rrd','N:100000000')      #str() because Python 
> needs to have a string
>        print  usr_info, sys_info, idle_info #Print out so you can see 
> what's happening
>    time.sleep(10)
> 
>    #cur_date=time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime())      
>    rrdtool.graph('example.png',
>        '--start','now-%s'%(60*60),
>        '--end','now',
>        '--width','400',
>        '--height','150',
>    '--base', '1000',
>    '--vertical-label','CPU Usuage',
>    '--title', 'EXAMPLE',
>    'DEF:ds0=usr.rrd:ds0:AVERAGE ',        #Defines all three aspects of 
> the /proc/stat file
>     'DEF:ds1=sys.rrd:ds1:AVERAGE:step=800',
>     'DEF:ds2=idle.rrd:ds2:AVERAGE:step=800',
>        'AREA:ds0#0000FF:"User CPU usuage"',      #Different Labels for 
> each of the three ascp
>        'AREA:ds1#00FF00:"System CPU usuage"',
>        'AREA:ds2#FF0000:"Idle CPU usuage"')   
> 
> 
> (it is all aligned properly) but I get this error message 
> python mult_rrd.py
> 256918 107489 111479877
> Traceback (most recent call last):
>  File "mult_rrd.py", line 58, in ?
>    'AREA:ds2#FF0000:"Idle CPU usuage"')
> rrdtool.error: Cannot parse CF in 'DEF:ds0=usr.rrd:ds0:AVERAGE '
> 
> 
> Emily Chouinard wrote:
> >Here's my graph command
> > cur_date=time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime())      
> > rrdtool.graph('example.png',
> >        '--start','now-%s'%(60*60),
> >        '--end','now',
> >        '--width','400',
> >        '--height','150',
> >       '--base', '1000',
> >       '--vertical-label','CPU Usuage',
> >       '--title', 'EXAMPLE',
> >       'COMMENT',time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime()), 
> >#Give the current date and time on the graph
> >       'DEF:ds0=usr.rrd:ds0:AVERAGE ',        #Defines all three aspects 
> >of the /proc/stat file
> >       'DEF:ds1=sys.rrd:ds1:AVERAGE:step=800',
> >       'DEF:ds2=idle.rrd:ds2:AVERAGE:step=800',
> >       'AREA:ds0#0000FF:"User CPU usuage"',      #Different Labels for 
> >each of the three ascp
> >       'AREA:ds1#00FF00:"System CPU usuage"',
> >       'AREA:ds2#FF0000:"Idle CPU usuage"')   
> >
> >
> >Matthew M. Boedicker wrote:
> >  
> >>What does your graph command look like?
> >>
> >>On Mon, Jun 16, 2008 at 03:13:55PM -0400, Emily Chouinard wrote:
> >>  
> >>    
> >>>Nope, so spaces
> >>>
> >>>Matthew M. Boedicker wrote:
> >>>    
> >>>      
> >>>>Do you still have a space after now in this part?
> >>>>
> >>>>'--start', 'now- %s' % (mins * 60),
> >>>>
> >>>>On Mon, Jun 16, 2008 at 02:56:56PM -0400, Emily Chouinard wrote:
> >>>> 
> >>>>      
> >>>>        
> >>>>>Alright hopefully this is the last thing, but now I'm getting an error 
> >>>>>like this:
> >>>>># python mult_rrd.py
> >>>>>250199 103542 105050751
> >>>>>Traceback (most recent call last):
> >>>>> File "mult_rrd.py", line 62, in ?
> >>>>>   'AREA:ds2#FF0000:"Idle CPU usuage"')
> >>>>>rrdtool.error: start time: There should be number after '-'
> >>>>>
> >>>>>And I have no clue what it means!
> >>>>>
> >>>>>_______________________________________________
> >>>>>rrd-users mailing list
> >>>>>rrd-users at lists.oetiker.ch
> >>>>>https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
> >>>>>   
> >>>>>        
> >>>>>          
> >>>> 
> >>>>      
> >>>>        
> >>  
> >>    
> >
> >_______________________________________________
> >rrd-users mailing list
> >rrd-users at lists.oetiker.ch
> >https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
> >
> >
> >  



More information about the rrd-users mailing list