summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2018-12-18 01:08:51 -0800
committerOle Trøan <otroan@employees.org>2018-12-20 15:12:11 +0000
commitfd0d50879f475a1b15cedb4ab49059a02c45ccfd (patch)
treecbb86dfe652ec5401492298335c9750cfad482b3 /src/plugins/nat/nat.c
parent775f73c6baaf9bc2283e7ab9752c81984823be99 (diff)
NAT: total users and sessions gauges (VPP-1484)
Change-Id: I41a82e21571d5c64d01af72cd88c3983afac26ed Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat.c')
-rwxr-xr-xsrc/plugins/nat/nat.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c
index 2e1aa770581..c2c812d114b 100755
--- a/src/plugins/nat/nat.c
+++ b/src/plugins/nat/nat.c
@@ -322,6 +322,9 @@ nat_user_get_or_create (snat_main_t * sm, ip4_address_t * addr, u32 fib_index,
/* add user */
if (clib_bihash_add_del_8_8 (&tsm->user_hash, &kv, 1))
nat_log_warn ("user_hash keay add failed");
+
+ vlib_set_simple_counter (&sm->total_users, thread_index, 0,
+ pool_elts (tsm->users));
}
else
{
@@ -397,6 +400,8 @@ nat_session_alloc_or_recycle (snat_main_t * sm, snat_user_t * u,
per_user_translation_list_elt - tsm->list_pool);
s->user_index = u - tsm->users;
+ vlib_set_simple_counter (&sm->total_sessions, thread_index, 0,
+ pool_elts (tsm->sessions));
}
return s;
@@ -471,6 +476,9 @@ nat_ed_session_alloc (snat_main_t * sm, snat_user_t * u, u32 thread_index,
s->per_user_list_head_index,
per_user_translation_list_elt - tsm->list_pool);
}
+
+ vlib_set_simple_counter (&sm->total_sessions, thread_index, 0,
+ pool_elts (tsm->sessions));
}
return s;
@@ -2207,6 +2215,16 @@ snat_init (vlib_main_t * vm)
nat_dpo_module_init ();
+ /* Init counters */
+ sm->total_users.name = "total-users";
+ sm->total_users.stat_segment_name = "/nat44/total-users";
+ vlib_validate_simple_counter (&sm->total_users, 0);
+ vlib_zero_simple_counter (&sm->total_users, 0);
+ sm->total_sessions.name = "total-sessions";
+ sm->total_sessions.stat_segment_name = "/nat44/total-sessions";
+ vlib_validate_simple_counter (&sm->total_sessions, 0);
+ vlib_zero_simple_counter (&sm->total_sessions, 0);
+
/* Init IPFIX logging */
snat_ipfix_logging_init (vm);