<div dir="ltr">Hello,<div><br></div><div>It works, but:</div><div>1) get_timestamp doesnt work inside has_totag section           </div><div> if (has_totag()) {   </div><div>    if (loose_route()) {</div><div>          if (is_method(&quot;BYE&quot;)) {</div>
<div>              get_timestamp($avp(secbye),$avp(usecbye));</div><div>              .....</div><div>              .....</div><div>but works if called before that section</div><div><br></div><div>2) because i need to count duration, i should rather place it inside onreply_route</div>
<div>         if (t_check_status(&quot;200&quot;)) {</div><div>                get_timestamp($avp(sec),$avp(usec));</div><div>        }</div><div> but the question is how it will behave in case of reINVITE is triggered from the originating side.</div>
<div>I think $avp(sec),$avp(usec) will be overwritten.</div><div>So maybe wise idea will be to set some flag in first 200 message and make another statement like if ((t_check_status(&quot;200&quot;)) &amp;&amp; !(isflagset(XX))) </div>
<div><br></div><div>What do you think about p1 and p2?</div><div><br></div><div>Thanks</div><div>Mac</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-14 12:56 GMT+02:00 Maciej Bylica <span dir="ltr">&lt;<a href="mailto:mbsip@gazeta.pl" target="_blank">mbsip@gazeta.pl</a>&gt;</span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Vlad,<div><br></div><div>Thanks for reply.</div><div>I am using OpenSIPS (1.9.1-notls (x86_64/linux)) so get_timestamp is available there.</div>
<div>Let me check this.</div><div><br></div><div>Regards,</div>
<div>Mac</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-04-14 10:57 GMT+02:00 Vlad Paiu <span dir="ltr">&lt;<a href="mailto:vladpaiu@opensips.org" target="_blank">vladpaiu@opensips.org</a>&gt;</span>:<div>
<div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Hello,<br>
      <br>
      Which OpenSIPS version are you using ?<br>
      You could use get_timestamp [1] from the Core to get the current
      second and microsecond,<br>
      and set the two variables at INVITE time, and set them as db_extra
      [2] .<br>
      <br>
      Then, at BYE time call again the get_timestamp function, store
      them in some AVPs and set those AVPs in [3]. This way you should
      get both the INVITE and BYE timestamps with microseconds precision
      in the CDR record.<br>
      <br>
      [1]
      <a href="http://www.opensips.org/Documentation/Script-CoreFunctions-1-10#toc18" target="_blank">http://www.opensips.org/Documentation/Script-CoreFunctions-1-10#toc18</a><br>
      [2]
      <a href="http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295028" target="_blank">http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295028</a><br>
      [3]
      <a href="http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295056" target="_blank">http://www.opensips.org/html/docs/modules/1.10.x/acc.html#id295056</a><br>
      <br>
      Best Regards,<br>
      <pre cols="72">Vlad Paiu
OpenSIPS Developer
<a href="http://www.opensips-solutions.com" target="_blank">http://www.opensips-solutions.com</a> </pre><div><div>
      On 12.04.2014 23:44, Maciej Bylica wrote:<br>
    </div></div></div><div><div>
    <blockquote type="cite">
      <div dir="ltr">Hello Ryan,
        <div><br>
        </div>
        <div>I am using dialog accounting, so each row is fully
          qualified cdr record, not only single transaction of a call.</div>
        <div>Couldn&#39;t i just use two extra db variables which will
          gather the $time inside INVITE {} and BYE {}?</div>
        <div><br>
        </div>
        <div>Thanks,</div>
        <div>Mac</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">2014-04-12 6:39 GMT+02:00 Ryan Mitchell
          <span dir="ltr">&lt;<a href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;</span>:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div dir="ltr">Hello Mac,
              <div><br>
              </div>
              <div>Each row in the acc table is for a transaction.  To
                make a proper CDR out of the data, you have to combine
                rows to find the start and end of the call.  That can be
                harder than it sounds, especially with forking
                (parallel, or the more common case of serial forking
                when you are LCR routing or simply sending calls to alt
                destinations after a timeout).  I wrote scripts that
                implement a simple dialog state machine to make sense of
                all the distinct legs of a call, though there should be
                an easier way with the auto-cdr / multi call-legs
                accounting feature of the acc module (anyone comment on
                this please?).</div>
              <div><br>
              </div>
              <div>The time field in the acc table will be the timestamp
                of the response for the given transaction.  If you
                assign an extra field for another timestamp, it will
                depend on where you assign that var in your script.  In
                my case I assign it in the main routing section so the
                timestamp indicates the start of the transaction.</div>
              <div><br>
              </div>
              <div>best regards,</div>
              <div>Ryan</div>
              <div>
                <div>
                  <div><br>
                  </div>
                  <div class="gmail_extra"><br>
                    <br>
                    <div class="gmail_quote">On Fri, Apr 11, 2014 at
                      10:06 AM, Maciej Bylica <span dir="ltr">&lt;<a href="mailto:mbsip@gazeta.pl" target="_blank">mbsip@gazeta.pl</a>&gt;</span>
                      wrote:<br>
                      <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                        <div dir="ltr">Ryan,
                          <div><br>
                          </div>
                          <div>One more question.</div>
                          <div>Currently i have some db extra attrs
                            setup. My acc table looks like following:</div>
                          <div>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              Field      | Type             | Null | Key
                              | Default | Extra          |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              id         | int(10) unsigned | NO   | PRI
                              | NULL    | auto_increment |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              method     | char(16)         | NO   |    
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              from_tag   | char(64)         | NO   |    
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              to_tag     | char(64)         | NO   |    
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              callid     | char(64)         | NO   | MUL
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              sip_code   | char(3)          | NO   |    
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              sip_reason | char(32)         | NO   |    
                              |         |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              time       | datetime         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              duration   | int(11) unsigned | NO   |    
                              | 0       |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              setuptime  | int(11) unsigned | NO   |    
                              | 0       |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              SourceAddr | char(30)         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              DestAddr   | char(30)         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              Anum       | char(30)         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              Bnum_rU    | char(30)         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              Bnum_tU    | char(30)         | NO   |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">|
                              created    | datetime         | YES  |    
                              | NULL    |                |</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">+------------+------------------+------+-----+---------+----------------+</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo"><br>
                            </p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo;color:rgb(83,48,225)">
                              <span style="color:rgb(206,121,36)">modparam(&quot;acc&quot;,
                                &quot;db_extra&quot;, &quot;SourceAddr=$si</span>;
                              DestAddr=$rd; Anum=$fU; Bnum_rU=$rU;
                              Bnum_tU=$tU&quot;)</p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo">
                              <br>
                            </p>
                            <p style="margin:0px;font-size:11px;font-family:Menlo"><span style="font-family:arial;font-size:small">Now using additional data like
                                $time will give me the exact moment the
                                call is ended, nothing more, am i right?</span></p>
                            <p style="margin:0px">To have detailed call
                              duration i need to know exact answer and
                              disconnect timestamps.</p>
                            <p style="margin:0px"><br>
                            </p>
                            <p style="margin:0px">Btw: i am using<span style="font-family:Menlo;font-size:11px"> OpenSIPS
                                (1.9.1-notls (x86_64/linux))</span></p>
                            <p style="margin:0px"><br>
                            </p>
                            <p style="margin:0px">Thanks,</p>
                            <p style="margin:0px">Mac</p>
                          </div>
                        </div>
                        <div class="gmail_extra"><br>
                          <br>
                          <div class="gmail_quote">
                            <div>2014-04-10 22:03 GMT+02:00 Ryan
                              Mitchell <span dir="ltr">&lt;<a href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;</span>:<br>
                            </div>
                            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                              <div dir="ltr">Using db_extra to stuff
                                custom data into your acc table, use the
                                $time var with a format such as &quot;%s.%N&quot;
                                or similar.
                                <div>
                                  <div>
                                    <div>
                                      <br>
                                    </div>
                                    <div>Or, as you suggested, do it on
                                      the database level with a trigger
                                      or auto-update column.</div>
                                    <div><br>
                                    </div>
                                    <div class="gmail_extra"><br>
                                      <br>
                                      <div class="gmail_quote">
                                        <div>
                                          <div>On Thu, Apr 10, 2014 at
                                            10:01 AM, Maciej Bylica <span dir="ltr">&lt;<a href="mailto:mbsip@gazeta.pl" target="_blank">mbsip@gazeta.pl</a>&gt;</span>
                                            wrote:<br>
                                          </div>
                                        </div>
                                        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                                          <div>
                                            <div>
                                              <div dir="ltr">
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">Hello</span><br>
                                                </div>
                                                <div><font face="arial,
                                                    sans-serif"><span style="white-space:nowrap"><br>
                                                    </span></font></div>
                                                <div><font face="arial,
                                                    sans-serif"><span style="white-space:nowrap">I
                                                      just want to know
                                                      how to achieve
                                                      miliseconds
                                                      precision for
                                                      accounting module.</span></font></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">This
                                                    is quite important
                                                    while trying to sum
                                                    up total traffic
                                                    duration with the
                                                    accuracy of hundred
                                                    of ms.</span><br>
                                                </div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">As
                                                    i see there is no
                                                    rounding feature
                                                    implemented as well,
                                                    but heaving ms
                                                    precision it could
                                                    be done directly on
                                                    DB level.</span></div>
                                                <div>
                                                  <span style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">Could
                                                    somebody give me a
                                                    hand.</span></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif"><br>
                                                  </span></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">Thanks
                                                    in advanced</span></div>
                                                <div><span style="white-space:nowrap;font-family:arial,sans-serif">Mac</span></div>
                                                <div><br>
                                                </div>
                                                <div><br>
                                                </div>
                                              </div>
                                              <br>
                                            </div>
                                          </div>
_______________________________________________<br>
                                          Users mailing list<br>
                                          <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
                                          <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                                          <br>
                                        </blockquote>
                                      </div>
                                      <span><font color="#888888"><br>
                                          <br clear="all">
                                          <div><br>
                                          </div>
                                          -- <br>
                                          Ryan Mitchell &lt;<a href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;<br>
                                          Telecom Logic, LLC<br>
                                          <br>
                                        </font></span></div>
                                  </div>
                                </div>
                              </div>
                              <div>
                                <div>
                                  <br>
_______________________________________________<br>
                                  Users mailing list<br>
                                  <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
                                  <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                                  <br>
                                </div>
                              </div>
                            </blockquote>
                          </div>
                          <br>
                        </div>
                        <br>
                        _______________________________________________<br>
                        Users mailing list<br>
                        <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
                        <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
                        <br>
                      </blockquote>
                    </div>
                    <br>
                    <br clear="all">
                    <div><br>
                    </div>
                    -- <br>
                    Ryan Mitchell &lt;<a href="mailto:rjm@tcl.net" target="_blank">rjm@tcl.net</a>&gt;<br>
                    Telecom Logic, LLC<br>
                    <br>
                  </div>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Users mailing list<br>
            <a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
            <a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><br>
            <br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
Users mailing list
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div></div></div><br></div>
</blockquote></div><br></div>