{"id":12605,"date":"2025-06-23T13:35:30","date_gmt":"2025-06-23T08:35:30","guid":{"rendered":"https:\/\/alexeyka.zantsev.com\/?p=12605"},"modified":"2025-08-21T15:49:03","modified_gmt":"2025-08-21T10:49:03","slug":"opensips-killing-a-plenty-of-dialogs-manually","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=12605","title":{"rendered":"OpenSIPS: killing a plenty of dialogs manually"},"content":{"rendered":"\n<p>This is almost the same as I&#8217;ve already <a href=\"https:\/\/alexeyka.zantsev.com\/?p=1271\" target=\"_blank\" rel=\"noreferrer noopener\">posted<\/a>.<\/p>\n\n\n\n<p>The difference is that now we will kill dialogs not based by the remote side IP address, but based on datestart. There was some short-term connectivity interruption which caused a sudden increase in dialogs count. It&#8217;s normal for such a situation and they will end by the configured lifetime (&#8216;<a href=\"https:\/\/opensips.org\/docs\/modules\/3.6.x\/dialog.html#param_default_timeout\" target=\"_blank\" rel=\"noreferrer noopener\">default_timeout<\/a>&#8216; parameter), e.g. 1 hour.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><a href=\"https:\/\/alexeyka.zantsev.com\/wp-content\/uploads\/2025\/06\/DeepinScreenshot_select-area_20250623131202.png\"><img loading=\"lazy\" decoding=\"async\" width=\"663\" height=\"303\" src=\"https:\/\/alexeyka.zantsev.com\/wp-content\/uploads\/2025\/06\/DeepinScreenshot_select-area_20250623131202.png\" alt=\"\" class=\"wp-image-12606\" srcset=\"https:\/\/alexeyka.zantsev.com\/wp-content\/uploads\/2025\/06\/DeepinScreenshot_select-area_20250623131202.png 663w, https:\/\/alexeyka.zantsev.com\/wp-content\/uploads\/2025\/06\/DeepinScreenshot_select-area_20250623131202-300x137.png 300w\" sizes=\"auto, (max-width: 663px) 100vw, 663px\" \/><\/a><\/figure>\n\n\n\n<p>But what if we don&#8217;t want to wait and if we want to kill them manually?<\/p>\n\n\n\n<p>The idea is to pick dialogs which were created during time range, assuming that you know an average call duration, and it&#8217;s obvious that if such calls are still shown by &#8216;opensips-cli -x mi dlg_list&#8217; , it means that it is not valid alive call and you can kill it.<\/p>\n\n\n\n<p>As it&#8217;s seen on the graph, the increasing was between 12:14 and 12:23. Let&#8217;s say it&#8217;s 12:30 now, and an average call duration is 30 &#8230; 60 seconds. So, we can kill dialogs which were created between 12:14 and 12:23 and which are still visible with &#8216;opensips-cli -x mi dlg_list&#8217;.<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-f7d6dcb83514089d2cdb97fcbcdb358a\"><code>opensips-cli -x mi dlg_list &gt; 2025-06-23_dlg_list.txt<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-7fe7bbf6d3ed69ea8350ca46236974bd\"><code>grep datestart -B5 2025-06-23_dlg_list.txt | grep -B5 \"2025-06-23 12:14:\" | grep ID | awk '{ print $2}' | sed 's\/\"\/\/g' | sed 's\/,\/\/g' &gt; dlgs_12-14.txt\n\ngrep datestart -B5 2025-06-23_dlg_list.txt | grep -B5 \"2025-06-23 12:15:\" | grep ID | awk '{ print $2}' | sed 's\/\"\/\/g' | sed 's\/,\/\/g' &gt; dlgs_12-15.txt<\/code><\/pre>\n\n\n\n<p>&#8230; and so on, up to 12:23. After that you&#8217;ll have several txt files with dialog IDs. Not it&#8217;s time to kill them:<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-red-color has-text-color has-link-color wp-elements-6b753eeee8b06f9ff77c8911ef5c48bd\"><code>for i in `echo $(cat dlgs_12-14.txt)` ; do opensips-cli -x mi dlg_end_dlg $i ; done<\/code><\/pre>\n\n\n\n<p>&#8230; and the same for each file.<\/p>\n\n\n\n<p>So, as a summary commands set we may use this one (just setting date\/time you need):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color has-link-color wp-elements-c83c6d565ad4d8ba5b9b197910dff814\"># remove old files, if they are<br>rm -f dlgs_all.txt dlgs_to_kill.txt<br><br># get all dialogs list<br>opensips-cli -x mi dlg_list &gt; dlgs_all.txt<br><br># just show the oldest dialog and the newest dialog<br>grep datestart dlgs_all.txt | sort | head -n1 ; echo ; grep datestart dlgs_all.txt | sort | tail -n1<br><br># kill all dialogs started at e.g. 2025-08-21 15:0x<br>grep datestart -B5 dlgs_all.txt | grep -B5 \"2025-08-21 15:0\" | grep ID | awk '{ print $2}' | sed 's\/\"\/\/g' | sed 's\/,\/\/g' &gt; dlgs_to_kill.txt &amp;&amp; for i in `echo $(cat dlgs_to_kill.txt)` ; do opensips-cli -x mi dlg_end_dlg $i ; done<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is almost the same as I&#8217;ve already posted. The difference is that now we will kill dialogs not based by the remote side IP address, but based on datestart. There was some short-term connectivity interruption which caused a sudden increase in dialogs count. It&#8217;s normal for such a situation and they will end by [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[304,305,208],"class_list":["post-12605","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-dialog","tag-dialogs","tag-opensips"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12605","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12605"}],"version-history":[{"count":15,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12605\/revisions"}],"predecessor-version":[{"id":12630,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12605\/revisions\/12630"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12605"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}