Changeset b354e99dbd9c5a7fed905a1de2014ea0ed2dc507

Show
Ignore:
Timestamp:
10/23/09 21:12:50 (4 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1256332370 +0000
git-parent:

[66acead9783cbb25309f4bbf73e2fed9462863f3]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1256332370 +0000
Message:

sweep

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • sql/scaffolding.sql

    rbe9e0d3 rb354e99  
    5555\i sprocs/stratcon.fetch_varset.sql 
    5656\i sprocs/stratcon.get_storage_node_for_sid.sql 
    57 \i sprocs/stratcon.init_metric_numeric_rollup_5m.sql 
     57\i sprocs/stratcon.init_metric_numeric_rollup.sql 
    5858\i sprocs/stratcon.map_uuid_to_sid.sql 
    5959\i sprocs/stratcon.update_config.sql 
    6060\i sprocs/stratcon.rollup_metric_numeric_5m.sql 
    6161\i sprocs/stratcon.metric_name_summary_compile_fts_data.sql 
    62 \i sprocs/stratcon.rollup_metric_numeric_generic.sql 
     62\i sprocs/stratcon.rollup_metric_numeric.sql 
    6363 
    6464\i sprocs/prism.add_graph_tags.sql 
  • sql/sprocs/stratcon.rollup_metric_numeric.sql

    r2946c90 rb354e99  
    1111    v_locked        BOOLEAN; 
    1212    v_this_roll     TEXT; 
    13     v_stored_rollup TIMESTAMPTZ; 
     13    v_stored_rollup INTEGER; 
     14    v_stored_rollup_tm TIMESTAMPTZ; 
    1415    v_offset        INTEGER; 
    1516    v_init          BOOLEAN := FALSE; 
     
    7071        END LOOP; 
    7172 
    72         v_sql := 'SELECT sid, name, $2 as rollup_time, SUM(1) as count_rows, (SUM(avg_value*1)/SUM(1)) as avg_value, (SUM(counter_dev*1)/SUM(1)) as counter_dev 
    73                   FROM  stratcon.unroll_metric_numeric( $2, $1, $3) 
     73        v_sql := 'SELECT sid, name, $1 as rollup_time, SUM(1) as count_rows, (SUM(avg_value*1)/SUM(1)) as avg_value, (SUM(counter_dev*1)/SUM(1)) as counter_dev 
     74                  FROM  stratcon.unroll_metric_numeric( $1, $2, $3) 
    7475                  GROUP BY sid, name'; 
    75 RAISE NOTICE 'v_sql was (%)',v_sql;  
    76         FOR v_rec IN EXECUTE v_sql USING v_min_whence - v_conf.seconds * '1 second'::INTERVAL, v_min_whence, v_conf.dependent_on LOOP 
    77             v_stored_rollup := floor( extract('epoch' from v_rec.rollup_time) / v_conf.span ) + v_conf.window; 
     76RAISE NOTICE 'v_sql was (%), %, %, %',v_sql,v_min_whence, v_min_whence + (v_conf.seconds - 1) * '1 second'::interval, v_conf.dependent_on;  
     77        FOR v_rec IN EXECUTE v_sql USING v_min_whence, 
     78                                         v_min_whence + (v_conf.seconds - 1) * '1 second'::interval, 
     79                                         v_conf.dependent_on LOOP 
     80            v_stored_rollup := floor( extract('epoch' from v_rec.rollup_time) / v_conf.span ) * v_conf.span; 
     81            v_stored_rollup_tm := 'epoch'::timestamptz + v_stored_rollup * '1 second'::interval; 
    7882            v_offset        := floor( ( extract('epoch' from v_rec.rollup_time) - v_stored_rollup) / v_conf.seconds ); 
    7983 
     
    8286            -- RAISE NOTICE 'sid %, name %, rollup_time %, offset %', v_rec.sid, v_rec.name, v_stored_rollup, v_offset; 
    8387 
    84             v_sql := 'SELECT * FROM metric_numeric_rollup_'||in_roll||' WHERE rollup_time = '||quote_literal(v_stored_rollup); 
     88            v_sql := 'SELECT * FROM metric_numeric_rollup_'||in_roll||' WHERE rollup_time = '||quote_literal(v_stored_rollup_tm); 
    8589            v_sql := v_sql ||' and sid='||v_rec.sid||' and name = '|| quote_literal(v_rec.name); 
    8690 
     
    8892            GET DIAGNOSTICS v_count = ROW_COUNT; 
    8993            IF v_count = 0 THEN 
    90                 v_segment := stratcon.init_metric_numeric_rollup_segment( in_roll ); 
     94                v_segment := stratcon.init_metric_numeric_rollup( in_roll ); 
    9195                v_init := true; 
    92                 RAISE NOTICE 'didnt find sid %, name %, rollup_time %, offset %', v_rec.sid, v_rec.name, v_stored_rollup, v_offset; 
     96                RAISE NOTICE 'didnt find sid %, name %, rollup_time %, offset %', v_rec.sid, v_rec.name, v_stored_rollup_tm, v_offset; 
    9397            END IF; 
    9498 
     
    101105            IF v_init THEN 
    102106                v_sql := 'INSERT INTO metric_numeric_rollup_'||in_roll||' (sid,name,rollup_time,count_rows,avg_value,counter_dev) 
    103                     VALUES ('|| v_segment.sid||','||quote_literal(v_segment.name)||','||quote_literal(v_stored_rollup)||','||v_segment.count_rows 
     107                    VALUES ('|| v_segment.sid||','||quote_literal(v_segment.name)||','||quote_literal(v_stored_rollup_tm)||','||v_segment.count_rows 
    104108                    ||','||v_segment.avg_value||','||v_segment.counter_dev||')'; 
    105109                EXECUTE v_sql; 
     
    108112                v_sql := 'UPDATE metric_numeric_rollup_'||in_roll; 
    109113                v_sql := v_sql || 'SET (count_rows,avg_value,counter_dev) = ('||v_rec.count_rows||','||v_rec.avg_value||','||v_rec.counter_dev||')'; 
    110                 v_sql := v_sql || 'WHERE rollup_time = '||v_stored_rollup||'  AND sid = '||v_info.sid||'  AND name = '||quote_literal(v_info.name); 
     114                v_sql := v_sql || 'WHERE rollup_time = '||v_stored_rollup_tm||'  AND sid = '||v_info.sid||'  AND name = '||quote_literal(v_info.name); 
    111115                EXECUTE v_sql;  
    112116            END IF; 
  • sql/sprocs/stratcon.rollup_metric_numeric_5m.sql

    r3d4ceaf rb354e99  
    3131  END IF; 
    3232 
    33   FOR whenceint IN SELECT * FROM metric_numeric_rollup_queue WHERE interval='5 minutes' LOOP 
     33  FOR whenceint IN SELECT * FROM metric_numeric_rollup_queue WHERE interval='5m' LOOP 
    3434 
    35     SELECT MIN(whence) FROM metric_numeric_rollup_queue WHERE interval='5 minutes
     35    SELECT MIN(whence) FROM metric_numeric_rollup_queue WHERE interval='5m
    3636        INTO v_min_whence; 
    3737         
     
    4242    
    4343    SELECT whence FROM metric_numeric_rollup_queue  
    44         WHERE whence=date_trunc('H',v_min_whence) + (round(extract('minute' from v_min_whence)/20)*20) * '1 minute'::interval and interval='20 minutes
     44        WHERE whence=date_trunc('H',v_min_whence) + (round(extract('minute' from v_min_whence)/20)*20) * '1 minute'::interval and interval='20m
    4545        INTO v_whence; 
    4646    IF NOT FOUND THEN 
    4747       INSERT INTO  metric_numeric_rollup_queue  
    48            VALUES(date_trunc('H',v_min_whence) + (round(extract('minute' from v_min_whence)/20)*20) * '1 minute'::interval,'20 minutes'); 
     48           VALUES(date_trunc('H',v_min_whence) + (round(extract('minute' from v_min_whence)/20)*20) * '1 minute'::interval,'20m'); 
    4949    END IF; 
    5050 
     
    6363        SELECT * FROM metric_numeric_rollup_5m WHERE rollup_time = v_info.rollup_time AND sid=v_info.sid AND name=v_info.name INTO v_rec; 
    6464        IF NOT FOUND THEN  
    65                 SELECT * FROM stratcon.init_metric_numeric_rollup_5m() INTO v_rec;  
     65                SELECT * FROM stratcon.init_metric_numeric_rollup('5m') INTO v_rec;  
    6666                v_init := true;  
    6767        END IF; 
     
    8686  
    8787    -- Delete from whence log table 
    88     DELETE FROM metric_numeric_rollup_queue WHERE WHENCE=v_min_whence AND INTERVAL='5 minutes'; 
     88    DELETE FROM metric_numeric_rollup_queue WHERE WHENCE=v_min_whence AND INTERVAL='5m'; 
    8989  
    9090    v_min_whence:= NULL; 
  • sql/sprocs/stratcon.unroll_metric_numeric.sql

    r31d5dd7 rb354e99  
    1717    temprec         RECORD; 
    1818BEGIN 
     19    IF in_start IS NULL OR in_end IS NULL THEN 
     20      RAISE EXCEPTION 'start and end must be not null (%,%)', in_start, in_end; 
     21    END IF; 
    1922    SELECT * FROM metric_numeric_rollup_config WHERE rollup = in_roll INTO v_conf;  
    2023    IF NOT FOUND THEN