/*****************************************************************************
- * RRDtool 1.2.13 Copyright by Tobi Oetiker, 1997-2006
+ * RRDtool 1.2.15 Copyright by Tobi Oetiker, 1997-2006
*****************************************************************************
* rrd_tool.c Startup wrapper
*****************************************************************************/
"\trrdtool xport [-s|--start seconds] [-e|--end seconds]\n"
"\t\t[-m|--maxrows rows]\n"
"\t\t[--step seconds]\n"
+ "\t\t[--enumds]\n"
"\t\t[DEF:vname=rrd:ds-name:CF]\n"
"\t\t[CDEF:vname=rpn-expression]\n"
"\t\t[XPORT:vname:legend]\n\n";
}
}
}
+ closedir(curdir);
}
else{
printf("ERROR: %s\n",rrd_strerror(errno));
free (data);
}
} else if (strcmp("xport", argv[1]) == 0) {
- int xxsize;
+ int xxsize;
unsigned long int j = 0;
time_t start,end, ti;
unsigned long step, col_cnt,row_cnt;
rrd_value_t *data,*ptr;
char **legend_v;
- if(rrd_xport(argc-1, &argv[1], &xxsize,&start,&end,&step,&col_cnt,&legend_v,&data) != -1) {
+ int enumds = 0;
+ int i;
+ char *vtag = NULL;
+ vtag = malloc( strlen(COL_DATA_TAG)+10);
+ for ( i = 2; i < argc; i++){
+ if (strcmp("--enumds", argv[i]) == 0)
+ enumds = 1;
+ }
+
+ if(rrd_xport(argc-1, &argv[1], &xxsize,&start,&end,&step,&col_cnt,&legend_v,&data) != -1) {
row_cnt = (end-start)/step;
ptr = data;
printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n\n", XML_ENCODING);
printf (" <%s>", DATA_ROW_TAG);
printf ("<%s>%lu</%s>", COL_TIME_TAG, ti, COL_TIME_TAG);
for (j = 0; j < col_cnt; j++) {
+ if (enumds == 1)
+ snprintf(vtag,15,"%s%lu", COL_DATA_TAG, j);
+ else
+ snprintf(vtag,15,"%s",COL_DATA_TAG);
+
rrd_value_t newval = DNAN;
newval = *ptr;
if(isnan(newval)){
- printf("<%s>NaN</%s>", COL_DATA_TAG, COL_DATA_TAG);
+ printf("<%s>NaN</%s>", vtag,vtag);
} else {
- printf("<%s>%0.10e</%s>", COL_DATA_TAG, newval, COL_DATA_TAG);
+ printf("<%s>%0.10e</%s>", vtag, newval, vtag);
};
ptr++;
}
printf(" </%s>\n", DATA_TAG);
printf("</%s>\n", ROOT_TAG);
}
+ free(vtag);
}
else if (strcmp("graph", argv[1]) == 0) {
char **calcpr;