@@ -11,7 +11,7 @@ local function logit(msg)
1111end
1212
1313local counters_db = ARGV [1 ]
14- local counters_table_name = ARGV [2 ]
14+ local counters_table_name = ARGV [2 ]
1515local rates_table_name = " RATES"
1616
1717-- Get configuration
@@ -51,7 +51,7 @@ for i = 1, n do
5151 local out_non_ucast_pkts_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last' )
5252 local in_octets_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_OCTETS_last' )
5353 local out_octets_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_OCTETS_last' )
54-
54+
5555 -- Calculate new rates values
5656 local rx_bps_new = (in_octets - in_octets_last )/ delta
5757 local tx_bps_new = (out_octets - out_octets_last )/ delta
@@ -69,25 +69,26 @@ for i = 1, n do
6969 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_BPS' , alpha * rx_bps_new + one_minus_alpha * rx_bps_old )
7070 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_PPS' , alpha * rx_pps_new + one_minus_alpha * rx_pps_old )
7171 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_BPS' , alpha * tx_bps_new + one_minus_alpha * tx_bps_old )
72- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_PPS' , alpha * tx_pps_new + one_minus_alpha * tx_pps_old )
72+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_PPS' , alpha * tx_pps_new + one_minus_alpha * tx_pps_old )
7373 else
7474 -- Store unsmoothed initial rates values in DB
7575 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_BPS' , rx_bps_new )
7676 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_PPS' , rx_pps_new )
7777 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_BPS' , tx_bps_new )
7878 redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_PPS' , tx_pps_new )
7979 redis .call (' HSET' , state_table , ' INIT_DONE' , ' DONE' )
80- end
80+ end
8181 else
82- -- Set old COUNTERS values
83- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_UCAST_PKTS_last' , in_ucast_pkts )
84- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last' , in_non_ucast_pkts )
85- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last' , out_ucast_pkts )
86- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last' , out_non_ucast_pkts )
87- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_OCTETS_last' , in_octets )
88- redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_OCTETS_last' , out_octets )
8982 redis .call (' HSET' , state_table , ' INIT_DONE' , ' COUNTERS_LAST' )
9083 end
84+
85+ -- Set old COUNTERS values
86+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_UCAST_PKTS_last' , in_ucast_pkts )
87+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_NON_UCAST_PKTS_last' , in_non_ucast_pkts )
88+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_UCAST_PKTS_last' , out_ucast_pkts )
89+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last' , out_non_ucast_pkts )
90+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_OCTETS_last' , in_octets )
91+ redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_OCTETS_last' , out_octets )
9192end
9293
9394return logtable
0 commit comments