From 484393e9a4d45b008cf7cc7a0eaa30b7e3f106e9 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@1410 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/bindings/python/rrdtoolmodule.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/program/bindings/python/rrdtoolmodule.c b/program/bindings/python/rrdtoolmodule.c index 6f5b36c5..497059d2 100644 --- a/program/bindings/python/rrdtoolmodule.c +++ b/program/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