Wednesday, May 29, 2013

Five Kamailio command line parameters for troubleshooting

In an era where clicks are ruling the interaction with computers, many people forget that most of applications provide a bunch of command line parameters, some of them quite useful.
It the case of Kamailio, not being the case of a GUI application but a daemon, the control is still done from the terminal, however that's usually via service or init.d scripts. The result is pretty much the same, not many pay attention to what parameters can be given from command line.

There are couple of them related to troubleshooting, which in various cases can save precious moments and make the operating of Kamailio deployments easier. Here are those that you should have always in mind for quick troubleshooting and safety checks.

1) - c - syntax checking of configuration file

No matter how simple changes you think you did to your config file, especially in production environments, do not forget to check for syntax errors. You never know when a key was pressed accidentally without notice. Kamailio can still fail to start for other reasons (e.g., invalid user or password for database), but at least the structure of the configuration file is correct.

Therefore have in mind to run a 'kamailio -c ...' before restarting kamailio.

2) -E - print log messages to standard error

This option can be controlled also via log_stderror global parameter in configuration file. But I don't like changing configs just for temporary needs. Besides that, it many cases (e.g., production environment), editing files can take too long.

I use it mainly with the next one (-d) and I do not want to pollute the log file by an increase of debug verbosity.

Stoping kamailio and starting it with -E -d... for watching live the log messages is helping me a lot. Typically I want to see some INFO, NOTICE or WARNING messages added in config file for a particular purpose, where normal operation mode is having a lower debug threshold like ERROR.

3) -d - increase debug level

This option is the solution to increase the verbosity of log messages without editing the configuration file. Used together with -E, you can watch the messages on the screen. Used alone, the syslog file will be filled with more messages, watching it in real time can be done with 'tail -f ...'.

4) -e - print colourful log messages

When the terminal has the capability to display colourful text, this option enables Kamailio to write the log messages in different colours, depending on log level. It requires -E, otherwise the log message would get non-ASCII content.

5) -A - add a pre-processor define

The queen option of controlling the config file, -A can be used to add pre-processor defines. No need to edit the file to define WITH_DEBUG, you can just start kamailio with '-A WITH_DEBUG'.

Many of my configs are having various #!ifdef's that I can turn on/off from command line just for troubleshooting purposes. Play with it, you are going to like it.

No comments:

Post a Comment