<div dir="ltr">Hi Daniel,<div><br></div><div>I am setting the htable as follows:</div><div><br></div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

modparam("htable", "htable", "message_counters=>size=10;autoexpire=10;initval=0;updateexpire=0;")</blockquote><div><br></div><div>* autoexpire=10 to have items expire after 10 seconds (in this example)</div>

</div><div>* updateexpire=0 to force the expiration no matter the items were updated or not</div><div><br></div><div>Yet, I can see the values persist.</div><div><br></div><div><br></div><div>Another concern is that, if I specify a number of child processes in my config (e.g. children=4), then will it be safe to increment the hash table entries in the route block upon receipt of messages? i.e will the table entries that reside in the shared memory be precise? or do I need to lock/unlock them while updating?</div>

<div><br></div><div><br></div><div>Thanks</div><div>Alireza</div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Aug 13, 2014 at 4:07 AM, Daniel-Constantin Mierla <span dir="ltr"><<a href="mailto:miconda@gmail.com" target="_blank">miconda@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Look at the definition of htable parameter, there you have various
    ways to set expires for each item in hash table.<br>
    <br>
    Cheers,<br>
    Daniel<div><div class="h5"><br>
    <br>
    <div>On 13/08/14 05:26, AliReza Khoshgoftar
      Monfared wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Thanks Alex,
        <div><br>
        </div>
        <div>This is exactly the module I needed.</div>
        <div>Now just another small usage question.</div>
        <div>How can I reset the value of all entries in my hash table
          to 0 every, say "10" seconds?</div>
        <div><br>
        </div>
        <div>---------------------</div>
        <div><br>
        </div>
        <div>Here is what I tried, but the values seem to persist:</div>
        <div><br>
        </div>
        <div>Option 1) in the parameter definition set "initval" to 0
          (to have all items 0 initially), "autoexpire" to "10" seconds
          and "updateexpire" to 0 (to force expiration upon the end of
          10 seconds)</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>Option 2) Create a fake route block executed every 10
          seconds (using "rtimer" module), and call
          "sht_rm_value_re("ha=>.*")" inside it.</div>
        <div><br>
        </div>
        <div>None of these seem to be resetting "all" of my entries in
          the hash table to 0, in fact, I can see that the values
          persist and continue increment (as I increment them upon
          receipt of messages). Am I missing sth here?</div>
        <div><br>
        </div>
        <div>Thanks</div>
        <div>Alireza</div>
      </div>
      <div class="gmail_extra"><br>
        <br>
        <div class="gmail_quote">On Tue, Aug 12, 2014 at 3:58 PM, Alex
          Balashov <span dir="ltr"><<a href="mailto:abalashov@evaristesys.com" target="_blank">abalashov@evaristesys.com</a>></span>
          wrote:<br>
          <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
            <div>
              <div>On 08/12/2014 03:56 PM, AliReza
                Khoshgoftar Monfared wrote:<br>
                <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
                  Hi List,<br>
                  <br>
                  I am trying to keep a counter for number of messages
                  received per source<br>
                  ip in my kamailio script.<br>
                  <br>
                  The basic challenge is to keep this data in a neat
                  structure.<br>
                  Ideally, I want some array with keys named after
                  source IP addresses,<br>
                  <br>
                  sth like number_of_messages["10.10.10.10"] = 23<br>
                  <br>
                  Of course, this data structure shall be
                  script-persistent (as opposed to<br>
                  transaction persistent)<br>
                  <br>
                  Is there any suggestion to do this? (keep a record of
                  # of messages<br>
                  received from each source IP address and log them)?<br>
                </blockquote>
                <br>
              </div>
            </div>
            It sounds to me like you're looking for:<br>
            <br>
            <a href="http://kamailio.org/docs/modules/4.1.x/modules/htable.html" target="_blank">http://kamailio.org/docs/modules/4.1.x/modules/htable.html</a><br>
            <br>
            The hash tables reside in shared memory, so the data is of
            global scope and script-persistent.<br>
            <br>
            -- <br>
            Alex Balashov - Principal<br>
            Evariste Systems LLC<br>
            Tel: <a href="tel:%2B1-678-954-0670" value="+16789540670" target="_blank">+1-678-954-0670</a><br>
            Web: <a href="http://www.evaristesys.com/" target="_blank">http://www.evaristesys.com/</a>,
            <a href="http://www.alexbalashov.com/" target="_blank">http://www.alexbalashov.com/</a><br>
            <br>
            Please be kind to the English language:<br>
            <br>
            <a href="http://www.entrepreneur.com/article/232906" target="_blank">http://www.entrepreneur.com/article/232906</a><br>
            <br>
            _______________________________________________<br>
            SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
            mailing list<br>
            <a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a><br>
            <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
          </blockquote>
        </div>
        <br>
      </div>
      <br>
      <fieldset></fieldset>
      <br>
      <pre>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a href="mailto:sr-users@lists.sip-router.org" target="_blank">sr-users@lists.sip-router.org</a>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
    </blockquote>
    <br>
    </div></div><span class="HOEnZb"><font color="#888888"><pre cols="72">-- 
Daniel-Constantin Mierla
<a href="http://twitter.com/#!/miconda" target="_blank">http://twitter.com/#!/miconda</a> - <a href="http://www.linkedin.com/in/miconda" target="_blank">http://www.linkedin.com/in/miconda</a>
Next Kamailio Advanced Trainings 2014 - <a href="http://www.asipto.com" target="_blank">http://www.asipto.com</a>
Sep 22-25, Berlin, Germany ::: Oct 15-17, San Francisco, USA</pre>
  </font></span></div>

<br>_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
<br></blockquote></div><br></div>