[SR-Users] Understanding hashtable usage

aft aftnix at gmail.com
Wed Aug 27 13:50:50 CEST 2014


Hi,

I've got a piece of config code which should solve my problem, but i'm
not getting the code. It involves hashtable module. Here it goes :

modparam("htable", "htable", "a=>size=8;autoexpire=400")
modparam("htable", "htable", "b=>size=8;autoexpire=31")

Ok we have two hashtable , a and b, both has a "size" of 8.

Then,

else if(status == "503") {
               if($sht(a=>alarm::503) == $null) $sht(a=>alarm::503)=0;
               $sht(a=>alarm::$si::503) = $sht(a=>alarm::$si::503) + 1;
       }

Here i get lost. what's "a=>alarm::503" and what's
"a=>alarm::$si::503"? What's there difference?

Next the code goes like :(its supposed be pseduocode)

$elem = the size of the sht array.

while($i < $elem) {
$src_ip = $sht(source_ip_array)[$i];
$i = $i +1;
sql_query("cb", "INSERT INTO alarm_data (create_date, type, total,
description, source_ip) VALUES(NOW(), 'Too Many 503',
$sht(a=>alarm::$src_ip::503), 'service unavailable', '$src_ip')");
}


Now i have couple of problems with this code

[1] what should be the value of $elem?
[2] $sht(source_ip_array)[$i]? what should be the value of source_ip_array?


The thing i'm trying to do is, when a 503 (Service unavailable) comes
to kamailio, I want to insert it into a database which records this.

-- 
-Cheers
-Arif



More information about the sr-users mailing list