Berkeley Database File

I have an Asterisk box that is going to be used solely for voicemail. Users don’t register with it, instead they register with an OpenSER box. Therefore the Asterisk Voicemail server has no knowledge of where it’s phones are and can’t sending notifications when there are new voicemails.

I got around this by writing a perl script that queries the MySQL database location table on OpenSER and creates new key/value pairs in the /var/lib/asterisk/astdb file, thereby allowing the Asterisk voicemail server to know where the phones are.

Seems to work great considering it took me less than an hour to hack it together.

Problem is however, that once this file is modified, Asterisk doesn’t know it’s been updated. A ‘reload’ doesn’t cause it to re-read the file. Shutting Asterisk down and restarting it does, but that’s not an option. I tried ‘reload’ but it said that module doesn’t support reloading. Asterisk must re-read this file, because it’s used for a whole bunch of things. Any ideas?

One other quirky thing I noticed too, that was when Asterisk loads, and the file already has key’/value pairs that I populated it with, it strips the last character of the key and the value… so I got around it by appending a space to the end of the key and the value… then Asterisk strips the space… Weird… wonder why it does that.


Post what you wrote and any example data and I would be happy to play around and see how it might be solved.

Thanks, but I don’t know if pasting the perl script is necessary.

Simple question… how can I get Asterisk to reload it’s astdb file without stopping and restarting it.

Another approach I just tried was to again, query the SER database, but this time use sipsak to send a registration pack to Asterisk and let Asterisk handle updating the astdb file. Sipsak isn’t exactly easy to use.

Command is:
sipsak -U -C sip:1000000101@ -s sip:1000000101@ -x 3600 -a foo

It’s sending:

U ->
REGISTER sip: SIP/2.0.
Via: SIP/2.0/UDP;branch=z9hG4bK.4cf27bce;rport.
From: sip:1000000101@;tag=43ca2c41.
To: sip:1000000101@
Call-ID: 1137323073@
Content-Length: 0.
Max-Forwards: 70.
User-Agent: sipsak 0.9.2.
Expires: 3600.
Contact: sip:1000000101@

and Asterisk is trying to send the reponse to… no idea why. Asterisk and sipsak are on different systems.

Wooo! I got it to work with sipsak. Much easier I think…

For now, I set insecure=very in sip.conf so that Asterisk wouldn’t ask for a password. It still tries to send the OK response back to, but that’s ok cuz it’s still registered the user.

Asterisk logs to console:
– Saved useragent “sipsak 0.9.2” for peer 1000000201
– Saved useragent “sipsak 0.9.2” for peer 1000000101

I leave a voicemail, and both phones get the MWI light. Nifty… now just to work out why Asterisk tries to send the OK to the REGISTER to

Allright… sipsak was inserting a Via header of which was causing Asterisk to send packets back to itself.

This works…
sipsak -U -C sip:1000000101@ -s sip:1000000101@ -x 3600 -a foo -n

I even turned on password authentication in Asterisk. So, now my script queries the location table on SER, and uses sipsak to notify the Asterisk voicemail server of the location of users by sending a REGISTER packet with password authentication.

That’s sweet…

Well done.

Well there’s an even simpler way to get it to send Notify…
If you can get you SER box to send the Subscribe to asterisk, then you just need to set up each ‘phone’ as a Peer in the asterisk

And when the Subscribe SIP message get’s to asterisk, it will correctly send back a Notify…
Just set up each phone as:

Works for me (not with a SER box, but should work the same)

Not quite sure what you mean there. Who’s initiating the SUBSCRIBE message?

Actually, for a moment I thought it had gotten even easier. I use the t_replicate() function in OpenSER to, upon registration, replicate the registration to the Asterisk voicemail server. Asterisk gets the registration and then sends unauthorised, which means that OpenSER has to send credentials. Not sure about how to do that yet…

Sweetest of all!

            if (method=="REGISTER") {

                    # Uncomment this if you want to use digest authentication
                    if (!www_authorize("", "subscriber")) {
                            www_challenge("", "0");


Now, that’s nice. Every time ser gets a registration, it copies it to the asterisk boxes. Schweet…