Showing posts with label pyrrd. Show all posts
Showing posts with label pyrrd. Show all posts

Thursday, March 26, 2009

New PyRRD Release: 0.0.7


Version 0.1 is nearing as the 7th release made it out the door tonight. The latest features include RRD info/fetch methods, a simple RRD object mapper, and the ability to dump files programmatically. Various bug fixes have been applied, thanks to feedback and patches from the community. In particular, Aaron Westendorf of Agora Games, Leem Smit, and nasvos.

You can download from PyPI (or use setuptools to install it) at the expected location:
http://pypi.python.org/pypi/PyRRD/

Note that the the PyPI page has a quick run-down on the basic features and how to use them.

The next feature to be implemented has already been planned out (it's just a matter of sitting down and writing the code now): adding support for the Python bindings. If this is important to you, be sure to star the issue in the bug tracker:
http://code.google.com/p/pyrrd/issues/detail?id=5&can=1



Sunday, January 22, 2006

PyRRD

Keeping alive the whimsy that had me pick webXcreta back up and get it working, I have returned to another old project: PyRRD. I had started work on this a couple years ago while adding functionality to CoyoteMonitoring, but had to put it on hold due to budget constraints.

In a nutshell, PyRRD is an object oriented interface (wrapper) for the RRDTool. python bindings (rrdtool). Where when using rrdtool you might see something like this:


rrdtool.graph(path,
'--imgformat', 'PNG',
'--width', '540',
'--height', '100',
'--start', "-%i" % YEAR,
'--end', "-1",
'--vertical-label', 'Downloads/Day',
'--title', 'Annual downloads',
'--lower-limit', '0',
'DEF:downloads=downloads.rrd:downloads:AVERAGE',
'AREA:downloads#990033:Downloads')

with PyRRD, you have this:


def1 = graph.GraphDefinition(vname='downloads', rrdfile='downloads.rrd',
ds_name='downloads', cdef='AVERAGE')

area1 = graph.GraphArea(value=def1.vname, color="#990033',
legend='Downloads', stack=True)

g = graph.Graph(path, imgformat='PNG', width=540, height=100,
start="-%i" % YEAR, end=-1, vertical_label='Downloads/Day',
title='Annual downloads', lower_limit=0)
g.data.append(def1)
g.data.append(area1)
g.write()

Optionally, you can use attributes (in combination with or to exclusion of parameters):


def1 = graph.GraphDefinition()
def1.vname='downloads'
def1.rrdfile='downloads.rrd'
def1.ds_name='downloads'
def1.cdef='AVERAGE'

And there are aliases for the classes so that you may use the more familiar names from RRDTool:


def = graph.DEF(vname='downloads', rrdfile='downloads.rrd',
ds_name='downloads', cdef='AVERAGE')
area = graph.AREA(value=def.vname, color="#990033', stack=True)

Not only is this object approach more aesthetically pleasing to me, but the interface is much easier to manipulate programmatically. That's insanely important to me because of how I use RRDTool in other projects. I do a great deal of data manipulation and graph representation, and using the regular RRDTool python bindings is simply a show-stopper.

Another neat thing about this wrapper is that the classes use __repr__() to present the complete value of the object as an RRDTool-ready string. This means that you are not limited to using the python bindings, but can also freely and easily interact with the command line tools, configuration values in files, etc.

When I've got a first release ready to go, I'll push it up to CheeseShop and post a notice here on the blog.

Update: PyRRD is now available in Debian and Ubuntu.