Asterisk Debug Gotcha

I was working on an issue being experienced by someone remotely attached to my asterisk machine, and found an abnormality.

I use a realtime implementation to allow for easy addition of users and to have the data I want in MySQL (makes it easier to monitor activity in CDR, etc). The problem recently was as a result of an upgrade, there appears to be changing to Asterisk’s debug log. Previously, Asterisk debug output would end up in the full log.

This made it easy to review the traces of an issue being experienced, and follow them back to the source – the log would simply contain the full sequence of issues leading up to the ‘issue’, and what happened after.

The newer version of asterisk however doesn’t enable debugging unless the startup option ‘-d’ is specified. safe_asterisk restarts asterisk in the event it bombs out – and one has to admit – crashing doesn’t happen often with asterisk, it’s ‘reliable’.

So, whilst I was reading the log, I was seeing messages such as:
” res_config_mysql.c: MySQL RealTime: Failed to query database. Check debug for more info.”

That’s a nice warning, it tells me to find the source of the issue, check into asterisk debug log. So we open the seperate file appointed to debug (it removes clutter), and it’s empty.

So, I look into the asterisk configuration file – is debug enabled? Of course it is. Spelt correctly? Yep. Where’s the debug – how can you debug a bug without debug?

I check Asterisk ‘logger show channels’ – this is described to show logging channels.

Sure enough, there is a line that states my ‘debug’ log is of “File” type, and is “Enabled” and is configured to be “Debug”. Asterisk isn’t doing anything wrong there.

Then I look into ‘help’ – core set debug. Could it really be, asterisk requires the debug option to be set? It does. You can set it there, or alternatively, you can have it enabled on startup in using safe_asterisk.

In the safe_asterisk script (nano -w /usr/sbin/safe_asterisk) – find “ASTARGS” and edit it to include a “-d” – this enables asterisk debugging information to a log file, by default, asterisk doesn’t log debug information.

This is confusing. The problem turns out that real-time now has an additional field required – ‘regserver’, adding that field seems to have caused asterisk to stop spewing the error message.

The issue may be ‘better’ managed by asterisk real time mysql having a seperate SQL based log for any errors it experiences. In a production system, you might not have so many errors.

Although, another point to note is the mysql realtime module is very chatty:
 res_config_mysql.c: MySQL RealTime: Connection okay.
res_config_mysql.c: MySQL RealTime: Retrieve SQL: SELECT * FROM sip_buddies WHERE name = ”
res_config_mysql.c: MySQL RealTime: Connection okay.
res_config_mysql.c: MySQL RealTime: Retrieve SQL: SELECT * FROM sip_buddies WHERE name = ” AND host = ‘dynamic’
res_config_mysql.c: MySQL RealTime: Connection okay.
This query might return no results, so it begs to question why is it even executed?

Enjoy!

This entry was posted in Linux, Programming, Random. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *