Skip to content

Commit 7383951

Browse files
committed
Track "weird routes" for manual intervention
1 parent 666690e commit 7383951

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

include/hpr_metrics.hrl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
-define(METRICS_ROUTES_GAUGE, "hpr_routes_gauge").
1414
-define(METRICS_EUI_PAIRS_GAUGE, "hpr_eui_pairs_gauge").
1515
-define(METRICS_SKFS_GAUGE, "hpr_skfs_gauge").
16+
-define(METRICS_WEIRD_ROUTES_GAUGE, "hpr_weird_routes_gauge").
1617
-define(METRICS_PACKET_REPORT_HISTOGRAM, "hpr_packet_report_histogram").
1718
-define(METRICS_MULTI_BUY_GET_HISTOGRAM, "hpr_multi_buy_get_histogram").
1819
-define(METRICS_FIND_ROUTES_HISTOGRAM, "hpr_find_routes_histogram").
@@ -35,6 +36,7 @@
3536
{?METRICS_ROUTES_GAUGE, prometheus_gauge, [], "Number of Routes"},
3637
{?METRICS_EUI_PAIRS_GAUGE, prometheus_gauge, [], "Number of EUI Pairs"},
3738
{?METRICS_SKFS_GAUGE, prometheus_gauge, [], "Number of SKFs"},
39+
{?METRICS_WEIRD_ROUTES_GAUGE, prometheus_gauge, [], "Number of weird routes"},
3840
{?METRICS_PACKET_REPORT_HISTOGRAM, prometheus_histogram, [status], "Packet Reports"},
3941
{?METRICS_MULTI_BUY_GET_HISTOGRAM, prometheus_histogram, [status], "Multi Buy Service Get"},
4042
{?METRICS_FIND_ROUTES_HISTOGRAM, prometheus_histogram, [], "Find Routes"},

src/metrics/hpr_metrics.erl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ handle_info(?METRICS_TICK, State) ->
187187
fun record_routes/0,
188188
fun record_eui_pairs/0,
189189
fun record_skfs/0,
190+
fun record_weird_routes/0,
190191
fun record_ets/0,
191192
fun record_queues/0,
192193
fun record_devices/0
@@ -278,6 +279,36 @@ record_skfs() ->
278279
_ = prometheus_gauge:set(?METRICS_SKFS_GAUGE, [], Count),
279280
ok.
280281

282+
-spec record_weird_routes() -> ok.
283+
record_weird_routes() ->
284+
Count = lists:foldl(
285+
fun(RouteETS, Acc) ->
286+
Route = hpr_route_ets:route(RouteETS),
287+
RouteID = hpr_route:id(Route),
288+
SKFCount =
289+
case ets:info(hpr_route_ets:skf_ets(RouteETS), size) of
290+
undefined -> 0;
291+
N -> N
292+
end,
293+
DevAddrRangesCount = hpr_devaddr_range_storage:count_for_route(RouteID),
294+
case SKFCount > 0 andalso DevAddrRangesCount == 0 of
295+
true ->
296+
lager:critical(
297+
[{route_id, RouteID}, {oui, hpr_route:oui(Route)}],
298+
"route has no devaddr ranges but has (~p) skfs",
299+
[SKFCount]
300+
),
301+
Acc + 1;
302+
false ->
303+
Acc
304+
end
305+
end,
306+
0,
307+
ets:tab2list(hpr_routes_ets)
308+
),
309+
_ = prometheus_gauge:set(?METRICS_WEIRD_ROUTES_GAUGE, [], Count),
310+
ok.
311+
281312
-spec record_grpc_connections() -> ok.
282313
record_grpc_connections() ->
283314
Opts = application:get_env(grpcbox, listen_opts, #{}),

0 commit comments

Comments
 (0)