[rrd-users] rrdtool update not working

Emily Chouinard cousin17 at msu.edu
Wed Jun 18 20:48:47 CEST 2008

Alright well I've been posting all day and my source code is up under 
other forums but I am opening the /proc/stat file and taking data on cpu 
usage for user, system and idle and I want to graph these in comparison 
of each other so I've created three rrds based on the user, system and 
idle cpu usage, I am running the python binding for rrdtool but the 
problem is with my update, it keeps returning NaN values and I can't 
seem to figure out why.It should be returning the DERIVE values for usr, 
sys and idle. When I use rrdtool fetch I get NaNs and don't know why. 
Here is my source code, thanks for any help.
import rrdtool
import os
import time

interval = 10
cur_date = time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime())
     '--start', 'N'
     '--step', '60',

     '--start', 'N'
     '--step', '60',

     '--start', 'N'
    '--step', '60',

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]
    infile.close()      #str() because Python needs to have a string
    print  usr_info, sys_info, idle_info #Print out so you can see 
what's happening
            'DEF:usr_info=usr.rrd:usr_info:AVERAGE',        #Defines all 
three aspects of the /proc/stat file
            'AREA:usr_info#0000FF:"User CPU usuage"',
            'AREA:sys_info#00FF00:"System CPU usuage":STACK',
#Different Labels for each of the three ascp
            'AREA:idle_info#FF0000:"Idle CPU usuage":STACK',
            '--base', '1000',
            '--vertical-label','CPU Usuage',
            '--title', 'EXAMPLE',
            'COMMENT:' + cur_date + '')   

Simon Hobson wrote:
> Emily Chouinard wrote:
>> So I can't seem to figure out why my update doesn't work, its returns
>> only NaN values and I can't seem to figure out why, everything looks
>> okay and my program runs but its not updating and I have no idea how to
>> fix it. Any one have any suggestions? Or what errors to looks for, I can
>> send you my code if you would like to help me, please I just need to
>> finish this project, my supervisor gave it to me as research and I
>> haven't been able to finish it, any help would be greatly appreciated!
> How can anyone ehlp you - we know NOTHING about what you are doing 
> other than "something involving rrdtool" !
> What command did you use to create the rrd file ?
> What update commands does your program use ?
> What do you expect to be returned ?
> What is actually returned (by rrdtool fetch) ?
> _______________________________________________
> 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