Pushes the current time on the stack.
+B<STEPWIDTH>
+
+The with of the current step in seconds. You can use this to go back from
+rate based presentations to absolute numbers
+
+ CDEF:abs=rate,STEPWIDTH,*,PREF,ADDNAN
+
B<TIME>
Pushes the time the currently processed value was taken at onto the stack.
*/
im->gdes[gdi].step = lcd(steparray);
free(steparray);
+ /* supply the actual stepwith for this run */
+ for (rpi = 0; im->gdes[gdi].rpnp[rpi].op != OP_END; rpi++) {
+ if (im->gdes[gdi].rpnp[rpi].op == OP_STEPWIDTH) {
+ im->gdes[gdi].rpnp[rpi].val = im->gdes[gdi].step;
+ im->gdes[gdi].rpnp[rpi].op = OP_NUMBER;
+ }
+ }
+
if ((im->gdes[gdi].data = (rrd_value_t*)malloc(((im->gdes[gdi].end -
im->gdes[gdi].start)
/ im->gdes[gdi].step)
add_op(OP_ISINF, ISINF)
add_op(OP_NOW, NOW)
add_op(OP_LTIME, LTIME)
+ add_op(OP_STEPWIDTH, STEPWIDTH)
add_op(OP_TIME, TIME)
add_op(OP_ATAN2, ATAN2)
add_op(OP_ATAN, ATAN)
* COMPUTE DS specific. This is less efficient, but creation doesn't
* occur too often. */
for (i = 0; rpnp[i].op != OP_END; i++) {
- if (rpnp[i].op == OP_TIME || rpnp[i].op == OP_LTIME ||
+ if (rpnp[i].op == OP_TIME || rpnp[i].op == OP_LTIME || rpnp[i].op == OP_STEPWIDTH ||
rpnp[i].op == OP_PREV || rpnp[i].op == OP_COUNT ||
rpnp[i].op == OP_TREND || rpnp[i].op == OP_TRENDNAN ||
rpnp[i].op == OP_PREDICT || rpnp[i].op == OP_PREDICTSIGMA ||
rpnp[i].op == OP_PREDICTPERC ) {
rrd_set_error
- ("operators TIME, LTIME, PREV COUNT TREND TRENDNAN PREDICT PREDICTSIGMA PREDICTPERC are not supported with DS COMPUTE");
+ ("operators TIME LTIME STEPWIDTH PREV COUNT TREND TRENDNAN PREDICT PREDICTSIGMA PREDICTPERC are not supported with DS COMPUTE");
free(rpnp);
return;
}
match_op(OP_EXC, EXC)
match_op(OP_POP, POP)
match_op(OP_LTIME, LTIME)
+ match_op(OP_STEPWIDTH, STEPWIDTH)
match_op(OP_LT, LT)
match_op(OP_LE, LE)
match_op(OP_GT, GT)
}
}
break;
+ case OP_STEPWIDTH:
+ rrd_set_error("STEPWIDTH should never show up here... aborting");
+ return -1;
+ break;
case OP_COUNT:
rpnstack->s[++stptr] = (output_idx + 1); /* Note: Counter starts at 1 */
break;
OP_AVG, OP_ABS, OP_ADDNAN,
OP_MINNAN, OP_MAXNAN,
OP_MEDIAN, OP_PREDICTPERC,
- OP_DEPTH, OP_COPY, OP_ROLL, OP_INDEX
+ OP_DEPTH, OP_COPY, OP_ROLL, OP_INDEX, OP_STEPWIDTH
};
typedef struct rpnp_t {
long ds_cnt; /* data source count for data pointer */
long step; /* time step for OP_VAR das */
void *extra; /* some extra data for longer setups */
- void (*free_extra)(void *); /* function pointer used to free extra
+ void (*free_extra)(void *); /* function pointer used to free extra
* - NULL for "simple" free(extra); */
} rpnp_t;
TESTS = modify1 modify2 modify3 modify4 modify5 \
- tune1 tune2 rpn1 \
+ tune1 tune2 rpn1 rpn2 \
rrdcreate \
dump-restore \
create-with-source-1 create-with-source-2 create-with-source-3 \
rrdcreate \
tune1-testa-mod1.dump tune1-testa-mod2.dump tune1-testorg.dump \
tune2-testa-mod1.dump tune2-testorg.dump \
- valgrind-supressions dcounter1 dcounter1.output vformatter1
+ valgrind-supressions dcounter1 dcounter1.output vformatter1 rpn2.output
# NB: AM_TESTS_ENVIRONMENT not available until automake 1.12
TESTS_ENVIRONMENT = \
BASEDIR=${abs_srcdir} ; export BASEDIR ; \
DIFF9=seddif
function seddif {
- sed -e "s/\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\)[0-9]\(e[+-][0-9]\)/\1\2/g" | $DIFF $@
+ perl -p -e 's/([-+]?\d\.\d+e[-+]\d+)/sprintf("%0.10e",$1)/ge' | $DIFF $@
}
#
--- /dev/null
+#!/bin/bash
+
+. $(dirname $0)/functions
+
+RRD=rpn2.rrd
+
+$RRDTOOL create $RRD --start 920804400 DS:speed:DCOUNTER:600:U:U RRA:AVERAGE:0.5:1:24 RRA:AVERAGE:0.5:6:10
+report "create"
+$RRDTOOL update $RRD 920804700:10 920805000:20 920805300:30
+$RRDTOOL update $RRD 920805600:40 920805900:50 920806200:60
+$RRDTOOL update $RRD 920806500:70 920806800:80 920807100:90
+$RRDTOOL update $RRD 920807400:100 920807700:110 920808000:120
+$RRDTOOL update $RRD 920808300:130 920808600:140 920808900:150
+report "update"
+$RRDTOOL xport \
+ --json \
+ --start 920804400 --end 920808000 \
+ DEF:myspeed=$RRD:speed:AVERAGE \
+ CDEF:total=myspeed,STEPWIDTH,*,PREV,ADDNAN \
+ XPORT:myspeed:myspeed XPORT:total:total |\
+ $DIFF9 - $BASEDIR/rpn2.output
+report "xport"
--- /dev/null
+{ "about": "RRDtool graph JSON output",
+ "meta": {
+ "start": 920804400,
+ "end": 920808000,
+ "step": 300,
+ "legend": [
+ "myspeed",
+ "total"
+ ]
+ },
+ "data": [
+ [ null, null ],
+ [ 3.3333333333e-02, 1.0000000000e+01 ],
+ [ 3.3333333333e-02, 2.0000000000e+01 ],
+ [ 3.3333333333e-02, 3.0000000000e+01 ],
+ [ 3.3333333333e-02, 4.0000000000e+01 ],
+ [ 3.3333333333e-02, 5.0000000000e+01 ],
+ [ 3.3333333333e-02, 6.0000000000e+01 ],
+ [ 3.3333333333e-02, 7.0000000000e+01 ],
+ [ 3.3333333333e-02, 8.0000000000e+01 ],
+ [ 3.3333333333e-02, 9.0000000000e+01 ],
+ [ 3.3333333333e-02, 1.0000000000e+02 ],
+ [ 3.3333333333e-02, 1.1000000000e+02 ]
+ ]
+}