[rrd-users] Please Help

Emily Chouinard cousin17 at msu.edu
Wed Jun 18 16:01:36 CEST 2008


In order to get familiar with RRDtool and the python binding (before I 
start work on Cacti) my supervisor asked me to create graphs that 
display the CPU usuage from the /proc/stat file, its just an example to 
really learn how to use RRDtool and everything it has to offer

I am not trying to re-invent the wheel this is a very simple problem its 
just there is something off about my code, I can't seem to figure it 
out, do my create and update files look alright, are there any 
discrepancies there?

Anyone, please help I've been working on this for 3 days my entire 
source code for this project it up so please help me, I'm stuck and I 
can't figure it out.

Ruttenberg, Tanya wrote:
> Not replying to the list.
>
> Isn't there already some package out there that does what you want?  I
> have a feeling you are trying to re-invent the wheel.  What is your
> ultimate goal here?  
>
> Have you checked out BigBrother or nagios or zenoss?  If you are just
> trying to collect process stats -- surely that has been done.  Or can be
> done using cricket or torrus or one of those packages.  You can
> configure cricket to run almost any script you want.  Torrus is sort of
> the same, though harder to hit the ground running with it.
>
> I think your time might be better spent leveraging what other people
> have done.
>
> TDR
>
> -----Original Message-----
> From: Emily Chouinard [mailto:cousin17 at msu.edu] 
> Sent: Wednesday, June 18, 2008 9:51 AM
> To: Ruttenberg, Tanya
> Subject: Re: [rrd-users] Please Help
>
> If you look at my code, my update function is within an while True and
> if loop so I'm not sure how often it gets updated, wouldn't it be
> everytime those statements get executed?
> Ruttenberg, Tanya wrote:
>   
>> Have you updated more than once?  Set up a simple script and a cron 
>> job to update it every 5 minutes (or whatever your step is).  Let it 
>> update for an hour.  Then take another look.
>>
>> -----Original Message-----
>> From: Emily Chouinard [mailto:cousin17 at msu.edu]
>> Sent: Wednesday, June 18, 2008 9:37 AM
>> To: Ruttenberg, Tanya
>> Cc: rrd-users at lists.oetiker.ch
>> Subject: Re: [rrd-users] Please Help
>>
>> If I rrdtool fetch usr.rrd AVERAGE all my values are nan, but how do I
>>     
>
>   
>> fix that?
>>
>>
>> Emily Chouinard wrote:
>>   
>>     
>>> I get this error
>>> rrdtool fetch usr.rrd LAST
>>> ERROR: the RRD does not contain an RRA matching the chosen CF and my 
>>> rrdtool info usr.rrd looks the same even though I let the program run
>>>       
>
>   
>>> for quite awhile, so my update function not be in the if statement, 
>>> is there something wrong with its placement?
>>>
>>>
>>> Emily Chouinard wrote:
>>>     
>>>       
>>>> Well there is nothing in those files except crazy symbols so I think
>>>>         
>
>   
>>>> there is something wrong with my update function, I wasn't sure how 
>>>> to create it,
>>>>
>>>>  rrdtool.update('idle.rrd','N:112431249')
>>>>  rrdtool.update('sys.rrd','N:108704')
>>>> rrdtool.update('usr.rrd','N:259845')
>>>>
>>>> which not in python would look like rrdtool update usr.rrd
>>>>       
>>>>         
>> N:112431249
>>   
>>     
>>>>  and I'm not sure exactly what was suppose to go in this command so 
>>>> I'm sure its wrong but I don't know how to fix it.
>>>>
>>>>
>>>> Ruttenberg, Tanya wrote:
>>>>  
>>>>       
>>>>         
>>>>> A couple of things look odd to me, but it could just be because you
>>>>>         
>>>>>           
>> ran
>>   
>>     
>>>>> your update only once. You need to do it a few times in order to 
>>>>> see data in your graph. RRDtool needs more than 1 datapoint to 
>>>>> calculate
>>>>>         
>>>>>           
>> a
>>   
>>     
>>>>> rate.
>>>>>
>>>>> Try a few more rrdtool commands on the command line to see whether 
>>>>> there is something in your rrdfile.  Rrdtool fetch is nice and 
>>>>> simple. Try something like:
>>>>>
>>>>> rrdtool fetch rrdfile.rrd LAST
>>>>>
>>>>> If you see a lot of numbers in there -- as opposed to a lot of 
>>>>> NaN's then perhaps it is your graph.
>>>>>
>>>>> -----Original Message-----
>>>>> From: Emily Chouinard [mailto:cousin17 at msu.edu] Sent: Wednesday, 
>>>>> June 18, 2008 9:04 AM
>>>>> To: Ruttenberg, Tanya
>>>>> Cc: rrd-users at lists.oetiker.ch
>>>>> Subject: Re: [rrd-users] Please Help
>>>>>
>>>>> Ruttenberg, Tanya wrote:
>>>>>      
>>>>>         
>>>>>           
>>>>>> What do you see when you do "rrdtool info filename"?  You should 
>>>>>> see some indication that data has gone into it, under last_ds, 
>>>>>> min,
>>>>>>           
>>>>>>             
>>   
>>     
>>>>>> max, or value. Like this:
>>>>>>
>>>>>> ds[ifhcinoctets].type = "COUNTER"
>>>>>> ds[ifhcinoctets].minimal_heartbeat = 1800 =>ds[ifhcinoctets].min =
>>>>>>             
>
>   
>>>>>> 0.0000000000e+00 =>ds[ifhcinoctets].max = 1.2500000000e+08 
>>>>>> =>ds[ifhcinoctets].last_ds = "3213871804"
>>>>>> =>ds[ifhcinoctets].value = 8.3618110390e+02 
>>>>>> ds[ifhcinoctets].unknown_sec = 0 ds[ifhcoutoctets].type =
>>>>>>             
> "COUNTER"
>   
>>>>>> ds[ifhcoutoctets].minimal_heartbeat = 1800 ds[ifhcoutoctets].min =
>>>>>>             
>
>   
>>>>>> 0.0000000000e+00 ds[ifhcoutoctets].max = 1.2500000000e+08 
>>>>>> ds[ifhcoutoctets].last_ds = "417872513"
>>>>>> ds[ifhcoutoctets].value = 9.3979997545e+01 
>>>>>> ds[ifhcoutoctets].unknown_sec = 0
>>>>>>
>>>>>> I suggest you download and use drraw to take a look at what is in
>>>>>>           
>>>>>>             
>> that
>>   
>>     
>>>>>>           
>>>>>>           
>>>>>>             
>>>>>      
>>>>>         
>>>>>           
>>>>>> file. This eliminates possible user error in your graph creation 
>>>>>> AND it will give you the exact rrdfile graph syntax you can use to
>>>>>>             
>
>   
>>>>>> create the graph.
>>>>>>
>>>>>> Good luck.
>>>>>>
>>>>>> Tanya Ruttenberg
>>>>>> SMC/OND Administrator for DNE
>>>>>> 410-965-9605
>>>>>>
>>>>>>
>>>>>> -----Original Message-----
>>>>>> From: rrd-users-bounces at lists.oetiker.ch
>>>>>> [mailto:rrd-users-bounces at lists.oetiker.ch] On Behalf Of Emily 
>>>>>> Chouinard
>>>>>> Sent: Wednesday, June 18, 2008 8:52 AM
>>>>>> To: rrd-users at lists.oetiker.ch
>>>>>> Subject: [rrd-users] Please Help
>>>>>>
>>>>>> I've spent a whole day looking at my code and trying to figure out
>>>>>>           
>>>>>>             
>> why
>>   
>>     
>>>>>>           
>>>>>>           
>>>>>>             
>>>>>      
>>>>>         
>>>>>           
>>>>>> nothing is being graphed but I can't seem to figure out it, will 
>>>>>> someone please help me? My code is below and it seems to work, but
>>>>>>             
>
>   
>>>>>> I don't know if its the update or graph function thats not 
>>>>>> working,
>>>>>>           
>>>>>>             
>>   
>>     
>>>>>> when
>>>>>>           
>>>>>>           
>>>>>>             
>>>>>      
>>>>>         
>>>>>           
>>>>>> I ls -l all my rrd files and my png seem updated but when I 
>>>>>> display
>>>>>>           
>>>>>>             
>> my
>>   
>>     
>>>>>>           
>>>>>>           
>>>>>>             
>>>>>      
>>>>>         
>>>>>           
>>>>>> png it shows the legend and stuff but no values are actually 
>>>>>> graphed. So any help would be really appreciated.
>>>>>>    Thanks,
>>>>>>             Emily
>>>>>> import rrdtool
>>>>>> import os
>>>>>> import time
>>>>>>
>>>>>>
>>>>>> interval = 10
>>>>>> interval = str(interval)
>>>>>> interval_mins = float(interval) / 60 heartbeat = str(int(interval)
>>>>>>             
>
>   
>>>>>> * 2) cur_date = time.strftime('%m/%d/%Y %H\:%M\:%S', 
>>>>>> time.localtime())
>>>>>>
>>>>>> 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
>>>>>>     sys_info = info[3]
>>>>>>     idle_info = info[4]
>>>>>>      #str() because Python needs to have a string
>>>>>>         print  usr_info, sys_info, idle_info #Print out so you can
>>>>>>           
>>>>>>             
>> see
>>   
>>     
>>>>>>           
>>>>>>           
>>>>>>             
>>>>>      
>>>>>         
>>>>>           
>>>>>> what's happening
>>>>>>     rrdtool.update('idle.rrd','N:112431249')
>>>>>>     rrdtool.update('sys.rrd','N:108704')
>>>>>>     rrdtool.update('usr.rrd','N:259845')
>>>>>>     rrdtool.graph('example.png',
>>>>>>         'DEF:usr_info=usr.rrd:usr_info:AVERAGE',        #Defines 
>>>>>> all three aspects of the /proc/stat file
>>>>>>         'AREA:usr_info#0000FF:"User CPU usuage"',
>>>>>>         'DEF:sys_info=sys.rrd:sys_info:AVERAGE:step=800',
>>>>>>         'AREA:sys_info#00FF00:"System CPU usuage":STACK',
>>>>>>         'DEF:idle_info=idle.rrd:idle_info:AVERAGE:step=800',
>>>>>> #Different Labels for each of the three ascp
>>>>>>             'AREA:idle_info#FF0000:"Idle CPU usuage":STACK',
>>>>>>         '--start','now-%s'%(30*60),
>>>>>>         '--end','now',
>>>>>>         '--width','500',
>>>>>>         '--height','250',
>>>>>>         '--base', '1000',
>>>>>>         '--vertical-label','CPU Usuage',
>>>>>>         '--title', 'EXAMPLE',
>>>>>>         'COMMENT:' + cur_date + '')       infile.close()       
>>>>>> time.sleep(10)
>>>>>> _______________________________________________
>>>>>> rrd-users mailing list
>>>>>> rrd-users at lists.oetiker.ch
>>>>>> https://lists.oetiker.ch/cgi-bin/listinfo/rrd-users
>>>>>>
>>>>>>
>>>>>>             
>>>>>>           
>>>>>>             
>>>>> This is what I see, but I'm not sure what it all means, I am very 
>>>>> new to rrdtool
>>>>>
>>>>> filename = "usr.rrd"
>>>>> rrd_version = "0003"
>>>>> step = 300
>>>>> last_update = 1213793679
>>>>> ds[usr_info].type = "COUNTER"
>>>>> ds[usr_info].minimal_heartbeat = 20 ds[usr_info].min = NaN 
>>>>> ds[usr_info].max = NaN ds[usr_info].last_ds = "259845"
>>>>> ds[usr_info].value = 0.0000000000e+00 ds[usr_info].unknown_sec = 0 
>>>>> rra[0].cf = "AVERAGE"
>>>>> rra[0].rows = 24000
>>>>> rra[0].pdp_per_row = 1
>>>>> rra[0].xff = 5.0000000000e-01
>>>>> rra[0].cdp_prep[0].value = NaN
>>>>> rra[0].cdp_prep[0].unknown_datapoints = 0 rra[1].cf = "AVERAGE"
>>>>> rra[1].rows = 800
>>>>> rra[1].pdp_per_row = 180
>>>>> rra[1].xff = 5.0000000000e-01
>>>>> rra[1].cdp_prep[0].value = 0.0000000000e+00 
>>>>> rra[1].cdp_prep[0].unknown_datapoints = 117 rra[2].cf = "AVERAGE"
>>>>> rra[2].rows = 800
>>>>> rra[2].pdp_per_row = 720
>>>>> rra[2].xff = 5.0000000000e-01
>>>>> rra[2].cdp_prep[0].value = 0.0000000000e+00 
>>>>> rra[2].cdp_prep[0].unknown_datapoints = 297 rra[3].cf = "AVERAGE"
>>>>> rra[3].rows = 800
>>>>> rra[3].pdp_per_row = 8640
>>>>> rra[3].xff = 5.0000000000e-01
>>>>> rra[3].cdp_prep[0].value = 0.0000000000e+00 
>>>>> rra[3].cdp_prep[0].unknown_datapoints = 2457
>>>>>
>>>>>
>>>>>       
>>>>>         
>>>>>           
>>>> _______________________________________________
>>>> 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