kamailio load balancing with dispatcher - kamailio

I am configuring kamailio with 2 or more asterisk servers from dispatcher. I configured dispatcher table with 2 asterisk servers.
+----+-------+------------------------+-------+----------+---------------------------------------+-------------+
| id | setid | destination | flags | priority | attrs | description |
+----+-------+------------------------+-------+----------+---------------------------------------+-------------+
| 1 | 1 | sip:*.*.*.*:5160 | 2 | 1 | duid=ABC;maxload=0;my=XYZ | sip 1 |
| 2 | 1 | sip:*.*.*.*:5160 | 2 | 1 | duid=DEF;weight=10;maxload=1;my=SRV02 | sip 2 |
+----+-------+------------------------+-------+----------+---------------------------------------+-------------+
In kamailio.cfg file i configured as
ds_select_dst("1", "10");
I am getting problem while connecting to asterisk. It's giving error and it's taking first entry from dispatcher table.
Error is :
ERROR: dispatcher [dispatch.c:1748]: ds_select_dst_limit(): no dst ID avp for load distribution - using first entry...
Could you please tell me the configuration with argument 10 in ds_select_dest();
and what should i give in "dstid_avp".

The parameter dstid_avp has to be set to a name of an AVP variable and be sure that the AVP is not used by anything else but dispatcher module. For example:
modparam("dispatcher", "dstid_avp", "$avp(dsdstid)")
If $avp(dsdstid) is not used anywhere else in the config, then all should be fine. Actuallt, the AVP can be used for reading its value, but do not delete or modify it.
As extra remark, it might be needed to set the other dispatcher parameters sufixed with _avp (e.g., if you want failure re-routing), the examples from the README of the dispatcher module can be simply taken and added to kamailio.cfg.

Related

Why Gnocchi apply 'server_group' to resource slowly?

