X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Frrd_fetch_libdbi.c;h=21fbc083c7575494adfcf26600f69a4de740a47a;hb=af579ff846d452cc3d83f514da87cf0fea1bcdaa;hp=2c4c722ee46ecbbbd8d95ece84c8deb8c4899d5a;hpb=372ab4d5e9689e01e7b7a770e1c380288c8b2d6a;p=rrdtool.git diff --git a/src/rrd_fetch_libdbi.c b/src/rrd_fetch_libdbi.c index 2c4c722..21fbc08 100644 --- a/src/rrd_fetch_libdbi.c +++ b/src/rrd_fetch_libdbi.c @@ -389,6 +389,7 @@ rrd_fetch_fn_libdbi( unsigned long minstepsize=300; /* by default assume unixtimestamp */ int isunixtime=1; + long gmt_offset=0; /* the result-set */ long r_timestamp,l_timestamp,d_timestamp; double r_value,l_value,d_value; @@ -459,7 +460,13 @@ rrd_fetch_fn_libdbi( return -1; } /* if we have leading '*', then we have a TIMEDATE Field*/ - if (table_help.timestamp[0]=='*') { isunixtime=0; table_help.timestamp++; } + if (table_help.timestamp[0]=='*') { + struct tm tm; + time_t t=time(NULL); + localtime_r(&t,&tm); + gmt_offset=tm.tm_gmtoff; + isunixtime=0; table_help.timestamp++; + } /* hex-unescape the value */ if(_inline_unescape(table_help.timestamp)) { return -1; } @@ -585,6 +592,7 @@ rrd_fetch_fn_libdbi( while((r_status=_sql_fetchrow(&table_help,&r_timestamp,&r_value,derive))>0) { /* processing of value */ /* calculate index for the timestamp */ + r_timestamp-=gmt_offset; idx=(r_timestamp-(*start))/(*step); /* some out of bounds checks on idx */ if (idx<0) { idx=0;} @@ -615,7 +623,7 @@ rrd_fetch_fn_libdbi( (*data)[idx*(*ds_cnt)+1]=r_value; /* AVG */ (*data)[idx*(*ds_cnt)+2]=r_value; /* MAX */ (*data)[idx*(*ds_cnt)+3]=1; /* COUNT */ - (*data)[idx*(*ds_cnt)+4]=r_value; /* SIGMA */ + (*data)[idx*(*ds_cnt)+4]=r_value*r_value; /* SIGMA */ } else { /* MIN */ if ((*data)[idx*(*ds_cnt)+0]>r_value) { (*data)[idx*(*ds_cnt)+0]=r_value; }