From de9959c7addb65449483bcd54919e9a5e16f5bfc Mon Sep 17 00:00:00 2001 From: oetiker Date: Sun, 8 Jun 2008 16:25:45 +0000 Subject: [PATCH] The python bindings do not currently support retrieval of the rpn expression in COMPUTE data sources. Attached is a patch that duplicates functionality from rrd_info.c to expose the correct data source attributes via the python binding. It: * exposes the rpn expression in the 'cdef' element for DST_CDEF data source types * exposes the heartbeat, min, and max only to the other data source types git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1410 a5681a0c-68f1-0310-ab6d-d61299d08faa --- bindings/python/rrdtoolmodule.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/bindings/python/rrdtoolmodule.c b/bindings/python/rrdtoolmodule.c index 6f5b36c..497059d 100644 --- a/bindings/python/rrdtoolmodule.c +++ b/bindings/python/rrdtoolmodule.c @@ -42,6 +42,7 @@ static const char *__version__ = "$Revision: 1.14 $"; #include "Python.h" #include "rrd.h" #include "rrd_extra.h" +#include "rrd_rpncalc.h" static PyObject *ErrorObject; extern int optind; @@ -445,9 +446,22 @@ PyRRD_info(PyObject UNUSED(*self), PyObject *args) DICTSET_STR(d, "ds_name", rrd.ds_def[i].ds_nam); DICTSET_STR(d, "type", rrd.ds_def[i].dst); - DICTSET_CNT(d, "minimal_heartbeat", rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); - DICTSET_VAL(d, "min", rrd.ds_def[i].par[DS_min_val].u_val); - DICTSET_VAL(d, "max", rrd.ds_def[i].par[DS_max_val].u_val); + + switch(dst_conv(rrd.ds_def[i].dst)) { + case DST_CDEF: + { + char *buffer = NULL; + rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]), + rrd.ds_def, &buffer); + DICTSET_STR(d, "cdef", buffer); + } + break; + default: + DICTSET_CNT(d, "minimal_heartbeat", rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); + DICTSET_VAL(d, "min", rrd.ds_def[i].par[DS_min_val].u_val); + DICTSET_VAL(d, "max", rrd.ds_def[i].par[DS_max_val].u_val); + break; + } DICTSET_STR(d, "last_ds", rrd.pdp_prep[i].last_ds); DICTSET_VAL(d, "value", rrd.pdp_prep[i].scratch[PDP_val].u_val); DICTSET_CNT(d, "unknown_sec", rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); -- 2.30.2