[rrd-users] Still trying to create a graph from multiple sources in RRDtool
Emily Chouinard
cousin17 at msu.edu
Mon Jun 16 16:12:09 CEST 2008
Alright so I've tried following everyone advice, thanks by the way, and
I've got this far and now I can't get the rrdcreate to work when I run
my code
import rrdtool
import os
import time
interval = 5
interval = str(interval)
interval_mins = float(interval) / 60
heartbeat = str(int(interval) * 2)
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] # These 3 index the specific CPU usages
sys_info = info[3]
idle_info = info[4]
print usr_info, sys_info, idle_info #Print out so you can see
what's happening
rrdtool.create (usr.rrd,
' DS:usr_info:COUNTER: %s:U:U % heartbeat',
' RRA:AVERAGE:0.5:1:', str(int(4000 / interval_mins)),
' RRA:AVERAGE:0.5:', str(int(30 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(120 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(1440 / interval_mins)), ':800')
rrdtool.create (sys.rrd,
' DS:sys_info:COUNTER: %s:U:U % heartbeat',
' RRA:AVERAGE:0.5:1:', str(int(4000 / interval_mins)),
' RRA:AVERAGE:0.5:', str(int(30 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(120 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(1440 / interval_mins)), ':800')
rrdtool.create (idle.rrd,
' DS:idle_info:COUNTER: %s:U:U % heartbeat',
' RRA:AVERAGE:0.5:1:', str(int(4000 / interval_mins)),
' RRA:AVERAGE:0.5:', str(int(30 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(120 / interval_mins)), ':800',
' RRA:AVERAGE:0.5:', str(int(1440 / interval_mins)), ':800')
rrdtool.update (usr.rrd, 12322)
rrdtool.update (sys.rrd,12322)
rrdtool.update (idle.rrd,12322)
rrdtool.graph(test.rrd.png,
' --width','400',
' --height', '150',
' --start', 'now- %s' % (mins * 60),
' --end', 'now',
' --vertical-label', 'CPU Usuage',
' --title', 'EXAMPLE',
' COMMENT',time.strftime('%m/%d/%Y %H\:%M\:%S', time.localtime()),
' DEF:ds0= usr.rrd:ds0:AVERAGE ',
' DEF:ds1 = sys.rrd:ds1:AVERAGE:step=800',
' DEF:ds2= idle.rrd:ds2:AVERAGE:step=800',
' AREA:ds0#0000FF:"User CPU usuage"',
' LINE1: ds1#00FF00:"System CPU usuage" ',
' LINE1: ds2#FF0000:"Idle CPU usuage" ')
I get this error # python mult_rrd.py
246176 97876 103312642
Traceback (most recent call last):
File "mult_rrd.py", line 21, in ?
rrdtool.create (usr.rrd,
NameError: name 'usr' is not defined
And this is where I am stuck, I'm not sure why it is giving me this
error, I thought the rrdtool.create defined the file usr.rrd if not let
me know what I should do to fix it, also let me know if you see other
things gone wrong in here (maybe take a peek at my rrdtool.update
commands), thanks!
Emily
Fabien Wernli wrote:
> On Fri, Jun 13, 2008 at 11:40:28AM -0400, Matthew M. Boedicker wrote:
>
>> For CPU usage you might want to try GAUGE instead of COUNTER. For graphing
>>
>
> no you don't: Emily is pulling /proc/stat values which _are_ counters
> using GAUGE would produce endlessly growing values
>
> _______________________________________________
> 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