thx David, again, for the reply.
The reason I want this is a little bit complicated. So here is the system I have.
- I have inbound Opensips that load balance call to several asterisk server (asterisk 11)
- Each asterisk server then send the call (that came from the inbound opensip) to a outbound opensips (asterisk and outbound opensips is 1:1)
So the other day I ran into issue where the outbound opensips went down thus all the call on that asterisk was failing. But the inbound opensips does not know the outbound opensips went down, thus call was keep getting distributed to that asterisk (which is bad).
Therefore, I needed a way to have asterisk server signal the inbound opensips to not to send call to it if the outbound opensips is down.
So (with the help with a forum member), I start write bash script where the bash scrip will execute asterisk -x ‘sip show peer blah’ and with that response, if the peer show down, it will execute a python script which will send a xmlrpc call to opensips to mark the asterisk node as “down”. When the peer (the opensip) comes back online, it will send a “up” message to inbound opensips.
BUT the issue now is, during “gracefully shut down”, and that the script runs every 3 minutes, it will keep telling opensips to turn the node “up” when it is mark as “down”.
Just quickly explain how opensips detect asterisk as “up” or “down”. Once asterisk IP gets added into opensips load balancer table, opensips will constantly send a SIP OPTION message to query if the asterisk is up. Once asterisk is in the process of gracefully shut down, opensips will mark the node down because of the negative result it gets from the asterisk’s SIP OPTION query. So, now with the job running, it will tell opensips to mark the node “up” and then 10 seconds later (when opensips send the OPTION query), opensips will mark it down again, and the process repeats until asterisk shut down.
So I really need a way where in my bash scrip, I can do some sort of “function call” to see what is the status of asterisk. If is in the process of gracefully shut down, DO NOT send “up” message to opensips.