I add the metadata "metering.server_group":"corey-group" to an instance while creating, and check it by using nova show, it is applied, then I check the Gnocchi resource using gnocchi resource show --type instance ${instance-id}, the attribute server_group is None in the begining, but after a while, it will be applied (always on the hour, ex: 07:00, 08:00...), I have no idea what happens, I think this issue will cause Gnocchi gets incorrect datasets while doing aggregation, so I spent some times to troubleshoot it.
First of all, the attributes of Gnocchi resource stored in database:
MariaDB [(none)]> use gnocchi
MariaDB [gnocchi]> select * from resource_type where name='instance';
# check its tablename, ex: rt_xxxxxx
MariaDB [gnocchi]> select * from rt_xxxxxx where display_name='corey-vm';
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
| display_name | host | image_ref | flavor_id | server_group | id | flavor_name |
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
| corey-vm | corey-test-com-001 | NULL | 26e46b4c-23bd-4224-a609-29bd3094a18e | NULL | xxxxxx | corey-flavor |
+----------------+---------------------+-----------+--------------------------------------+-------------------------+------------------+---+
As you can see, the column server_group should be corey-group, but it is always NULL when the instance is just created, and seems like ceilometer updates the resource per hour on the hour.
I added some log in the file ceilometer/publisher/gnocchi.py, and found that it updates resource every minutes, but the variable resource_extra gets server_group only on the hour, that's why it is None is the begining.
Here are some parts of the logs
2020-11-09 11:59:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_id': u'xxx', 'flavor_name': u'xxx'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
2020-11-09 12:00:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_name': u'xxx', 'server_group': 'corey-group'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
2020-11-09 12:01:15 DEBUG ceilometer.publisher.gnocchi Resource {'host': u'test-com-002', 'display_name': u'vm-001', 'flavor_id': u'xxx', 'flavor_name': u'xxx'} publish_samples /usr/lib/python2.7/site-packages/ceilometer/publisher/gnocchi.py:345
But I stuck at this point, I can't understand why the variable resource_extra can't gets server_group each time. What causes this happpening exactly? (Running on Queens)
I would appreciate any ideas.
Update 09/11/2020
After some days of troubleshooting, I still can't find the root cause.
But I found a command line to apply the 'server_group' manually, that can help me to avoid Gnocchi gets incorrect datasets to aggregate.
Here it is:
gnocchi resource update --type instance -a server_group:corey-group ${resource_id}
Update 11/11/2020
I tried to grep the integer 3600 and modify them to 300, but nothing changed, below are what I've tried.
/etc/ceilometer/ceilometer.conf
[compute]
resource_cache_expiry = 300
ceilometer/compute/discovery.py
cfg.IntOpt('resource_cache_expiry',
default=300,
ceilometer/publisher/zaqar.py
DEFAULT_TTL = 300
Update 12/11/2020
I can't reproduce this issue on Pike.
Maybe you can refer to the following discussions:
Heat autoscaling with gnocchi based aodh alarms requires use of naive instance_discovery_method setting with ceilometer compute agents?
According to the reference, try to change the default instance_discovery_method from "libvirt_metadata" to "naive" in ceilometer config file, like this:
[compute]
instance_discovery_method = naive
Switching to "naive" resolves this issue, however it obviously generates load on the Nova API for metadata retrieval.

Cannot reference Alice fixture in EntityContext following step (KnpLabs/FriendlyContexts) - Behat

I use the really cool knplabs/friendlycontexts bundle to test VictoireDCMS, a Symfony2 open source DCMS.
Actually, this is working pretty well in spite of the kind of my project (not a basic symfony-project architecture but a suite of bundles with a functionnal test application).
But... I'm now blocked to use alice reference in the EntityContext. The documentation give these examples :
user.yml
App\Entity\User:
user-john:
firstname: John
lastname: Doe
user-admin:
firstname: Admin
lastname: Admin
my.feature
#alice(User)
Feature: My feature
The feature description
Background:
Given the following products
| name | user |
| Ball | John |
| Shoes | Admin |
...
This is really looking good and is exactly what I want to do and here is my code:
template.yml (full file)
Victoire\Bundle\TemplateBundle\Entity\Template:
template_base:
name: Base
...
my.feature (full file)
Given the following page:
| name | slug | locale | template |
| tatooine | tatooine | fr | base |
Unfortunatelly, it doesn't work properly and I have this error when I run my feature :
Expected value of type
"Victoire\Bundle\TemplateBundle\Entity\Template" for association field
"Victoire\Bundle\PageBundle\Entity\BasePage#$template", got "string"
instead. (Doctrine\ORM\ORMInvalidArgumentException)
I can't figure this out and can't see any difference btw the example and my code... Any help would be appreciated.

Self cookies in cross-domain iframe not working

I've got the situation below:
+-------------------------+
| not-my-website.com |
| +--------------------+|
| | my-website.local ||
| | ||
| |(Can't read or write||
| |its own cookies) ||
| | ||
| +--------------------+|
+---+---------------------+
My problem is that my-website.local is not able to write or read its own cookies (my-website.local cookies).
Most surprising is that google chrome developer console displays the cookies that was existing before (from an another tab where my-website.local in full page), but it does not send cookies with the request to load the iframe content.
Is there a way to get this working ?
Thank you

Partial caching and fiddler?

I'm building a website page with asp.net (webforms).
I'm using partial caching (output caching) for a page. So A and B (user controls) are cached. (while the page is not). Is there any way I can see in Fiddler that A and B are retrieved from the cache while the page is not?
___________________
| Page |
| ____ |
| + + |
| | A |(ascx) |
| +____+ |
| |
| |
| ____ |
| + + |
| | B |(ascx) |
| +____+ |
| |
| |
___________________
edit
Lets say A.ascx contains only :
<span>Hello A</span>
and B.ascx contains only :
<span>Hello B</span>
and the output cache location is "Private" ( for the ascx only !).
Fiddler shows all HTTP requests/responses as they are loaded by your browser.
If A and B are cached by the client, then when the page loads, you will not see requests for either A or B in Fiddler, except on the very first page load. On the first load, A and B will be downloaded (you will see them in Fiddler) and cached on the client.

Multiple onClick events firing

I have several divs that are nested within each other. Each has it's own onclick event. So, imagine that it's like a sandwich, the bottom layer is bread (this layer is geographically larger than the ones that are nested inside),then there's lettuce and then tomato on top.
So, it looks like this:
---------------------------
| Bread |
| |
| ----------------------- |
| | Lettuce | |
| | | |
| | ------------------- | |
| | |Tomato | | |
| | | | | |
| | | <*click> | | |
| | | | | |
| | | | | |
| | ------------------- | |
| ----------------------- |
---------------------------
Currently, when the user clicks on the tomato, it fires off the proper sequence for the tomato, but then things go awry. Because as soon as it fires tomato, it recursively fires lettuce, and then finally the bread.
I suppose it does this because technically the user DID click within those divs, but only because tomato is nested inside them.
The way it should work is that if the user clicks on the Tomato portion of the sandwich, then it should fire off only tomato's event. On the other hand, if the user clicks on the lettuce portion that is peeking out behind tomato, then it should fire lettuce.
So, my question is whether it is possible to make the divs "opaque" for clicks so that even though they are nested inside each other, only the one that was actually clicked on counts.
You can add a return false after your current handler code to prevent the click from bubbling up or propagating...this is what causes the click events on the parent elements.
I would suggest the following reading for a better understanding of what's happening: quirksmode.org's excellent explanation of event bubbling.
In non-IE browsers event.stopPropagation(); will stop the event from bubbling up to parent nodes, in IE, event.cancelBubble = true; should do the trick. event is the argument passed to the listener.
Hey guys, thanks for the help. Unfortunately, I think I may have inadvertently left out a vital piece of information. The JS in this case is actually firing an AJAX request back to the server. So, for some reason in this type of situation the "return false" on the event handler didn't work.
I suspect that the XMLHttpRequest call to the server was probably all fired at the same time.
However, I was able to fix the problem by putting a block-level (empty) <a> tag inside the div, and then putting my click event on the <a> tag instead of the <div>.
So I just changed the code from this:
<div class='container' id='idstring' onclick="ajaxcall(parameters)">
<? server-side call to recursive function ?>
</div>
To this:
<div class='container' id='idstring'><a onclick="ajaxcall(parameters)">
<? server-side call to recursive function ?>
</a></div>

Resources