how to insert dynamic hostname into shared CDR database

Home » Asterisk Users » how to insert dynamic hostname into shared CDR database
Asterisk Users No Comments

So I’m in a situation where I want to consolidate cdr logs. My general
idea is to use cdr_mysql for this.

I know I can do things like

And I can hardcode the hostname for the dialplan on each system.

But what I’d really like to do is have this dynamic, so I can use the
same exact dialplan on multiple hosts, and have hostname dynamically

I went looking for a built-in asterisk variable for this, but haven’t
found anything yet.

I know I can do something like

Set(HOSTNAME=(System(/bin/hostname -s))

But that seems like more overhead than it should take to do this.

Can anybody think of a better way?

Hey, I just discovered

${SYSTEMNAME} * value of the systemname option of asterisk.conf

which was turned off in my asterisk.conf, but then there’s an option called
autosystemname = yes

With that enabled, ${SYSTEMNAME} is giving me what I want.

I also spotted
${ENV(HOSTNAME)} which I assume would let me have whatever is set as
an environmental variable. This didn’t work for me, perhaps because my
asterisk daemon is running in an environment without that variable