Sep 17, 2011 9:14 PM
getRRDValues when datasource name contains a space
-
Like (0)
So I've been playing around with creating some time based reports as outlined in message/32004#32004 and message/60977#60977. I've managed to get it work, however I ran into a bump with a certain set of datasources I want to include. I have data sources that contain spaces in the names.
So take something like 'ServiceName HTTP totalServicedSum_totalServicedSum.rrd'
As a simple example I have:
print d.getRRDValues(['ServiceName HTTP totalServicedSum'],
start=startDate, end=endDate, function=how)
It results in a traceback:
ERROR:RenderServer:Failed while generating summary
Traceback (most recent call last):
File "/opt/zenoss/Products/ZenRRD/RenderServer.py", line 346, in summary
values = rrdtool.graph(*gopts)[2]
error: Cannot parse vname from 'DEF:ServiceName HTTP totalServicedSum_r=/opt/zenoss/perf/Devices/DeviceName/ServiceName HTTP totalServicedSum_totalServicedSum.rrd:ds0:AVERAGE'
WARNING:RenderServer:/dev/null DEF:ServiceName HTTP totalServicedSum_r=/opt/zenoss/perf/Devices/DeviceName/ServiceName HTTP totalServicedSum_totalServicedSum.rrd:ds0:AVERAGE CDEF:ServiceName HTTP totalServicedSum_c=ServiceName HTTP totalServicedSum_r VDEF:ServiceName HTTP totalServicedSum=ServiceName HTTP totalServicedSum_c,MAXIMUM PRINT:ServiceName HTTP totalServicedSum:%.2lf --start=1316203200 --end=1316206800
ERROR:zen.RRDView:Cannot parse vname from 'DEF:ServiceName HTTP totalServicedSum_r=/opt/zenoss/perf/Devices/DeviceName/ServiceName HTTP totalServicedSum_totalServicedSum.rrd:ds0:AVERAGE'
Traceback (most recent call last):
File "/opt/zenoss/Products/ZenModel/RRDView.py", line 167, in getRRDValues
vals = perfServer.performanceCustomSummary(gopts)
File "/opt/zenoss/Products/ZenModel/PerformanceConf.py", line 400, in performanceCustomSummary
return server.summary(gopts)
File "/opt/zenoss/Products/ZenRRD/RenderServer.py", line 346, in summary
values = rrdtool.graph(*gopts)[2]
error: Cannot parse vname from 'DEF:ServiceName HTTP totalServicedSum_r=/opt/zenoss/perf/Devices/DeviceName/ServiceName HTTP totalServicedSum_totalServicedSum.rrd:ds0:AVERAGE'
Based on http://oss.oetiker.ch/rrdtool/doc/rrdgraph_data.en.html
Variable names (vname) must be made up strings of the following characters
A-Z, a-z, 0-9, -,_
and a maximum length of 255 characters.
So it would appear that when its trying to generate the VDEF name, it contains illegal characters in the form of the spaces.
Anyone have any ideas, on how I could get this to work?
So I managed to get this to work on a test system, but I'm fairly certain my approach would be frowned upon, and probably not the greastest idea on my production system.
I've hacked an updated to RRDView.py
Starting on line 155 of $ZENHOME/Products/ZenModel/RRDView.py
From:
gopts.append("DEF:%s_r=%s:ds0:AVERAGE" % (dsname,filename))
gopts.append("CDEF:%s_c=%s_r%s" % (dsname,dsname,rpn))
gopts.append("VDEF:%s=%s_c,%s" % (dsname,dsname,function))
gopts.append("PRINT:%s:%s" % (dsname, format))
To:
gopts.append("DEF:%s_r=%s:ds0:AVERAGE" % (dsname.replace(" ","_"),filename))
gopts.append("CDEF:%s_c=%s_r%s" % (dsname.replace(" ","_"),dsname.replace(" ","_"),rpn))
gopts.append("VDEF:%s=%s_c,%s" % (dsname.replace(" ","_"),dsname.replace(" ","_"),function))
gopts.append("PRINT:%s:%s" % (dsname.replace(" ","_"), format))
After doing this, I can seem to fetch data from data sources that have spaces in the name. I have no idea how much other damage it might do though.
So I managed to get this working thanks to some guidance from rmatte in IRC, via a slightly different approach. Pasting a small sample in case it helps someone else, or myself when i need to do this again.. Obvious variable, resolution, cfunc replaces apply as needed
dps_to_collect = ['Service HTTP totalServicedSum_totalServicedSum']
for d in dmd.Devices.getOrganizer("/").getSubDevices():
for dp in d.getRRDDataPoints():
if dp.name() in dps_to_collect:
print d.fetchRRDValue(dp.name(), "MAX", 3600, start=slot_start, end=slot_end)
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||