summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 07722e4)
raw | patch | inline | side by side (parent: 07722e4)
author | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 11 Apr 2003 19:43:44 +0000 (19:43 +0000) | ||
committer | oetiker <oetiker@a5681a0c-68f1-0310-ab6d-d61299d08faa> | |
Fri, 11 Apr 2003 19:43:44 +0000 (19:43 +0000) |
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>
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@199 a5681a0c-68f1-0310-ab6d-d61299d08faa
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>
git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@199 a5681a0c-68f1-0310-ab6d-d61299d08faa
index 7a327f8b6b4db5b1318424d515f58b7daefe3855..d516ab401844bdf41c52e9eb72ee489b69f6a5bb 100644 (file)
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
index 6d3478210f3d7b6bc4fb12727a4a1dd9c8888864..ef730c4560022af4b88ee5c206ec34e0e74f77a1 100644 (file)
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
index a8c4b112634c76fd92236e71eac8bde6a12dab95..f9ac7fedb9959cb66390026df5dd1fe921009c20 100644 (file)
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
diff --git a/program/src/rrd_open.c b/program/src/rrd_open.c
index f345e28f71839e53ad16190db1c469fcfe6b52e6..9ce17a33f300c9b06d80660fe66d250d90e44e26 100644 (file)
--- a/program/src/rrd_open.c
+++ b/program/src/rrd_open.c
*****************************************************************************
* $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)
index a0ef6359c1e7be1298832687325521feb2b546c1..150f1ee8fd5f53a578d683297386160e1d6e1f40 100644 (file)
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);
index 9bb35d22d9233883f5b4a7cee1af38d5831705fc..65748cc491cf1933ee48934aa2b7ebb9dc3463dc 100644 (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];
index a4e7c65cd7c116100f8dcba97be1df95b9dc6193..796aa7d180957c416356bb8f6f0d1629bd31ad06 100644 (file)
* 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,
diff --git a/program/src/rrd_tool.c b/program/src/rrd_tool.c
index 037894085141c1a3c54d5cc18e19c28061f25274..2cb449499a607fb6f8c4d7ac56f1e7351d6a1202 100644 (file)
--- a/program/src/rrd_tool.c
+++ b/program/src/rrd_tool.c
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[] =