/***************************************************************************** * RRDtool 1.0.50 Copyright Tobias Oetiker, 1997 - 2000 ***************************************************************************** * rrd_dump Display a RRD ***************************************************************************** * $Id: rrd_dump.c,v 1.1.1.1 2002/02/26 10:21:37 oetiker Exp $ * $Log: rrd_dump.c,v $ * Revision 1.1.1.1 2002/02/26 10:21:37 oetiker * Intial Import * *****************************************************************************/ #include "rrd_tool.h" extern char *tzname[2]; int rrd_dump(int argc, char **argv) { int i,ii,ix,iii=0; time_t now; char somestring[255]; rrd_value_t my_cdp; long rra_base, rra_start, rra_next; FILE *in_file; rrd_t rrd; if(rrd_open(argv[1],&in_file,&rrd, RRD_READONLY)==-1){ return(-1); } puts(""); puts(""); printf("\t %s \n",rrd.stat_head->version); printf("\t %lu \n",rrd.stat_head->pdp_step); #if HAVE_STRFTIME strftime(somestring,200,"%Y-%m-%d %H:%M:%S %Z", localtime(&rrd.live_head->last_up)); #else # error "Need strftime" #endif printf("\t %ld \n\n", rrd.live_head->last_up,somestring); for(i=0;ids_cnt;i++){ printf("\t\n"); printf("\t\t %s \n",rrd.ds_def[i].ds_nam); printf("\t\t %s \n",rrd.ds_def[i].dst); printf("\t\t %lu \n",rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); if (isnan(rrd.ds_def[i].par[DS_min_val].u_val)){ printf("\t\t NaN \n"); } else { printf("\t\t %0.10e \n",rrd.ds_def[i].par[DS_min_val].u_val); } if (isnan(rrd.ds_def[i].par[DS_max_val].u_val)){ printf("\t\t NaN \n"); } else { printf("\t\t %0.10e \n",rrd.ds_def[i].par[DS_max_val].u_val); } printf("\n\t\t\n"); printf("\t\t %s \n",rrd.pdp_prep[i].last_ds); if (isnan(rrd.pdp_prep[i].scratch[PDP_val].u_val)){ printf("\t\t NaN \n"); } else { printf("\t\t %0.10e \n",rrd.pdp_prep[i].scratch[PDP_val].u_val); } printf("\t\t %lu \n", rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); printf("\t\n\n"); } puts(""); rra_base=ftell(in_file); rra_next = rra_base; for(i=0;irra_cnt;i++){ long timer=0; rra_start= rra_next; rra_next += ( rrd.stat_head->ds_cnt * rrd.rra_def[i].row_cnt * sizeof(rrd_value_t)); printf("\t\n"); printf("\t\t %s \n",rrd.rra_def[i].cf_nam); printf("\t\t %lu \n", rrd.rra_def[i].pdp_cnt, rrd.rra_def[i].pdp_cnt *rrd.stat_head->pdp_step); printf("\t\t %0.10e \n\n",rrd.rra_def[i].par[RRA_cdp_xff_val].u_val); printf("\t\t\n"); for(ii=0;iids_cnt;ii++){ double value = rrd.cdp_prep[i*rrd.stat_head->ds_cnt+ii].scratch[CDP_val].u_val; printf("\t\t\t"); if (isnan(value)){ printf(" NaN "); } else { printf(" %0.10e ", value); } printf(" %lu ", rrd.cdp_prep[i*rrd.stat_head->ds_cnt+ii].scratch[CDP_unkn_pdp_cnt].u_cnt); printf("\n"); } printf("\t\t\n"); printf("\t\t\n"); fseek(in_file,(rra_start +(rrd.rra_ptr[i].cur_row+1) * rrd.stat_head->ds_cnt * sizeof(rrd_value_t)),SEEK_SET); timer = - (rrd.rra_def[i].row_cnt-1); ii=rrd.rra_ptr[i].cur_row; for(ix=0;ix=rrd.rra_def[i].row_cnt) { fseek(in_file,rra_start,SEEK_SET); ii=0; /* wrap if max row cnt is reached */ } now = (rrd.live_head->last_up - rrd.live_head->last_up % (rrd.rra_def[i].pdp_cnt*rrd.stat_head->pdp_step)) + (timer*rrd.rra_def[i].pdp_cnt*rrd.stat_head->pdp_step); timer++; #if HAVE_STRFTIME strftime(somestring,200,"%Y-%m-%d %H:%M:%S %Z", localtime(&now)); #else # error "Need strftime" #endif printf("\t\t\t ",somestring,(int)now); for(iii=0;iiids_cnt;iii++){ fread(&my_cdp,sizeof(rrd_value_t),1,in_file); if (isnan(my_cdp)){ printf(" NaN "); } else { printf(" %0.10e ",my_cdp); }; } printf("\n"); } printf("\t\t\n\t\n"); } printf("\n"); rrd_free(&rrd); fclose(in_file); return(0); }