In Python I am using the RRDTool Python wrapper to store and read values into / from a RRD-Database.
The RRDTool for Python is a wrapper for the C-based source / command-line utility of rrdtool.
After creating a database I want to read out it's header using the python command:
header_info = rrdtool.info('database_file_name.rrd')
which is equal to the command line utility:
rrdtool info database_file_name.rd
and which would print header-infos like that:
filename = "database_file_name.rrd"
rrd_version = 5
...
ds[datasource_identifier_1].index = 0
ds[datasource_identifier_1].type = "GAUGE"
...
ds[datasource_identifier_2].index = 1
ds[datasource_identifier_2].type = "GAUGE"
...
In python the output of the command line tool is wrapped inside a single big dictionary with the following schema:
key: value
"filename" : "database_file_name.rrd"
"ds[datasource_identifier_1].index" : "0"
"ds[datasource_identifier_2].type" : "GAUGE"
I am now trying to figure out how to split up that dictionary so that I could access it like that:
index = dictionary["ds"]["datasource_identifier_1"]["index"]
But I do not have a clue how to do that using python. I would guess this can be done with iteration over the original dictionary and split up those keys using "[","]" and "." as triggers and create a new dictionary then.
How can I do that in Python?