[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())
rrdtool.create('usr.rrd',
'--start', 'N'
'--step', '60',
'DS:usr_info:DERIVE:900:0:1000000',
'RRA:AVERAGE:0.5:1:9600',
'RRA:AVERAGE:0.5:4:9600',
'RRA:AVERAGE:0.5:24:6000')
rrdtool.create('sys.rrd',
'--start', 'N'
'--step', '60',
'DS:sys_info:DERIVE:00:0:1000000',
'RRA:AVERAGE:0.5:1:9600',
'RRA:AVERAGE:0.5:4:9600',
'RRA:AVERAGE:0.5:24:6000')
rrdtool.create('idle.rrd',
'--start', 'N'
'--step', '60',
'DS:idle_info:DERIVE:00:0:1000000',
'RRA:AVERAGE:0.5:1:9600',
'RRA:AVERAGE:0.5:4:9600',
'RRA:AVERAGE:0.5:24:6000')
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
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 + '')
time.sleep(100)
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