diff --git a/orchagent/port_rates.lua b/orchagent/port_rates.lua index 37b5ab7f2942..60ff27c0aae1 100644 --- a/orchagent/port_rates.lua +++ b/orchagent/port_rates.lua @@ -18,6 +18,10 @@ local rates_table_name = "RATES" redis.call('SELECT', counters_db) local smooth_interval = redis.call('HGET', rates_table_name .. ':' .. 'PORT', 'PORT_SMOOTH_INTERVAL') local alpha = redis.call('HGET', rates_table_name .. ':' .. 'PORT', 'PORT_ALPHA') +if not alpha then + logit("Alpha is not defined") + return logtable +end local one_minus_alpha = 1.0 - alpha local delta = tonumber(ARGV[3]) @@ -25,7 +29,7 @@ logit(alpha) logit(one_minus_alpha) logit(delta) -local initialized = redis.call('HGET', rates_table_name, 'INIT_DONE') +local initialized = redis.call('HGET', rates_table_name .. ':' .. 'PORT', 'INIT_DONE') logit(initialized) @@ -72,7 +76,7 @@ for i = 1, n do redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_PPS', rx_pps_new) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_BPS', tx_bps_new) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_PPS', tx_pps_new) - redis.call('HSET', rates_table_name, 'INIT_DONE', 'DONE') + redis.call('HSET', rates_table_name .. ':' .. 'PORT', 'INIT_DONE', 'DONE') end else -- Set old COUNTERS values @@ -82,7 +86,7 @@ for i = 1, n do redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last', out_non_ucast_pkts) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_IN_OCTETS_last', in_octets) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_PORT_STAT_IF_OUT_OCTETS_last', out_octets) - redis.call('HSET', rates_table_name, 'INIT_DONE', 'COUNTERS_LAST') + redis.call('HSET', rates_table_name .. ':' .. 'PORT', 'INIT_DONE', 'COUNTERS_LAST') end end diff --git a/orchagent/rif_rates.lua b/orchagent/rif_rates.lua index a2f7e58e317b..edda70d248f1 100644 --- a/orchagent/rif_rates.lua +++ b/orchagent/rif_rates.lua @@ -18,10 +18,14 @@ local rates_table_name = "RATES" redis.call('SELECT', counters_db) local smooth_interval = redis.call('HGET', rates_table_name .. ':' .. 'RIF', 'RIF_SMOOTH_INTERVAL') local alpha = redis.call('HGET', rates_table_name .. ':' .. 'RIF', 'RIF_ALPHA') +if not alpha then + logit("Alpha is not defined") + return logtable +end local one_minus_alpha = 1.0 - alpha local delta = tonumber(ARGV[3]) -local initialized = redis.call('HGET', rates_table_name, 'INIT_DONE') +local initialized = redis.call('HGET', rates_table_name .. ':' .. 'RIF', 'INIT_DONE') logit(initialized) local n = table.getn(KEYS) @@ -63,7 +67,7 @@ for i = 1, n do redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'RX_PPS', rx_pps_new) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_BPS', tx_bps_new) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'TX_PPS', tx_pps_new) - redis.call('HSET', rates_table_name, 'INIT_DONE', 'DONE') + redis.call('HSET', rates_table_name .. ':' .. 'RIF', 'INIT_DONE', 'DONE') end else -- Set old COUNTERS values @@ -71,7 +75,7 @@ for i = 1, n do redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_IN_PACKETS_last', in_pkts) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS_last', out_octets) redis.call('HSET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS_last', out_pkts) - redis.call('HSET', rates_table_name, 'INIT_DONE', 'COUNTERS_LAST') + redis.call('HSET', rates_table_name .. ':' .. 'RIF', 'INIT_DONE', 'COUNTERS_LAST') end end