data source from other data sources in the same <RRD>. It is similar to defining
a B<CDEF> argument for the graph command. Please refer to that manual page
for a list and description of RPN operations supported. For
-COMPUTE data sources, the following RPN operations are not supported: PREV,
+COMPUTE data sources, the following RPN operations are not supported: COUNT, PREV,
TIME, and LTIME. In addition, in defining the RPN expression, the COMPUTE
data source may only refer to the names of data source listed previously
in the create command. This is similar to the restriction that B<CDEF>s must
the value of this CDEF at the previous time step. This allows you to
perform calculations across the data.
+=item COUNT
+
+Pushes the number 1 if it is at the first value of the data set, the
+number 2 if it is at the second, and so on. This special value, allows
+you to make calculations based on the position of the value within
+the data set.
+
=item INF, NEGINF
Push a positive or negative infinite (oo) value onto the stack. When
step. This allows you to do calculations across the data. This
function cannot be used in B<VDEF> instructions.
+B<COUNT>
+
+Pushes the number 1 if this is the first value of the data set, the
+number 2 if it is the second, and so on. This special value, allows
+you to make calculations based on the position of the value within
+the data set. This function cannot be used in B<VDEF> instructions.
+
Z<>
=item Time
*****************************************************************************
* $Id$
* $Log$
+ * Revision 1.8 2003/04/11 19:43:44 oetiker
+ * New special value COUNT which allows calculations based on the position of a
+ * value within a data set. Bug fix in rrd_rpncalc.c. PREV returned erroneus
+ * value for the second value. Bug fix in rrd_restore.c. Bug causing seek error
+ * when accesing an RRD restored from an xml that holds an RRD version <3.
+ * -- Ruben Justo <ruben@ainek.com>
+ *
* Revision 1.7 2003/03/31 21:22:12 oetiker
* enables RRDtool updates with microsecond or in case of windows millisecond
* precision. This is needed to reduce time measurement error when archive step
fclose(*in_file);
return (-1);
}
- fread(&rrd->live_head->last_up, sizeof(long), 1, *in_file);
+ fread(&rrd->live_head->last_up, sizeof(long), 1, *in_file);
+ rrd->live_head->last_up_usec = 0;
}
else {
MYFREAD(rrd->live_head, live_head_t, 1)
fwrite(rrd->rra_def,
sizeof(rra_def_t), rrd->stat_head->rra_cnt, rrd_file);
-
- fwrite(rrd->live_head, sizeof(live_head_t),1, rrd_file);
+
+ /* maybe the xml hold an old formatted rrd */
+ if (atoi(rrd->stat_head->version) < 3)
+ fwrite(&(rrd->live_head->last_up), sizeof(long),1, rrd_file);
+ else
+ fwrite(rrd->live_head, sizeof(live_head_t),1, rrd_file);
fwrite( rrd->pdp_prep, sizeof(pdp_prep_t),rrd->stat_head->ds_cnt,rrd_file);
* occur too often. */
for (i = 0; rpnp[i].op != OP_END; i++) {
if (rpnp[i].op == OP_TIME || rpnp[i].op == OP_LTIME ||
- rpnp[i].op == OP_PREV)
+ rpnp[i].op == OP_PREV || rpnp[i].op == OP_COUNT)
{
rrd_set_error(
- "operators time, ltime and prev not supported with DS COMPUTE");
+ "operators time, ltime, prev and count not supported with DS COMPUTE");
free(rpnp);
return;
}
match_op(OP_UN,UN)
match_op(OP_NEGINF,NEGINF)
match_op(OP_NE,NE)
+ match_op(OP_COUNT,COUNT)
match_op_param(OP_PREV_OTHER,PREV)
match_op(OP_PREV,PREV)
match_op(OP_INF,INF)
}
}
break;
+ case OP_COUNT:
+ rpnstack -> s[++stptr] = (output_idx+1); /* Note: Counter starts at 1 */
+ break;
case OP_PREV:
- if ((output_idx-1) <= 0) {
+ if ((output_idx) <= 0) {
rpnstack -> s[++stptr] = DNAN;
} else {
rpnstack -> s[++stptr] = output[output_idx-1];
}
break;
case OP_PREV_OTHER:
- if ((output_idx-1) <= 0) {
+ if ((output_idx) <= 0) {
rpnstack -> s[++stptr] = DNAN;
} else {
rpnstack -> s[++stptr] = rpnp[rpnp[rpi].ptr].data[output_idx-1];
* This is because COMPUTE (CDEF) DS store OP nodes by number (name is not
* an option due to limited par array size). OP nodes must have the same
* numeric values, otherwise the stored numbers will mean something different. */
-enum op_en {OP_NUMBER=0,OP_VARIABLE,OP_INF,OP_PREV,OP_NEGINF,
+enum op_en {OP_NUMBER=0,OP_VARIABLE,OP_INF,OP_PREV,OP_COUNT,OP_NEGINF,
OP_UNKN,OP_NOW,OP_TIME,OP_ADD,OP_MOD,OP_SUB,OP_MUL,
OP_DIV,OP_SIN, OP_DUP, OP_EXC, OP_POP,
OP_COS,OP_LOG,OP_EXP,OP_LT,OP_LE,OP_GT,OP_GE,OP_EQ,OP_IF,
char help_main[] =
"RRDtool 1.1.x Copyright 1997-2003 by Tobias Oetiker <tobi@oetiker.ch>\n"
+#ifndef WIN32
" Compiled " MAKE_TIMESTAMP "\n\n"
+#else
+ " Compiled " __DATE__ " " __TIME__ "\n\n"
+#endif
"Usage: rrdtool [options] command command_options\n\n";
char help_list[] =