Hermann Lauer wrote: > Hello all, > > I noticed that in the python bindings of rrdtool-1.3.99909060808 > the rrdtool.info() function the datasources in the flat hash dict returned > are partly indexed with the datasource name and partly indexed with numbers > (see example below). Besides beeing somehow inconsistent a problem arises: > > How to find out the ordering of datasources to > find the datasource name for the rra[].cdp_prep[] values (or for > using rrdtool.update('N:...:...:...')) without knowing the order > of the datasources. > > How is this handled in other bindings (e.g. perl) ? > > Please tell me if I missed something obvious, > greetings > Hermann > > >>>> import rrdtool >>>> rrdtool.__version__ > '$Revision: 1.14 $' >>>> rrdtool.create('/tmp/test.rrd','--step','20','DS:ds2:GAUGE:300:0:100','DS:x1:GAUGE:300:0:100','DS:ds0:GAUGE:300:-5:100','RRA:AVERAGE:0.5:3:2') >>>> rrdtool.info('/tmp/test.rrd') > {'rra[0].cdp_prep[0].value': None, 'ds[ds2].min': 0.0, 'ds[ds0].min': -5.0, > 'rra[0].cdp_prep[1].unknown_datapoints': 1L, 'ds[ds2].value': 0.0, > 'ds[ds2].last_ds': 'U', 'ds[x1].max': 100.0, 'ds[ds2].unknown_sec': 5L, > 'ds[ds0].value': 0.0, 'ds[ds0].unknown_sec': 5L, 'ds[ds0].max': 100.0, > 'ds[ds2].max': 100.0, 'rrd_version': '0003', 'filename': '/tmp/test.rrd', > 'last_update': 1256646805L, 'rra[0].cf': 'AVERAGE', 'ds[x1].type': 'GAUGE', > 'rra[0].pdp_per_row': 3L, 'rra[0].cur_row': 1L, 'header_size': 1172L, > 'ds[ds0].last_ds': 'U', 'step': 20L, 'rra[0].cdp_prep[0].unknown_datapoints': > 1L, 'ds[ds0].type': 'GAUGE', 'rra[0].cdp_prep[2].value': None, > 'ds[x1].last_ds': 'U', 'ds[ds2].minimal_heartbeat': 300L, 'rra[0].rows': 2L, > 'ds[x1].min': 0.0, 'ds[ds0].minimal_heartbeat': 300L, 'ds[x1].unknown_sec': > 5L, 'rra[0].xff': 0.5, 'rra[0].cdp_prep[2].unknown_datapoints': 1L, > 'ds[ds2].type': 'GAUGE', 'rra[0].cdp_prep[1].value': None, 'ds[x1].value': > 0.0, 'ds[x1].minimal_heartbeat': 300L} >
Hey Herman, It's important to note that both the keys and the values in that data tructure are strings -- don't let the form trick you :-) As such, you can simply sort them like this: sorted(d.items()) And that will give you a list of (key, value) tuples that you can iterate through and check. Since these are string values, you have to do stringy things... PyRRD does provide non-string keys in its data structures, so you have more flexibility. If you want to email the PyRRD list, we can talk about the type of data access you'd like to have... adding features like this to PyRRD is probably much easier than doing so to the RRDTool Python bindings. Thanks, d _______________________________________________ rrd-developers mailing list rrd-developers@lists.oetiker.ch https://lists.oetiker.ch/cgi-bin/listinfo/rrd-developers