I want to count the first REGISTER request during an initial register or re-register from UE. In my scscf instance, I have defined att_init_reg and att_rereg counters to count the number of initial registers and re-registers respectively. In my early tests, the following piece of logic worked as expected to filter the very first register request (one that is sent from UE before getting challenged). However, more tests showed that during re-registers, UE sends a REGISTER request, containing an authorization header and non-empty response, in that case the code is unable to distinguish a re-register attempt and the related counter fails to increment. Is there a way to fix this issue?
#!ifdef WITH_XHTTP_PROM /* Only count the first register request */ if (!is_present_hf("Authorization") || search_hf("Authorization","response=""","f")) { if ($var(impu_registered) != 1) { prom_counter_inc("att_init_reg", "1"); } else { prom_counter_inc("att_rereg", "1"); } } #!endif
Am Mon, 19 May 2025 13:35:17 -0000 schrieb James Morrison via sr-users sr-users@lists.kamailio.org:
Is there a way to fix this issue?
Just an idea - untested and unsure if this is what you are looking for,
https://www.kamailio.org/docs/modules/devel/modules/registrar.html#registrar...
Return Code => 1 Inserted => New Register Return Code => 2 Updated => Re-Register
Mit freundlichen Grüssen
-Benoît Panizzon-
Thanks for reply I already know how to detect if it is a new register or re-register. As you know during registration UE first sends a register request which automatically fails the authentication (which is exactly what I want to count) and then the next request with response to that authentication challenge. In scripts I just want to count the first request, but when it is a re-register, sometimes the first request has the authentication header and response value is not empty.
Hi In that case, I would get the return code of the pv_auth_check() function and use that for the metrics. - https://www.kamailio.org/docs/modules/devel/modules/auth.html#auth.f.pv_auth...
It's not simple to look at a REGISTER request that has auth in it and know whether it's a reREGISTER (after several minutes, for example, to refresh a binding) or simply an authenticated REGISTER for which the client has just been challenged, but this function can tell you by its return code. The return codes are the same as those for pv_www_authenticate(). - -4 (nonce expired) - -6 (nonce reused)
Those two would tell you that the REGISTER credentials were generated/used some time ago - default 600 seconds - and therefore this must be a re-REGISTER.
Does that help? James
On Tue, 20 May 2025 at 07:13, James Morrison via sr-users sr-users@lists.kamailio.org wrote:
Thanks for reply I already know how to detect if it is a new register or re-register. As you know during registration UE first sends a register request which automatically fails the authentication (which is exactly what I want to count) and then the next request with response to that authentication challenge. In scripts I just want to count the first request, but when it is a re-register, sometimes the first request has the authentication header and response value is not empty. __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions -- sr-users@lists.kamailio.org To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender!