1 /*****************************************************************************
2 * RRDtool 1.2rc8 Copyright by Tobi Oetiker, 1997-2005
3 *****************************************************************************
5 *****************************************************************************
6 * Initial version by Burton Strauss, ntopSupport.com - 3/2005
7 *****************************************************************************/
13 rrd_first(int argc, char **argv)
15 int target_rraindex=0;
19 static struct option long_options[] =
21 {"rraindex", required_argument, 0, 129},
26 opt = getopt_long(argc, argv, "", long_options, &option_index);
33 target_rraindex=strtol(optarg,&endptr,0);
34 if(target_rraindex < 0) {
35 rrd_set_error("invalid rraindex number");
40 rrd_set_error("usage rrdtool %s [--rraindex number] file.rrd", argv[0]);
46 rrd_set_error("not enough arguments");
50 return(rrd_first_r(argv[optind], target_rraindex));
55 rrd_first_r(const char *filename, const int rraindex)
63 if(rrd_open(filename,&in_file,&rrd, RRD_READONLY)==-1){
64 rrd_set_error("could not open RRD");
68 if((rraindex < 0) || (rraindex >= (int)rrd.stat_head->rra_cnt)) {
69 rrd_set_error("invalid rraindex number");
73 rra_start = ftell(in_file);
76 (rrd.rra_ptr[rraindex].cur_row+1) *
77 rrd.stat_head->ds_cnt *
80 timer = - (rrd.rra_def[rraindex].row_cnt-1);
81 if (rrd.rra_ptr[rraindex].cur_row + 1 > rrd.rra_def[rraindex].row_cnt) {
82 fseek(in_file,rra_start,SEEK_SET);
84 then = (rrd.live_head->last_up -
85 rrd.live_head->last_up %
86 (rrd.rra_def[rraindex].pdp_cnt*rrd.stat_head->pdp_step)) +
88 rrd.rra_def[rraindex].pdp_cnt*rrd.stat_head->pdp_step);