[rrd-users] Please Help

Ruttenberg, Tanya Tanya.Ruttenberg at ssa.gov
Wed Jun 18 14:58:03 CEST 2008


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



More information about the rrd-users mailing list