Skip to content

Commit

Permalink
fix error in rif_rates.lua (#3218)
Browse files Browse the repository at this point in the history
why I did:
    the values cant't be got from COUNTERS and RATES table in counter_db as removing routing interfaces
what I did:
    checking the values are existing first, and then calculating rate values
  • Loading branch information
inspurSDN authored Oct 29, 2024
1 parent a3aaa39 commit d76c34e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions orchagent/rif_rates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ for i = 1, n do
local out_octets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS')
local out_pkts = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS')

if not in_octets or not in_pkts or not out_octets or not out_pkts then
return logtable
end

if initialized == "DONE" or initialized == "COUNTERS_LAST" then
-- Get old COUNTERS values
local in_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_IN_OCTETS_last')
local in_pkts_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_IN_PACKETS_last')
local out_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS_last')
local out_pkts_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS_last')

if not in_octets_last or not in_pkts_last or not out_octets_last or not out_pkts_last then
return logtable
end

-- Calculate new rates values
local rx_bps_new = (in_octets - in_octets_last) / delta * 1000
local tx_bps_new = (out_octets - out_octets_last) / delta * 1000
Expand Down

0 comments on commit d76c34e

Please sign in to comment.