index 8e64d8b200b58b61bde2402d94caa01e3d095ad3..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 ||
* 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(
{
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;
}
free(rpnp);
return;
}
*/
long lookup_DS(void *rrd_vptr,char *ds_name)
{
*/
long lookup_DS(void *rrd_vptr,char *ds_name)
{
- int i;
+ unsigned int i;
rrd_t *rrd;
rrd = (rrd_t *) rrd_vptr;
rrd_t *rrd;
rrd = (rrd_t *) rrd_vptr;
match_op(OP_UN,UN)
match_op(OP_NEGINF,NEGINF)
match_op(OP_NE,NE)
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)
match_op_param(OP_PREV_OTHER,PREV)
match_op(OP_PREV,PREV)
match_op(OP_INF,INF)
}
}
break;
}
}
break;
+ case OP_COUNT:
+ rpnstack -> s[++stptr] = (output_idx+1); /* Note: Counter starts at 1 */
+ break;
case OP_PREV:
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:
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];
rpnstack -> s[++stptr] = DNAN;
} else {
rpnstack -> s[++stptr] = rpnp[rpnp[rpi].ptr].data[output_idx-1];
tzoffset( time_t now ){
int gm_sec, gm_min, gm_hour, gm_yday, gm_year,
l_sec, l_min, l_hour, l_yday, l_year;
tzoffset( time_t now ){
int gm_sec, gm_min, gm_hour, gm_yday, gm_year,
l_sec, l_min, l_hour, l_yday, l_year;
- struct tm *t;
+ struct tm t;
int off;
int off;
- t = gmtime(&now);
- gm_sec = t->tm_sec;
- gm_min = t->tm_min;
- gm_hour = t->tm_hour;
- gm_yday = t->tm_yday;
- gm_year = t->tm_year;
- t = localtime(&now);
- l_sec = t->tm_sec;
- l_min = t->tm_min;
- l_hour = t->tm_hour;
- l_yday = t->tm_yday;
- l_year = t->tm_year;
+ gmtime_r(&now, &t);
+ gm_sec = t.tm_sec;
+ gm_min = t.tm_min;
+ gm_hour = t.tm_hour;
+ gm_yday = t.tm_yday;
+ gm_year = t.tm_year;
+ localtime_r(&now, &t);
+ l_sec = t.tm_sec;
+ l_min = t.tm_min;
+ l_hour = t.tm_hour;
+ l_yday = t.tm_yday;
+ l_year = t.tm_year;
off = (l_sec-gm_sec)+(l_min-gm_min)*60+(l_hour-gm_hour)*3600;
if ( l_yday > gm_yday || l_year > gm_year){
off += 24*3600;
off = (l_sec-gm_sec)+(l_min-gm_min)*60+(l_hour-gm_hour)*3600;
if ( l_yday > gm_yday || l_year > gm_year){
off += 24*3600;