@@ -11,7 +11,7 @@ local function logit(msg)
11
11
end
12
12
13
13
local counters_db = ARGV [1 ]
14
- local counters_table_name = ARGV [2 ]
14
+ local counters_table_name = ARGV [2 ]
15
15
local rates_table_name = " RATES"
16
16
17
17
-- Get configuration
@@ -51,7 +51,7 @@ for i = 1, n do
51
51
local out_non_ucast_pkts_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_NON_UCAST_PKTS_last' )
52
52
local in_octets_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_IN_OCTETS_last' )
53
53
local out_octets_last = redis .call (' HGET' , rates_table_name .. ' :' .. KEYS [i ], ' SAI_PORT_STAT_IF_OUT_OCTETS_last' )
54
-
54
+
55
55
-- Calculate new rates values
56
56
local rx_bps_new = (in_octets - in_octets_last )/ delta
57
57
local tx_bps_new = (out_octets - out_octets_last )/ delta
@@ -69,25 +69,26 @@ for i = 1, n do
69
69
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_BPS' , alpha * rx_bps_new + one_minus_alpha * rx_bps_old )
70
70
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_PPS' , alpha * rx_pps_new + one_minus_alpha * rx_pps_old )
71
71
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 )
73
73
else
74
74
-- Store unsmoothed initial rates values in DB
75
75
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_BPS' , rx_bps_new )
76
76
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' RX_PPS' , rx_pps_new )
77
77
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_BPS' , tx_bps_new )
78
78
redis .call (' HSET' , rates_table_name .. ' :' .. KEYS [i ], ' TX_PPS' , tx_pps_new )
79
79
redis .call (' HSET' , state_table , ' INIT_DONE' , ' DONE' )
80
- end
80
+ end
81
81
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 )
89
82
redis .call (' HSET' , state_table , ' INIT_DONE' , ' COUNTERS_LAST' )
90
83
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 )
91
92
end
92
93
93
94
return logtable
0 commit comments