Verifying Asterisk config file structure

HI all,

yesterday, we had a problem and takes some time to find it : a “)” was misplaced :slight_smile:

Is there a program, or asterisk option, that can parse the conf files and tell if the structure is ok ?
For those who knows something like config check on NGinX or HAProxy

It seems quite an obvious thing, but i was unable to find that

Thanks !

run : core set verbose 9
then reload the module related to your wana check file

1 Like

A lot of parsing is delegated,. That means that there is no central part of the system that knows the full syntax.

1 Like

Hi and thanks for your quick reply.
The main file i’m trying to verify is “extention.conf”, which module should i reload ?

Yes this is why i was hoping someone wrote a utility like “checkmyconf /etc/asterisk/extention.conf” :slight_smile:
A utility that only verifies that syntax is ok, nothing more

That file doesn’t exist. I think pbx.c is part of the core, so you would need to use the special command: dialplan reload. You may need to touch the file, that it is treated as updated.

However the format of the parameters field is only checked at run time when actually used. If the error is in the fully substituted parameters for a command, that command has to be executed. Generally anything beginning with $ and some form of bracket is evaluated before the command is run.

If you need to know which module relates to which config file then what you really need is to read the Asterisk book, as for the syntax I find vim very useful, it does not show the errors exactly but you will notice that the highlighting is not right where there are errors, I guess you still need some getting used to.

This may be of interest:

Asterisk PBX configuration syntax checker

1 Like

Ok, thanks David, this is exactly what i did, a “dialplan reload”, which seems the most obvious for me

Yes khamlichi.khalil vim help us a lot but sometimes parenthesis mismatch or so are not easy to see
And yes, i need to go forward into reading docs, and this is what i do everydays :slight_smile:

sedwards,

i just read the link and yes this seems really to be what we were looking for.
We will give a deeper look and come back with updates !

It looks like it is only a heuristic checker, and I note that expressions are not parsed.

One other point to note is that syntactic elements can be included in “variables”, as they are really macros, so it is possible to construct dialplans that cannot be statically validated.

Hi David,

yes and it seems to have lots of bugs, it crashes a lot… The author says it is not really stable.
This is a realy a good idea but it have to improve.
My first will would be to be sure that all {,[,(,),],},",… are correct !
Vim helps when typing, but a post verification would be great.

I tried it (the online version, https://asterisklint.osso.pub/) using a production dialplan which is written in AEL, which it does not understand.

After munging ‘dialplan show’ into ‘basic dialplan,’ it reported over 300 errors that are mostly stylistic

    E_VAR_BAD_TOKENS: bad tokens in variable name 'CALL-ID'
    W_APP_BAD_CASE: app 'agi' does not have the proper Case 'AGI'
    W_WSH_BOL: unexpected leading whitespace

It also fails parsing statements like ‘exten = foo,1,…’ because it thinks the ‘>’ is important.

The program appears to ‘know’ all of the Asterisk application names, but not some ‘newer’ ones like:

    E_APP_MISSING: app 'MSet' does not exist, dialplan will halt here!
    E_APP_MISSING: app 'stopmonitor' does not exist, dialplan will halt here!

It did note a missing closing bracket and a missing closing brace, but did not note a missing closing parenthesis.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.